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

rubocop: Some more config cleanup #14709

Merged
merged 2 commits into from
Feb 20, 2023
Merged

Conversation

issyl0
Copy link
Member

@issyl0 issyl0 commented Feb 19, 2023

  • 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 style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

  • Found on my travels through Remove usage of Exclude with rubocop #14685.
  • Clean up non-existent files/dirs from excludes.
  • Naming/PredicateName allows is_a? by default.
  • The test dir is a default exclude for Style/Documentation.

@BrewTestBot
Copy link
Member

Review period will end on 2023-02-21 at 00:00:00 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Feb 19, 2023
@issyl0
Copy link
Member Author

issyl0 commented Feb 19, 2023

🤔 Why are things in test/**/* failing Style/Documentation on CI? Locally the cop shows no offenses.

@Bo98
Copy link
Member

Bo98 commented Feb 19, 2023

🤔 Why are things in test/**/* failing Style/Documentation on CI? Locally the cop shows no offenses.

I think the PWD where you run brew style can affect its output sometimes. (It obviously shouldn't but I have seen it happen nevertheless.)

@MikeMcQuaid MikeMcQuaid added the critical Critical change which should be shipped as soon as possible. label Feb 20, 2023
@MikeMcQuaid
Copy link
Member

Thanks again @issyl0!

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Feb 20, 2023
@BrewTestBot
Copy link
Member

Review period skipped due to critical label.

@dduugg
Copy link
Member

dduugg commented Feb 20, 2023

🤔 Why are things in test/**/* failing Style/Documentation on CI? Locally the cop shows no offenses.

I think the PWD where you run brew style can affect its output sometimes. (It obviously shouldn't but I have seen it happen nevertheless.)

Specifically, I think this has to do with whether rubocop is invoked with config https://github.com/Homebrew/brew/blob/master/Library/.rubocop.yml
or
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/.rubocop.yml

I'm looking into consolidating them into a single file.

@MikeMcQuaid
Copy link
Member

Specifically, I think this has to do with whether rubocop is invoked with config https://github.com/Homebrew/brew/blob/master/Library/.rubocop.yml or https://github.com/Homebrew/brew/blob/master/Library/Homebrew/.rubocop.yml

I'm looking into consolidating them into a single file.

We have separate rules for things in Library/Taps and for the Homebrew/brew codebase. As you’ve probably seen in other issues: specifying paths in .rubocop.yml doesn’t seem to be terribly reliable here so we rely on separate configurations. The style varies a fair bit between the two, deliberately, as Library/Taps are formula/cask DSL(s) and Homebrew/brew is a fairly standard Ruby project.

@dduugg
Copy link
Member

dduugg commented Feb 20, 2023

Specifically, I think this has to do with whether rubocop is invoked with config https://github.com/Homebrew/brew/blob/master/Library/.rubocop.yml or https://github.com/Homebrew/brew/blob/master/Library/Homebrew/.rubocop.yml
I'm looking into consolidating them into a single file.

We have separate rules for things in Library/Taps and for the Homebrew/brew codebase. As you’ve probably seen in other issues: specifying paths in .rubocop.yml doesn’t seem to be terribly reliable here so we rely on separate configurations. The style varies a fair bit between the two, deliberately, as Library/Taps are formula/cask DSL(s) and Homebrew/brew is a fairly standard Ruby project.

This is useful context. It's been confusing triggering failures in other repos when making updates to the rubocop config here. Another approach could be to have a centralized, versioned rubocop repo, and each brew repo can independently use that config and a dedicated github action to run rubocop (and this repo could still enable the add'l config options that are currently in a separate file). (It looks like Shopify takes this approach: https://rubygems.org/gems/rubocop-shopify )

@issyl0
Copy link
Member Author

issyl0 commented Feb 20, 2023

@dduugg Yeah, GitHub has the "separate repo, versioned gem" approach too - github/rubocop-github - it's a common pattern. Might be worth an issue to track this separately as a future enhancement us?

@issyl0
Copy link
Member Author

issyl0 commented Feb 20, 2023

I'm going to undo the Style/Documentation test/** exclude removal since it's not working. No amount of massaging

inherit_mode:
  merge:
  - Exclude

works when RuboCop is run from the specific path. 🤔

@MikeMcQuaid
Copy link
Member

It's been confusing triggering failures in other repos when making updates to the rubocop config here.

I think given that we don't "use RuboCop" as much as we "use brew style that happens to use RubocCop (and shellcheck): it makes more sense for this to live here.

I appreciate that it's a little confusing to have to change other repos to have CI pass here but I think it's better for us to have this a big more centralised and blocking.

@MikeMcQuaid
Copy link
Member

I'm going to undo the Style/Documentation test/** exclude removal since it's not working.

@issyl0 IMO we should just remove it as a requirement and instead flip it to only be required on specific classes that are part of our public API.

@issyl0
Copy link
Member Author

issyl0 commented Feb 20, 2023

@issyl0 IMO we should just remove it as a requirement and instead flip it to only be required on specific classes that are part of our public API.

@MikeMcQuaid Yeah, will do this soon with the metrics stuff too.

@MikeMcQuaid MikeMcQuaid merged commit 4eaaa86 into Homebrew:master Feb 20, 2023
@issyl0 issyl0 deleted the rubocop-tidying branch February 20, 2023 22:10
issyl0 added a commit to issyl0/brew that referenced this pull request Feb 26, 2023
- Suggested in Homebrew#14709 (comment).
- Found the public API paths with `git grep -l "@api public"`.
issyl0 added a commit to issyl0/brew that referenced this pull request Feb 28, 2023
- Suggested in Homebrew#14709 (comment).
- Found the public API paths with `git grep -l "@api public"`.
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants