Permalink
Browse files

[Linter] Take into account the comments ratio

  • Loading branch information...
1 parent 8edbb21 commit 438797791311b1a7e21a43e9476dc59010f2e734 @fabiopelosin fabiopelosin committed Mar 22, 2013
Showing with 5 additions and 2 deletions.
  1. +4 −1 lib/cocoapods-core/specification/linter.rb
  2. +1 −1 spec/specification/linter_spec.rb
@@ -92,7 +92,10 @@ def perform_textual_analysis
text = @file.read
error "`config.ios?` and `config.osx?` are deprecated." if text =~ /config\..?os.?/
error "clean_paths are deprecated (use preserve_paths)." if text =~ /clean_paths/
- warning "Comments must be deleted." if text.scan(/^\s*#\s+/).length > 24
+ all_lines_count = text.lines.count
+ comments_lines_count = text.scan(/^\s*#\s+/).length
+ comments_ratio = comments_lines_count.fdiv(all_lines_count)
+ warning "Comments must be deleted." if comments_lines_count > 20 && comments_ratio > 0.2
end
# Checks that every root only attribute which is required has a value.
@@ -153,7 +153,7 @@ def message_should_include(*values)
message_should_include('summary', 'punctuation')
end
- it "checks to make sure there are not too many comments in the file" do
+ it "checks that there are not too many comments in the file" do
podspec = "# some comment\n" * 30
path = SpecHelper.temporary_directory + 'BananaLib.podspec'
FileUtils.cp @podspec_path, path

0 comments on commit 4387977

Please sign in to comment.