-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Prefer it default params to numbered default params
#21330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
22934a5 to
8fcd614
Compare
There was a problem hiding this 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
_1withitin single-parameter blocks across 28 files - Updates RuboCop configuration for
Style/ItBlockParameterto enforce the new convention - Adds
on_itblockalias to RuboCop cask helper to handle bothon_blockandon_itblockAST node types - Adds comprehensive test coverage for
itblocksyntax 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.
MikeMcQuaid
left a comment
There was a problem hiding this 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!
brew lgtm(style, typechecking and tests) with your changes locally?This is a bit of an opinionated PR. The rationale is:
_1, viaStyle/NumberedParametersLimit, so the numbering isn't useful. Additionally,ithas better readability (IMO).itand_1presents unnecessary confusion to novice ruby codersitblockandnumblockitbecause 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
itand_1, elaborated here, so this is not a safe autocorrect (though the differences should be unlikely to matter).)