Match the "formula name in description" on word boundaries
- The regexp for the "check if formula name is used in formula's description" cop matches every instance of the formula name if it exists, whether it's in a word or not. - For example, the formula `mon` has the description "Monitor hosts/services/whatever and alert about problems". This makes `brew audit --strict` complain because it matches "Monitor", which isn't the formula name! The formula `pass` has the description "Password manager". Again, the strict audit matches "Password", which isn't an issue. - Instead, this change matches on a word boundary, so it will match `mon:`, or `mon `, but not "Monitor", or, for example, "harmony". - I've changed the tests to account for this change.
This commit is contained in:
parent
fb33acbbe4
commit
279a4df6c3
@ -40,7 +40,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Check if formula's name is used in formula's desc
|
# Check if formula's name is used in formula's desc
|
||||||
problem "Description shouldn't include the formula name" if regex_match_group(desc, /^#{@formula_name}/i)
|
problem "Description shouldn't include the formula name" if regex_match_group(desc, /^#{@formula_name}\b/i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -120,7 +120,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do
|
|||||||
source = <<-EOS.undent
|
source = <<-EOS.undent
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url 'http://example.com/foo-1.0.tgz'
|
url 'http://example.com/foo-1.0.tgz'
|
||||||
desc 'Foo'
|
desc 'Foo: foobar'
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user