Enable strict typing in Library/Homebrew/rubocops/#21540
Merged
Conversation
fd290ef to
f8c0811
Compare
MikeMcQuaid
approved these changes
Mar 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR moves the Library/Homebrew/rubocops/ code toward Sorbet # typed: strict, primarily by tightening type signatures, introducing T.let/casts where needed, and adjusting AST-argument access patterns to satisfy stricter nilability rules.
Changes:
- Switch multiple RuboCop cop/helper files to
# typed: strictand add/update Sorbetsigs. - Replace a number of
.first/.lastargument accesses with.fetch(...)and add casts to satisfy strict typing. - Update/extend RBI/type definitions used by the RuboCop cask AST layer.
Reviewed changes
Copilot reviewed 26 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/sorbet/rbi/upstream.rbi | Updates temporary upstream RBI overrides (Integer <=> signature) and removes the prior IO patch. |
| Library/Homebrew/rubocops/version.rb | Uses fetch(0) for strict argument typing. |
| Library/Homebrew/rubocops/uses_from_macos.rb | Refactors first-argument handling for strict typing. |
| Library/Homebrew/rubocops/urls.rb | Uses fetch for strict argument typing in URL-related checks. |
| Library/Homebrew/rubocops/shared/url_helper.rb | Moves helper to typed: strict, adds sigs, adds casts/fetches. |
| Library/Homebrew/rubocops/shared/on_system_conditionals_helper.rb | Adjusts offensive node handling for strict typing. |
| Library/Homebrew/rubocops/shared/helper_functions.rb | Converts to typed: strict, adds many sigs, changes some return/collection behavior. |
| Library/Homebrew/rubocops/resource_requires_dependencies.rb | Adjusts offensive node handling for strict typing. |
| Library/Homebrew/rubocops/presence.rb | Converts to typed: strict and adds sigs for helper methods. |
| Library/Homebrew/rubocops/patches.rb | Uses fetch(0) for strict argument typing in patch URL extraction. |
| Library/Homebrew/rubocops/options.rb | Uses fetch(0) for strict argument typing. |
| Library/Homebrew/rubocops/livecheck.rb | Adds nil-guards and replaces .first with .fetch in some paths. |
| Library/Homebrew/rubocops/lines.rb | Broad set of strict-typing tweaks (fetches/casts/offensive node usage). |
| Library/Homebrew/rubocops/keg_only.rb | Converts to typed: strict and tightens nil handling for string indexing. |
| Library/Homebrew/rubocops/homepage.rb | Uses fetch(0) for strict argument typing. |
| Library/Homebrew/rubocops/extend/formula_cop.rb | Tightens audit_urls block typing and argument fetching/casting. |
| Library/Homebrew/rubocops/deprecate_disable.rb | Adjusts offensive node usage for strict typing. |
| Library/Homebrew/rubocops/dependency_order.rb | Converts to typed: strict, adds sigs, minor logic/style adjustments. |
| Library/Homebrew/rubocops/conflicts.rb | Tightens hash-node extraction and string indexing for strict typing. |
| Library/Homebrew/rubocops/components_order.rb | Adds initialize ivar declarations and more sigs/fetches. |
| Library/Homebrew/rubocops/cask/url.rb | Adjusts audit_url invocation to use the local stanza_node. |
| Library/Homebrew/rubocops/cask/stanza_order.rb | Converts to typed: strict and changes stanza sort implementation. |
| Library/Homebrew/rubocops/cask/stanza_grouping.rb | Converts to typed: strict, adds ivar typing and helper methods. |
| Library/Homebrew/rubocops/cask/extend/node.rbi | Adds an RBI definition for RuboCop::AST::BlockNode#method_node. |
| Library/Homebrew/rubocops/cask/ast/stanza.rb | Narrows stanza method_node types to specific AST node unions. |
| Library/Homebrew/rubocops/cask/ast/cask_header.rb | Converts to typed: strict and adds memoized helpers with sigs. |
| Library/Homebrew/rubocops/cask/array_alphabetization.rb | Converts to typed: strict and tightens nil handling in sorting logic. |
| Library/Homebrew/rubocops/bottle.rb | Adds a cast to align cellar_node typing with first_argument usage. |
Files not reviewed (2)
- Library/Homebrew/rubocops/cask/extend/node.rbi: Language not supported
- Library/Homebrew/sorbet/rbi/upstream.rbi: Language not supported
Comments suppressed due to low confidence (1)
Library/Homebrew/rubocops/dependency_order.rb:96
- Minor style issue:
if idx1 &&idx2is missing a space after&&. This will likely violate the project's RuboCop spacing rules and reduce readability; consideridx1 && idx2.
end
insert_after!(ordered, idx1, idx2 + idx1) if idx1 &&idx2
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
samford
reviewed
Mar 2, 2026
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
f8c0811 to
841d78a
Compare
dduugg
commented
Mar 31, 2026
841d78a to
8ffebdb
Compare
8ffebdb to
d03d51d
Compare
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?Gets us a bit closer to the finish line of #17297