diff --git a/Library/Homebrew/rubocops/shared/desc_helper.rb b/Library/Homebrew/rubocops/shared/desc_helper.rb index 8e43f1f39f..22113414dc 100644 --- a/Library/Homebrew/rubocops/shared/desc_helper.rb +++ b/Library/Homebrew/rubocops/shared/desc_helper.rb @@ -49,10 +49,8 @@ module RuboCop problem "Description should use \"#{c}ommand-line\" instead of \"#{match}\"." end - # Check if the desc starts with "A" or "An". - if match = regex_match_group(desc, /^(an?)(?=\s)/i) - problem "Description shouldn't start with an indefinite article, i.e. \"#{match}\"." - end + # Check if the desc starts with an article. + problem "Description shouldn't start with an article." if regex_match_group(desc, /^(the|an?)(?=\s)/i) # Check if invalid lowercase words are at the start of a desc. if !VALID_LOWERCASE_WORDS.include?(string_content(desc).split.first) && @@ -91,7 +89,7 @@ module RuboCop correction.gsub!(/^\s+/, "") correction.gsub!(/\s+$/, "") - correction.sub!(/^an?\s+/i, "") + correction.sub!(/^(the|an?)\s+/i, "") first_word = correction.split.first unless VALID_LOWERCASE_WORDS.include?(first_word) diff --git a/Library/Homebrew/test/rubocops/cask/desc_spec.rb b/Library/Homebrew/test/rubocops/cask/desc_spec.rb index f27722b459..d76d37b6c7 100644 --- a/Library/Homebrew/test/rubocops/cask/desc_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/desc_spec.rb @@ -6,7 +6,7 @@ require "test/rubocops/cask/shared_examples/cask_cop" describe RuboCop::Cop::Cask::Desc do subject(:cop) { described_class.new } - it "does not start with an indefinite article" do + it "does not start with an article" do expect_no_offenses <<~RUBY cask "foo" do desc "Bar program" @@ -16,7 +16,14 @@ describe RuboCop::Cop::Cask::Desc do expect_offense <<~RUBY, "/homebrew-cask/Casks/foo.rb" cask 'foo' do desc 'A bar program' - ^ Description shouldn\'t start with an indefinite article, i.e. \"A\". + ^ Description shouldn\'t start with an article. + end + RUBY + + expect_offense <<~RUBY, "/homebrew-cask/Casks/foo.rb" + cask 'foo' do + desc 'The bar program' + ^^^ Description shouldn\'t start with an article. end RUBY diff --git a/Library/Homebrew/test/rubocops/formula_desc_spec.rb b/Library/Homebrew/test/rubocops/formula_desc_spec.rb index e3bd25f62a..5d85184ef3 100644 --- a/Library/Homebrew/test/rubocops/formula_desc_spec.rb +++ b/Library/Homebrew/test/rubocops/formula_desc_spec.rb @@ -84,7 +84,15 @@ describe RuboCop::Cop::FormulaAudit::Desc do class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' desc 'An aardvark' - ^^ Description shouldn\'t start with an indefinite article, i.e. \"An\". + ^^ Description shouldn\'t start with an article. + end + RUBY + + expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") + class Foo < Formula + url 'https://brew.sh/foo-1.0.tgz' + desc 'The aardvark' + ^^^ Description shouldn\'t start with an article. end RUBY end