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

style: disable NewFormulaAudit cops' execution by default unless specified #2906

Merged
merged 2 commits into from
Jul 21, 2017

Conversation

GauthamGoli
Copy link
Contributor

  • 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 NewFormulaAudit cop got enabled for all Formulae because I forgot to disable it for brew style ( I disabled for brew audit ) in #2905, This PR fixes that mistake.

@@ -28,7 +28,7 @@ FormulaAuditStrict/Options:
Enabled: true

NewFormulaAudit/Options:
Enabled: false
Enabled: true
Copy link
Member

Choose a reason for hiding this comment

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

This still won't quite work because it'll show up in files when using e.g. rubocop in my editor. Need some way to have it be disabled by default and enabled only when requested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems tricky to achieve. But I'll try to think of someway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MikeMcQuaid One way that works involves some redundant configuration. (Redundant because we are doing similar thing in brew style , but it has to be redundant because brew and rubocop run in different processes and aren't as such coupled and editor integration is independent of brew)

In sublime, we can add args line in Sublime Linter User Settings (found in Menu->Preferences->Package Settings->SublimeLinter->Settings - User) so final rubocop section should look like below

"rubocop": {
       "@disable": false,
       "args": ["--except", "FormulaAuditStrict, NewFormulaAudit"],
       "excludes": []
}

If we are planning to go by this method, It would be better to update our docs to have a section on editor integration.

Copy link
Member

Choose a reason for hiding this comment

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

@GauthamGoli I think we need to have something that involves zero configuration. Is there any way to have a cop that's only run when specified on the command-line? There may be some hack using a global ARGV check or similar in the cop itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes
Example: #569 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

@GauthamGoli Worst case we can run the new formulae cops in a separate rubocop invocation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The editor plugin finds .rubocop.yml file at HOMEBREW_LIBRARY and uses it to highlight violations.
So, in HOMEBREW_LIBRARY/.rubocop.yml ,FormulaAuditStrict and NewFormulaAudit departments can be disabled. This configuration can be inherited and overriden in another configuration file with the former departments(or specific cops) enabled, which will now be used in style.rb to handle brew audit and brew style commands.

This also achieves the zero configuration goal for end user/developer. I can push it here if you want to see this approach.

Copy link
Member

Choose a reason for hiding this comment

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

I think FormulaAuditStrict are fine to leave enabled by default and we just have a separate configuration file for NewFormulaAudit. That could be useful for enforcing things like e.g. 80 character wrapping, too.

@GauthamGoli
Copy link
Contributor Author

@MikeMcQuaid
If the developer/contributor does not want some cops to get executed in editor, then they can disable them either in the editor config or HOMEBREW_LIBRARY/.rubocops.yml

@MikeMcQuaid
Copy link
Member

Yeah. This line needs to be included because this department has been disabled in .rubocop.yml. But below this we can disable cops in that namespace.

I think it's worth just enabling/disabling cops based on their namespace rather than enabling each one individually. What do you think?

@GauthamGoli
Copy link
Contributor Author

Yeah, agree.

@GauthamGoli GauthamGoli force-pushed the new_formula_rubocop_fix branch from 8640da8 to 086e540 Compare July 18, 2017 14:53
@JCount
Copy link
Contributor

JCount commented Jul 20, 2017

This seems to be a be in general a good approach. We just need to make certain that this won't accidentally trigger unwanted strict/new formula, audits/style checks on the homebrew/core's CI/test-bot when this eventually gets merged.

To that end, cc @ilovezfs

@MikeMcQuaid
Copy link
Member

This seems to be a be in general a good approach. We just need to make certain that this won't accidentally trigger unwanted strict/new formula, audits/style checks on the homebrew/core's CI/test-bot when this eventually gets merged.

Tried that and it's looking 👍 so 🚢!

@MikeMcQuaid MikeMcQuaid merged commit 9747bc3 into Homebrew:master Jul 21, 2017
@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.

3 participants