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

Match the "formula name in description" on word boundaries #2687

Merged
merged 1 commit into from May 29, 2017

Conversation

issyl0
Copy link
Member

@issyl0 issyl0 commented May 27, 2017

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew tests with your changes locally?

  • 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.

@issyl0 issyl0 force-pushed the fix_formula_description_regex branch from 224c66e to 93ecaae Compare May 27, 2017 23:02
@GauthamGoli
Copy link
Contributor

Thanks @issyl0 for finding this bug and the PR!

@@ -40,7 +40,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body)
end

# 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, /^\b#{@formula_name}\b/i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can drop the first \b; ^ already ensures it’s the first word.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I've amended my commit.

- 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.
@issyl0 issyl0 force-pushed the fix_formula_description_regex branch from 93ecaae to 279a4df Compare May 28, 2017 23:27
@MikeMcQuaid MikeMcQuaid merged commit da39db0 into Homebrew:master May 29, 2017
@MikeMcQuaid
Copy link
Member

Thanks for your first contribution to Homebrew, @issyl0! Without people like you submitting PRs we couldn't run this project. You rock!

@issyl0 issyl0 deleted the fix_formula_description_regex branch May 29, 2017 11:37
@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants