Skip to content

Fix/cask on system conditionals infinite loop#21733

Merged
MikeMcQuaid merged 2 commits intoHomebrew:mainfrom
hyuraku:fix/cask-on-system-conditionals-infinite-loop
Mar 14, 2026
Merged

Fix/cask on system conditionals infinite loop#21733
MikeMcQuaid merged 2 commits intoHomebrew:mainfrom
hyuraku:fix/cask-on-system-conditionals-infinite-loop

Conversation

@hyuraku
Copy link
Contributor

@hyuraku hyuraku commented Mar 14, 2026

  • 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 lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

Fix infinite autocorrect loop in Cask::OnSystemConditionals cop.

audit_macos_version_conditionals was called without allowed_blocks, so when audit_on_system_blocks corrected on_monterey doif MacOS.version == :monterey inside flight stanzas (postflight, etc.), the next pass would reverse it back to on_monterey do, causing an infinite loop.

The fix passes allowed_blocks: FLIGHT_STANZA_NAMES to audit_macos_version_conditionals, matching the existing pattern used by audit_arch_conditionals.

Also removes the loop: false workarounds and stale FIXME comments from tests.

Fixes the 3 FIXME comments in on_system_conditionals_spec.rb.

Copilot AI review requested due to automatic review settings March 14, 2026 09:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an infinite autocorrect loop in the RuboCop::Cop::Cask::OnSystemConditionals cop when handling macOS version conditionals inside flight stanzas, and updates the spec to assert stable autocorrection without workarounds.

Changes:

  • Passes allowed_blocks: FLIGHT_STANZA_NAMES to audit_macos_version_conditionals to prevent conflicting corrections within flight stanzas.
  • Removes loop: false and associated FIXME comments from the cop’s spec now that autocorrection converges.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Library/Homebrew/rubocops/cask/on_system_conditionals.rb Ensures macOS version conditional auditing respects flight-stanza exclusions to avoid flip-flop autocorrections.
Library/Homebrew/test/rubocops/cask/on_system_conditionals_spec.rb Cleans up specs by removing infinite-loop workarounds and confirming stable corrections.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks again @hyuraku!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Mar 14, 2026
Merged via the queue into Homebrew:main with commit b079460 Mar 14, 2026
39 of 40 checks passed
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