Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formula_desc_cop: allow formula name in desc #2838

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Library/Homebrew/rubocops/formula_desc_cop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
problem "Description should start with a capital letter"
end

# Check if formula's name is used in formula's desc
return unless regex_match_group(desc, /(^|[^a-z])#{@formula_name}([^a-z]|$)/i)
problem "Description shouldn't include the formula name"
# Check if formula's desc starts with formula's name
return unless regex_match_group(desc, /^#{@formula_name} /i)
problem "Description shouldn't start with the formula name"
end

private
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ class Foo < Formula
source = <<-EOS.undent
class Foo < Formula
url 'http://example.com/foo-1.0.tgz'
desc 'Foo: foobar'
desc 'Foo is a foobar'
end
EOS

expected_offenses = [{ message: "Description shouldn't include the formula name",
expected_offenses = [{ message: "Description shouldn't start with the formula name",
severity: :convention,
line: 3,
column: 8,
Expand Down