diff options
| author | Mike McQuaid | 2017-10-17 21:29:24 +0100 |
|---|---|---|
| committer | GitHub | 2017-10-17 21:29:24 +0100 |
| commit | 69d28f9d8f0c13c1d38dda08470f9dd774eae683 (patch) | |
| tree | d7662ec66c171024c9d8b29c2f9f2346f30f19f8 /Library | |
| parent | 77f3fcf25455c8ad6a6ae9c4723f638c611c0c26 (diff) | |
| parent | 29070e5cbecad6553b29bb482ce94352682b9c64 (diff) | |
| download | brew-69d28f9d8f0c13c1d38dda08470f9dd774eae683.tar.bz2 | |
Merge pull request #3294 from DomT4/an_empty_string_is_a_naughty_desc
formula_desc_cop: empty string is not a valid desc
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/rubocops/formula_desc_cop.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb | 21 |
2 files changed, 28 insertions, 1 deletions
diff --git a/Library/Homebrew/rubocops/formula_desc_cop.rb b/Library/Homebrew/rubocops/formula_desc_cop.rb index 2b613c9b4..2ef60303d 100644 --- a/Library/Homebrew/rubocops/formula_desc_cop.rb +++ b/Library/Homebrew/rubocops/formula_desc_cop.rb @@ -18,8 +18,14 @@ module RuboCop return end - # Check if a formula's desc is too long + # Check the formula's desc length. Should be >0 and <80 characters. desc = parameters(desc_call).first + pure_desc_length = string_content(desc).length + if pure_desc_length.zero? + problem "The desc (description) should not be an empty string." + return + end + desc_length = "#{@formula_name}: #{string_content(desc)}".length max_desc_length = 80 return if desc_length <= max_desc_length diff --git a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb index ac8893e18..4816c3b26 100644 --- a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb @@ -27,6 +27,27 @@ describe RuboCop::Cop::FormulaAuditStrict::DescLength do end end + it "reports an offense when desc is an empty string" do + source = <<-EOS.undent + class Foo < Formula + url 'http://example.com/foo-1.0.tgz' + desc '' + end + EOS + + msg = "The desc (description) should not be an empty string." + expected_offenses = [{ message: msg, + severity: :convention, + line: 3, + column: 2, + source: source }] + + inspect_source(source, "/homebrew-core/Formula/foo.rb") + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) + end + end + it "When desc is too long" do source = <<-EOS.undent class Foo < Formula |
