Merge pull request #8757 from reitermarkus/desc-the
Check for descriptions starting with “the”.
This commit is contained in:
commit
f6cd7b72f4
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user