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

audit: Port audit_conflicts method to rubocop and add tests #2843

Merged
merged 1 commit into from Jul 8, 2017

Conversation

Projects
None yet
3 participants
@GauthamGoli
Copy link
Member

GauthamGoli commented Jun 30, 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?

#569
This PR partially ports audit_conflicts method to a custom cop. Remaining code in audit_conflicts uses Homebrew internals methods and I could not figure out their exact functionality to port them. Please let me know if this approach is not good.

@GauthamGoli GauthamGoli force-pushed the GauthamGoli:audit_conflicts_rubocop branch from f0f645d to 4f30de4 Jun 30, 2017

@MikeMcQuaid
Copy link
Member

MikeMcQuaid left a comment

Two tiny nits but otherwise looking good 👍

# This cop audits versioned Formulae for `conflicts_with`
class Conflicts < FormulaCop
MSG = <<-EOS.undent
Versioned formulae should not use `conflicts_with`.

This comment has been minimized.

@MikeMcQuaid

MikeMcQuaid Jun 30, 2017

Member

Only indent by two characters here.


def audit_formula(_node, _class_node, _parent_class_node, body)
return unless versioned_formula?
whitelist = %w[node@ bash-completion@].freeze

This comment has been minimized.

@MikeMcQuaid

MikeMcQuaid Jun 30, 2017

Member

Let's make this a constant earlier in the class and have one formula per line so they stand out a bit more

@GauthamGoli GauthamGoli force-pushed the GauthamGoli:audit_conflicts_rubocop branch 2 times, most recently from 8a9f570 to 0db695e Jun 30, 2017

EOS

WHITELIST = %w[node@
bash-completion@].freeze

This comment has been minimized.

@MikeMcQuaid

MikeMcQuaid Jul 7, 2017

Member

Let's go for:

WHITELIST = %w[
   node@
   bash-completion@
].freeze

This comment has been minimized.

@MikeMcQuaid

MikeMcQuaid Jul 7, 2017

Member

that will reduce the diff on future additions here.

This comment has been minimized.

@GauthamGoli

GauthamGoli Jul 7, 2017

Member

Waoh. Never thought of that!

@GauthamGoli

This comment has been minimized.

Copy link
Member

GauthamGoli commented Jul 7, 2017

@MikeMcQuaid I'm moving the two private methods defined in conflicts_cop.rb to formula_cop.rb as they can be reused in other cops. ( options_cop.rb)

@GauthamGoli GauthamGoli force-pushed the GauthamGoli:audit_conflicts_rubocop branch from 0db695e to 4ed34f9 Jul 7, 2017

@JCount

JCount approved these changes Jul 7, 2017

Copy link
Contributor

JCount left a comment

Looks good to me. 👍

@MikeMcQuaid MikeMcQuaid merged commit f1fa475 into Homebrew:master Jul 8, 2017

3 checks passed

codecov/patch 100% of diff hit (target 65.61%)
Details
codecov/project 65.65% (+0.04%) compared to 0740855
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

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