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

on_macos/on_linux block: improve rubocop message #9486

Merged

Conversation

SeekingMeaning
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 style with your changes locally?
  • Have you successfully run brew tests with your changes locally?
  • Have you successfully run brew man locally and committed any changes?

Related: #9470 (comment)

Changes:

  • Include the name and line number of the method that isn't allowed
  • Print the list of all allowed methods

Before:

% brew style util-linux
Library/Taps/homebrew/homebrew-core/Formula/util-linux.rb:19:3: C: on_macos can only include depends_on, patch and resource nodes.
  on_macos do ...
  ^^^^^^^^^^^

After:

% brew style util-linux
Library/Taps/homebrew/homebrew-core/Formula/util-linux.rb:20:5: C: on_macos cannot include keg_only.
Only these are allowed: depends_on, patch, resource, deprecate!, disable!
    keg_only "macOS provides the uuid.h header"
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@BrewTestBot
Copy link
Member

Review period will end on 2020-12-10 at 17:05:22 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Dec 9, 2020
@SeekingMeaning
Copy link
Contributor Author

SeekingMeaning commented Dec 10, 2020

components_order_spec expects the old message, and updating it to check for multiline messages was harder than I thought as the parser doesn't seem to support multiline messages

Here are the tests in question: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/test/rubocops/components_order_spec.rb#L388-L412

^^^^^^^^^^^ `on_macos` can only include `depends_on`, `patch` and `resource` nodes.

Our best available options, I think:

  1. Shorten the message to only this:
`on_macos` cannot include `keg_only`.
  1. Or shorten the message to only this:
`on_macos` can only include `depends_on`, `patch`, `resource`, `deprecate!`, `disable!`
  1. Or put the entire message on one line:
`on_macos` cannot include `keg_only`. Only these are allowed: `depends_on`, `patch`, `resource`, `deprecate!`, `disable!`

@reitermarkus
Copy link
Member

I found you can abbreviate the message with [...], but it still cannot be multiline because the span will not match on the second line.

@reitermarkus
Copy link
Member

Another bug I found: If the block only contains one node which isn't allowed, it will not catch it since I guess the whole cop only applies if there are multiple components in the block.

@reitermarkus
Copy link
Member

I'm not quite sure why this is even part of ComponentsOrder and not a separate cop.

@SeekingMeaning
Copy link
Contributor Author

Another bug I found: If the block only contains one node which isn't allowed, it will not catch it since I guess the whole cop only applies if there are multiple components in the block.

#9470 fixes this

@BrewTestBot
Copy link
Member

Review period ended.

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Dec 10, 2020
Co-authored-by: Markus Reiter <me@reitermark.us>
@SeekingMeaning SeekingMeaning merged commit 06c60b9 into Homebrew:master Dec 10, 2020
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Jan 10, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Jan 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants