Skip to content

Conversation

@dduugg
Copy link
Member

@dduugg dduugg commented Dec 29, 2025

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

This is a bit of an opinionated PR. The rationale is:

  • We already enforced a max limit of _1, via Style/NumberedParametersLimit, so the numbering isn't useful. Additionally, it has better readability (IMO).
  • Mixing it and _1 presents unnecessary confusion to novice ruby coders
  • Supporting both styles requires more technical lift (for instance, rubocop-ast has separate node types for itblock and numblock
  • We previously avoided it because sorbet didn't support it. This was fixed in Add support for 'it' as the default block param sorbet/sorbet#9443.

(Note that there are some subtle behavior differences between it and _1, elaborated here, so this is not a safe autocorrect (though the differences should be unlikely to matter).)

Copilot AI review requested due to automatic review settings December 29, 2025 00:15
@dduugg dduugg force-pushed the dug/it-block-params branch from 22934a5 to 8fcd614 Compare December 29, 2025 00:16
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

This PR converts numbered block parameters (_1) to the it parameter throughout the Homebrew codebase. The rationale is to improve readability and reduce confusion for Ruby novices by standardizing on a single block parameter syntax, now that Sorbet supports it.

Key changes:

  • Replaces all instances of _1 with it in single-parameter blocks across 28 files
  • Updates RuboCop configuration for Style/ItBlockParameter to enforce the new convention
  • Adds on_itblock alias to RuboCop cask helper to handle both on_block and on_itblock AST node types
  • Adds comprehensive test coverage for itblock syntax in cask RuboCop cop tests

Reviewed changes

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

Show a summary per file
File Description
Library/.rubocop.yml Updates Style/ItBlockParameter configuration and removes Layout/EmptyLinesAfterModuleInclusion rule
Library/Homebrew/rubocops/cask/mixin/cask_help.rb Adds on_itblock alias to support itblock AST nodes
Library/Homebrew/test/rubocops/cask/no_overrides_spec.rb Adds test cases for itblock syntax in cask cop tests
Library/Homebrew/test/tab_spec.rb Converts _1 to it in Pathname.new calls
Library/Homebrew/test/cask/list_spec.rb Converts _1 to it in InstallHelper call
Library/Homebrew/tap.rb Converts _1 to it in formula_file_to_name and from_path calls
Library/Homebrew/tab.rb Converts _1 to it in Version.new calls
Library/Homebrew/system_command.rb Converts _1 to it in write operation
Library/Homebrew/style.rb Converts _1 to it in Pathname call
Library/Homebrew/sorbet/tapioca/utils.rb Converts _1 to it in method reflection calls
Library/Homebrew/sorbet/tapioca/require.rb Converts _1 to it in require call
Library/Homebrew/sorbet/tapioca/compilers/args.rb Converts _1 to it in option_to_name and require calls
Library/Homebrew/service.rb Converts _1 to it in replace_placeholders calls
Library/Homebrew/os/mac/mach.rb Converts _1 to it in resolve_variable_name call
Library/Homebrew/manpages.rb Converts _1 to it in sort_key_for_path call
Library/Homebrew/livecheck/livecheck.rb Converts _1 to it in require call
Library/Homebrew/keg_relocate.rb Converts _1 to it in path.join call
Library/Homebrew/formula_installer.rb Converts _1 to it in Formatter.identifier and install/fetch_dependency calls
Library/Homebrew/formula.rb Converts _1 to it in split call
Library/Homebrew/extend/os/linux/extend/ENV/super.rb Converts _1 to it in dependency check
Library/Homebrew/diagnostic.rb Converts _1 to it in user_tilde call
Library/Homebrew/dev-cmd/formula.rb Converts _1 to it in puts call
Library/Homebrew/dev-cmd/extract.rb Converts _1 to it in Tap.with_formula_name call
Library/Homebrew/dev-cmd/edit.rb Converts _1 to it in puts call
Library/Homebrew/dev-cmd/bump.rb Converts _1 to it in drop call
Library/Homebrew/description_cache_store.rb Converts _1 to it in delete! call
Library/Homebrew/cmd/install.rb Converts _1 to it in is_a? check
Library/Homebrew/cli/parser.rb Converts _1 to it in name_to_option and disable_switch calls
Library/Homebrew/cli/error.rb Converts _1 to it in Formatter.option call
Library/Homebrew/cli/args.rb Converts _1 to it in start_with? checks
Library/Homebrew/cleanup.rb Converts _1 to it in T.cast and skip_clean_formula? calls
Library/Homebrew/cask/pkg.rb Converts _1 to it in special? check
Library/Homebrew/cask/list.rb Converts _1 to it in format_versioned and list_artifacts calls
Library/Homebrew/cask/dsl/version.rb Converts _1 to it in Version constructor
Library/Homebrew/cask/artifact/app.rb Converts _1 to it in OS::Mac.system_dir? check
Library/Homebrew/bundle/formula_dumper.rb Converts _1 to it in add_formula call
Library/Homebrew/bundle/commands/cleanup.rb Converts _1 to it in lookup_formula call
Library/Homebrew/abstract_command.rb Converts _1 to it in command_name comparison
Library/Homebrew/PATH.rb Converts _1 to it in File.directory? check

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

This reads much nicer to me, thanks @dduugg!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Dec 29, 2025
Merged via the queue into main with commit 000b0fc Dec 29, 2025
46 checks passed
@MikeMcQuaid MikeMcQuaid deleted the dug/it-block-params branch December 29, 2025 08:57
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