Skip to content

rubocops/cask: add cops for all conditional stanzas - #23554

Merged
MikeMcQuaid merged 4 commits into
Homebrew:mainfrom
AlternateRT:improve-conditional-stanzas-cops
Aug 18, 2026
Merged

rubocops/cask: add cops for all conditional stanzas#23554
MikeMcQuaid merged 4 commits into
Homebrew:mainfrom
AlternateRT:improve-conditional-stanzas-cops

Conversation

@AlternateRT

@AlternateRT AlternateRT commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

The changes here introduces two new cops for conditional stanzas:

  1. The first cop, Cask/EmptyConditionalArgument, replaces Cask/EmptyArchArgument so that it can also autocorrect empty strings in on_arch_conditional, os, and on_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

  2. The second cop, Cask/ConditionalArgumentsOrder (similar to Cask/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 (for arch/on_arch_conditional), and macOS before Linux (for os/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.

@krehel

krehel commented Aug 17, 2026

Copy link
Copy Markdown
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
AlternateRT force-pushed the improve-conditional-stanzas-cops branch from a6670b5 to 20863ae Compare August 17, 2026 21:05

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks again @AlternateRT!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Aug 18, 2026
Merged via the queue into Homebrew:main with commit 5d2d611 Aug 18, 2026
45 checks passed
@AlternateRT
AlternateRT deleted the improve-conditional-stanzas-cops branch August 18, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants