From c59d9fa83350ccaea761cf0463a122317d3d691d Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Mon, 8 Apr 2024 09:47:06 -0700 Subject: [PATCH] Prefer numbered block params over proc conversion, cont'd --- Library/Homebrew/cask/list.rb | 4 ++-- Library/Homebrew/cask/pkg.rb | 2 +- Library/Homebrew/cleanup.rb | 4 ++-- Library/Homebrew/cli/parser.rb | 4 ++-- Library/Homebrew/cmd/leaves.rb | 6 +++--- Library/Homebrew/commands.rb | 4 ++-- Library/Homebrew/diagnostic.rb | 2 +- Library/Homebrew/manpages.rb | 2 +- Library/Homebrew/os/mac/mach.rb | 2 +- Library/Homebrew/service.rb | 4 ++-- Library/Homebrew/tap.rb | 10 +++++----- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Library/Homebrew/cask/list.rb b/Library/Homebrew/cask/list.rb index aa3a84867d..82d0ddf2ad 100644 --- a/Library/Homebrew/cask/list.rb +++ b/Library/Homebrew/cask/list.rb @@ -20,9 +20,9 @@ module Cask elsif full_name puts output.map(&:full_name).sort(&tap_and_name_comparison) elsif versions - puts output.map(&method(:format_versioned)) + puts output.map { format_versioned(_1) } elsif !output.empty? && casks.any? - output.map(&method(:list_artifacts)) + output.map { list_artifacts(_1) } elsif !output.empty? puts Formatter.columns(output.map(&:to_s)) end diff --git a/Library/Homebrew/cask/pkg.rb b/Library/Homebrew/cask/pkg.rb index 49dcade6b0..8d204251d7 100644 --- a/Library/Homebrew/cask/pkg.rb +++ b/Library/Homebrew/cask/pkg.rb @@ -76,7 +76,7 @@ module Cask sig { returns(T::Array[Pathname]) } def pkgutil_bom_specials - @pkgutil_bom_specials ||= pkgutil_bom_all.select(&method(:special?)) + @pkgutil_bom_specials ||= pkgutil_bom_all.select { special?(_1) } end sig { returns(T::Array[Pathname]) } diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index bb4301fb49..d3176c26ca 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -345,7 +345,7 @@ module Homebrew def cleanup_formula(formula, quiet: false, ds_store: true, cache_db: true) formula.eligible_kegs_for_cleanup(quiet:) - .each(&method(:cleanup_keg)) + .each { cleanup_keg(_1) } cleanup_cache(Pathname.glob(cache/"#{formula.name}{_bottle_manifest,}--*").map { |path| { path:, type: nil } }) rm_ds_store([formula.rack]) if ds_store cleanup_cache_db(formula.rack) if cache_db @@ -687,7 +687,7 @@ module Homebrew formulae = Formula.installed # Remove formulae listed in HOMEBREW_NO_CLEANUP_FORMULAE and their dependencies. if Homebrew::EnvConfig.no_cleanup_formulae.present? - formulae -= formulae.select(&method(:skip_clean_formula?)) + formulae -= formulae.select { skip_clean_formula?(_1) } .flat_map { |f| [f, *f.runtime_formula_dependencies] } end casks = Cask::Caskroom.casks diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index 0f042094b8..74312ae63f 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -590,9 +590,9 @@ module Homebrew end select_cli_arg = violations.count - env_var_options.count == 1 - raise OptionConflictError, violations.map(&method(:name_to_option)) unless select_cli_arg + raise OptionConflictError, violations.map { name_to_option(_1) } unless select_cli_arg - env_var_options.each(&method(:disable_switch)) + env_var_options.each { disable_switch(_1) } end end diff --git a/Library/Homebrew/cmd/leaves.rb b/Library/Homebrew/cmd/leaves.rb index d679fbee08..4534a678fb 100644 --- a/Library/Homebrew/cmd/leaves.rb +++ b/Library/Homebrew/cmd/leaves.rb @@ -29,12 +29,12 @@ module Homebrew CaskDependent.new(cask).runtime_dependencies.map(&:to_formula) end leaves_list -= casks_runtime_dependencies - leaves_list.select!(&method(:installed_on_request?)) if args.installed_on_request? - leaves_list.select!(&method(:installed_as_dependency?)) if args.installed_as_dependency? + leaves_list.select! { installed_on_request?(_1) } if args.installed_on_request? + leaves_list.select! { installed_as_dependency?(_1) } if args.installed_as_dependency? leaves_list.map(&:full_name) .sort - .each(&method(:puts)) + .each { puts(_1) } end private diff --git a/Library/Homebrew/commands.rb b/Library/Homebrew/commands.rb index 2afbd84c6a..d57563a27d 100644 --- a/Library/Homebrew/commands.rb +++ b/Library/Homebrew/commands.rb @@ -135,13 +135,13 @@ module Commands def self.find_internal_commands(path) find_commands(path).map(&:basename) - .map(&method(:basename_without_extension)) + .map { basename_without_extension(_1) } end def self.external_commands Tap.cmd_directories.flat_map do |path| find_commands(path).select(&:executable?) - .map(&method(:basename_without_extension)) + .map { basename_without_extension(_1) } .map { |p| p.to_s.delete_prefix("brew-").strip } end.map(&:to_s) .sort diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index e0841e73bf..9792ed45f6 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -963,7 +963,7 @@ module Homebrew end def check_cask_load_path - paths = $LOAD_PATH.map(&method(:user_tilde)) + paths = $LOAD_PATH.map { user_tilde(_1) } add_info "$LOAD_PATHS", paths.presence || none_string diff --git a/Library/Homebrew/manpages.rb b/Library/Homebrew/manpages.rb index 9e05bb8151..5454a88544 100644 --- a/Library/Homebrew/manpages.rb +++ b/Library/Homebrew/manpages.rb @@ -81,7 +81,7 @@ module Homebrew man_page_lines = [] # preserve existing manpage order - cmd_paths.sort_by(&method(:sort_key_for_path)) + cmd_paths.sort_by { sort_key_for_path(_1) } .each do |cmd_path| cmd_man_page_lines = if (cmd_parser = Homebrew::CLI::Parser.from_cmd_path(cmd_path)) next if cmd_parser.hide_from_man_page diff --git a/Library/Homebrew/os/mac/mach.rb b/Library/Homebrew/os/mac/mach.rb index b1ecd686ed..1580f06b9b 100644 --- a/Library/Homebrew/os/mac/mach.rb +++ b/Library/Homebrew/os/mac/mach.rb @@ -90,7 +90,7 @@ module MachOShim def dynamically_linked_libraries(except: :none, resolve_variable_references: true) lcs = macho.dylib_load_commands.reject { |lc| lc.type == except } names = lcs.map { |lc| lc.name.to_s }.uniq - names.map!(&method(:resolve_variable_name)) if resolve_variable_references + names.map! { resolve_variable_name(_1) } if resolve_variable_references names end diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb index 1fb732076d..0f479f4d0a 100644 --- a/Library/Homebrew/service.rb +++ b/Library/Homebrew/service.rb @@ -581,11 +581,11 @@ module Homebrew when String replace_placeholders(api_hash["run"]) when Array - api_hash["run"].map(&method(:replace_placeholders)) + api_hash["run"].map { replace_placeholders(_1) } when Hash api_hash["run"].to_h do |key, elem| run_cmd = if elem.is_a?(Array) - elem.map(&method(:replace_placeholders)) + elem.map { replace_placeholders(_1) } else replace_placeholders(elem) end diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 8599a20bfc..4378f5561b 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -622,7 +622,7 @@ class Tap formula_dir.children else formula_dir.find - end.select(&method(:formula_file?)) + end.select { formula_file?(_1) } else [] end @@ -645,7 +645,7 @@ class Tap sig { returns(T::Array[Pathname]) } def cask_files @cask_files ||= if cask_dir.directory? - cask_dir.find.select(&method(:ruby_file?)) + cask_dir.find.select { ruby_file?(_1) } else [] end @@ -699,7 +699,7 @@ class Tap # An array of all {Formula} names of this {Tap}. sig { returns(T::Array[String]) } def formula_names - @formula_names ||= formula_files.map(&method(:formula_file_to_name)) + @formula_names ||= formula_files.map { formula_file_to_name(_1) } end # A hash of all {Formula} name prefixes to versioned {Formula} in this {Tap}. @@ -716,7 +716,7 @@ class Tap # An array of all {Cask} tokens of this {Tap}. sig { returns(T::Array[String]) } def cask_tokens - @cask_tokens ||= cask_files.map(&method(:formula_file_to_name)) + @cask_tokens ||= cask_files.map { formula_file_to_name(_1) } end # path to the directory of all alias files for this {Tap}. @@ -944,7 +944,7 @@ class Tap sig { returns(T::Array[Tap]) } def self.installed cache[:installed] ||= if TAP_DIRECTORY.directory? - TAP_DIRECTORY.subdirs.flat_map(&:subdirs).map(&method(:from_path)) + TAP_DIRECTORY.subdirs.flat_map(&:subdirs).map { from_path(_1) } else [] end