rubocops/move_to_extend_os: audit OS checks in extend/os#21698
Merged
MikeMcQuaid merged 1 commit intomainfrom Mar 9, 2026
Merged
rubocops/move_to_extend_os: audit OS checks in extend/os#21698MikeMcQuaid merged 1 commit intomainfrom
extend/os#21698MikeMcQuaid merged 1 commit intomainfrom
Conversation
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)
Contributor
There was a problem hiding this comment.
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/MoveToExtendOSto emit targeted offenses forOS.mac?/OS.linux?calls insideextend/os/macandextend/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.
MikeMcQuaid
approved these changes
Mar 9, 2026
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.
brew lgtm(style, typechecking and tests) with your changes locally?Test cases were AI-generated and manually verified.
Extend the
Homebrew/MoveToExtendOScop to identify incorrect or redundantOS.mac?andOS.linux?checks inextend/os/{mac,linux}.Originally proposed in #20738 (comment).