rubocops/cask: add cops for all conditional stanzas - #23554
Merged
MikeMcQuaid merged 4 commits intoAug 18, 2026
Conversation
9 tasks
Member
|
Thanks for this. I also had an iteration of this in progress to be refined when I discovered the same thing regarding empty Linux keys being allowed, so glad to see someone else also saw this problem. |
`Cask/EmptyArchArgument` only autocorrected empty `arch` strings; this reworks it into `Cask/EmptyConditionalArgument` so that it can also autocorrect empty `on_arch_conditional`, `os`, and `on_system_conditional` strings
Only remove a line where an `on_<system>_conditional` stanza is being used if it is for a variable; uses inside other conditional stanzas should only result in that key being removed
Adds a new `Cask/ConditionalArgumentsOrder` cop to check that the order of all conditional stanzas is consistent with the order employed by the `on_<system>` blocks: ARM before Intel for `arch`/`on_arch_conditional`, and macOS before Linux for `os`/`on_system_conditional`
AlternateRT
force-pushed
the
improve-conditional-stanzas-cops
branch
from
August 17, 2026 21:05
a6670b5 to
20863ae
Compare
MikeMcQuaid
approved these changes
Aug 18, 2026
MikeMcQuaid
left a comment
Member
There was a problem hiding this comment.
Thanks again @AlternateRT!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?The changes here introduces two new cops for conditional stanzas:
The first cop,
Cask/EmptyConditionalArgument, replacesCask/EmptyArchArgumentso that it can also autocorrect empty strings inon_arch_conditional,os, andon_system_conditional.Two casks need to be aligned first to comply with this PR - db-browser-for-sql*@nightly: remove empty linux key聽homebrew-cask#281566
The second cop,
Cask/ConditionalArgumentsOrder(similar toCask/Sha256ArchOrder), checks that the order of the keys is always consistent.With it, they should follow the same order as
on_<system>blocks: ARM before Intel (forarch/on_arch_conditional), and macOS before Linux (foros/on_system_conditional) - all existing casks are already ordering them this way, so this ensures that it is enforced for any future cask as well.