-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Unify (mostly) Homebrew code style #7867
Conversation
CC @vitorgalvao as your feedback heavily influenced the approach here and I want you to be OK with this before it ships. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think I understand this much better now.
Here's my summary:
brew style
: usesHomebrew/.rubocop.yml
as its config file- Inheritance:
Homebrew/.rubocop.yml
-->.rubocop_rspec.yml
-->.rubocop.yml
- Inheritance:
brew style <formula/tap>
: uses.rubocop.yml
as its config file.brew cask style
: uses.rubocop_cask.yml
as its config file- Inheritance:
.rubocop_cask.yml
-->Homebrew/.rubocop.yml
-->.rubocop_rspec.yml
-->.rubocop.yml
- Inheritance:
What's still unclear to me:
If I understand correctly, rubocop
looks for a .rubcop.yml
file. For formulae, this file is Library/.rubocop.yml
. For files in the Library/Homebrew
directory, this is Library/Homebrew/.rubocop.yml
.
What I don't understand is how casks use Library/.rubocop_cask.yml
(aside from when they're checked using brew cask style
. The way I understand it, running rubocop
on a cask will still use Library/.rubocop.yml
as its config file. Doesn't this mean that any additional/overridden cops in Library/.rubocop_cask.yml
won't be applied?
Additional questions:
- Why does
.rubocop_cask.yml
inherit fromHomebrew/.rubocop.yml
when.rubocop.yml
doesn't? I would think it would inherit directly from.rubocop.yml
and make cask-only changes - Is
.rubocop_rspec.yml
only used when inherited fromHomebrew/.rubocop.yml?
If so, should it be moved to theHomebrew
directory?
@@ -11,11 +11,11 @@ | |||
quit: 'my.fancy.package.app', | |||
login_item: 'Fancy', | |||
delete: [ | |||
"#{TEST_TMPDIR}/absolute_path", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m fine either way with the indentation, but if we’re making it a fixed number of spaces instead of visual, shouldn’t we also change the first line?
To explain what I mean, on this file we have:
quit: 'my.fancy.package.app',
login_item: 'Fancy',
delete: [
But given the indentation change, don’t you think it should now be:
quit: 'my.fancy.package.app',
login_item: 'Fancy',
delete: [
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But given the indentation change, don’t you think it should now be:
I'm fine with that, it just won't be autocorrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick check, and it seems sub(/:\s+/, ': ')
should be enough to fix these in one swoop. I can do that (and do audit
and style
checks) after this is live.
Ideally we’ll get rid of that check (it should be an
Thank you! But as I mentioned, I agree that the project consistency is more important than my usage. If I could convince you of the advantages of bot single and double quotes—and thus make it the default for everyone—so much the better. But failing that, I’ll get used to only having double quotes. In no way do I want my preference to mean more maintenance work, especially because I’m not the one doing the cop maintenance! |
Yes. This is why we exclude Casks from those things that are overridden. This is another reason why it would have been nicer to have them be unified.
It's still used for some taps and by |
Don't worry, it's not meaningful extra work to leave the quoting as-is. |
Thanks for answering all my questions, @MikeMcQuaid! I definitely have a better sense of how this works and why you made the changes you did. |
Is Steps to reproduce:
|
Is that before this PR, with this PR or both? |
Only with this PR |
Thanks @Rylan12. I dug into this further and the styles that contradict (formulae) and therefore require exclusion are going to be impossible to enforce on casks. You cannot exclude something from a RuboCop rule in one place and then de-exclude it elsewhere, this is just a limitation with RuboCop. The resulting options are:
|
Whichever enforces and is able to autocorrect the most cases. |
@vitorgalvao et. al: this has been updated to have a (more) consistent style between Homebrew/brew, casks and formulae. The fixtures are the best place to look here to see the cask style. Once we're 👍 on this approach: I'll mass update homebrew-core and homebrew-cask and push directly to them (without PRs). |
Ah, this would explain why I just got several screens worth of updated casks when I ran |
I don't understand the question, sorry.
Yes, feel free. |
sorry about being unclear here. those 6 casks now contain
thanks, will do |
Make the Homebrew/cask and Homebrew/homebrew-core style more closely match the rest of Homebrew.
To accomplish this:
brew cask style
to ensure we don't break style there when making changes or upgrading RuboCop in Homebrew/brew..rubocop_shared.yml
brew cask style --fix
.@Homebrew/cask once I have 👍 from at least one of you'll I'll fix the current style violations in Homebrew/cask (almost 100%
brew cask style --fix
).brew style
with your changes locally?brew tests
with your changes locally?