Skip to content

Enable strict typing in Library/Homebrew/rubocops/#21540

Merged
dduugg merged 1 commit intomainfrom
strict-typing-rubocops
Mar 31, 2026
Merged

Enable strict typing in Library/Homebrew/rubocops/#21540
dduugg merged 1 commit intomainfrom
strict-typing-rubocops

Conversation

@dduugg
Copy link
Copy Markdown
Member

@dduugg dduugg commented Feb 7, 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.

Gets us a bit closer to the finish line of #17297

@dduugg dduugg force-pushed the strict-typing-rubocops branch 2 times, most recently from fd290ef to f8c0811 Compare February 7, 2026 22:15
Copy link
Copy Markdown
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.

Looks good when 🟢!

@MikeMcQuaid MikeMcQuaid marked this pull request as ready for review March 2, 2026 08:25
Copilot AI review requested due to automatic review settings March 2, 2026 08:25
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Mar 2, 2026
Copy link
Copy Markdown
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

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: strict and add/update Sorbet sigs.
  • Replace a number of .first/.last argument 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 &&idx2 is missing a space after &&. This will likely violate the project's RuboCop spacing rules and reduce readability; consider idx1 && 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.

Comment thread Library/Homebrew/rubocops/cask/stanza_order.rb
Comment thread Library/Homebrew/rubocops/cask/ast/cask_header.rb
Comment thread Library/Homebrew/rubocops/cask/ast/cask_header.rb
Comment thread Library/Homebrew/rubocops/shared/helper_functions.rb
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 2, 2026
Comment thread Library/Homebrew/rubocops/urls.rb Outdated
@github-actions
Copy link
Copy Markdown

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.

@github-actions github-actions bot added the stale No recent activity label Mar 24, 2026
@github-actions github-actions bot closed this Mar 31, 2026
@github-actions github-actions bot deleted the strict-typing-rubocops branch March 31, 2026 00:27
@dduugg dduugg restored the strict-typing-rubocops branch March 31, 2026 02:22
@dduugg dduugg reopened this Mar 31, 2026
@dduugg dduugg force-pushed the strict-typing-rubocops branch from f8c0811 to 841d78a Compare March 31, 2026 02:30
@github-actions github-actions bot removed the stale No recent activity label Mar 31, 2026
Comment thread Library/Homebrew/rubocops/shared/helper_functions.rb
@dduugg dduugg force-pushed the strict-typing-rubocops branch from 841d78a to 8ffebdb Compare March 31, 2026 02:59
@dduugg dduugg force-pushed the strict-typing-rubocops branch from 8ffebdb to d03d51d Compare March 31, 2026 03:05
@dduugg dduugg enabled auto-merge March 31, 2026 03:29
@dduugg dduugg requested review from MikeMcQuaid and samford March 31, 2026 03:32
Copy link
Copy Markdown
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.

Seems fine if 🟢, thanks!

@dduugg dduugg added this pull request to the merge queue Mar 31, 2026
Merged via the queue into main with commit 7ad35f8 Mar 31, 2026
40 checks passed
@dduugg dduugg deleted the strict-typing-rubocops branch March 31, 2026 08:05
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.

5 participants