Skip to content

rubocops/move_to_extend_os: audit OS checks in extend/os#21698

Merged
MikeMcQuaid merged 1 commit intomainfrom
audit-os-checks-in-extend-os
Mar 9, 2026
Merged

rubocops/move_to_extend_os: audit OS checks in extend/os#21698
MikeMcQuaid merged 1 commit intomainfrom
audit-os-checks-in-extend-os

Conversation

@ZhongRuoyu
Copy link
Member

  • 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.

Test cases were AI-generated and manually verified.


Extend the Homebrew/MoveToExtendOS cop to identify incorrect or redundant OS.mac? and OS.linux? checks in extend/os/{mac,linux}.

Originally proposed in #20738 (comment).

Extend the `Homebrew/MoveToExtendOS` cop to identify incorrect or
redundant `OS.mac?` and `OS.linux?` checks in `extend/os/{mac,linux}`.

Originally proposed in [1].

[1]: #20738 (comment)
Copilot AI review requested due to automatic review settings March 9, 2026 10:28
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

Extends the existing Homebrew/MoveToExtendOS RuboCop cop so it can also audit extend/os/mac and extend/os/linux for incorrect/redundant OS.mac?/OS.linux? checks, aligning with Homebrew’s OS-specific extension layout under extend/os.

Changes:

  • Update Homebrew/MoveToExtendOS to emit targeted offenses for OS.mac?/OS.linux? calls inside extend/os/mac and extend/os/linux.
  • Adjust RuboCop configuration so the cop runs on extend/** (while still excluding tests/requirements).
  • Add RSpec coverage and update the Sorbet RBI for the new node matchers.

Reviewed changes

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

File Description
Library/Homebrew/rubocops/move_to_extend_os.rb Implements path-aware offenses for extend/os/mac and extend/os/linux, while preserving the existing “move to extend/os” behavior elsewhere.
Library/Homebrew/.rubocop.yml Enables the cop for extend/** by removing extend from the exclusion glob.
Library/Homebrew/test/rubocops/move_to_extend_os_spec.rb Adds tests verifying offenses are raised for redundant/incorrect OS checks under extend/os/mac and extend/os/linux.
Library/Homebrew/sorbet/rbi/dsl/rubo_cop/cop/homebrew/move_to_extend_os.rbi Updates the RBI to reflect the new os_mac? / os_linux? node matcher methods.
Files not reviewed (1)
  • Library/Homebrew/sorbet/rbi/dsl/rubo_cop/cop/homebrew/move_to_extend_os.rbi: Language not supported

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

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.

Good catch, thanks!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 0160cd1 Mar 9, 2026
42 checks passed
@MikeMcQuaid MikeMcQuaid deleted the audit-os-checks-in-extend-os branch March 9, 2026 14:58
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