Skip to content

Commit

Permalink
Merge pull request #16807 from dduugg/numbered-params
Browse files Browse the repository at this point in the history
Prefer numbered block params over proc conversion
  • Loading branch information
MikeMcQuaid authored Mar 4, 2024
2 parents 5b01e59 + c4db192 commit c5e7282
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/PATH.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def empty?

sig { returns(T.nilable(T.self_type)) }
def existing
existing_path = select(&File.method(:directory?))
existing_path = select { File.directory?(_1) }
# return nil instead of empty PATH, to unset environment variables
existing_path unless existing_path.empty?
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def minor_patch
# @api public
sig { returns(T::Array[Version]) } # Only top-level T.self_type is supported https://sorbet.org/docs/self-type
def csv
split(",").map(&self.class.method(:new))
split(",").map { self.class.new(_1) }
end

# @api public
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def pkgutil_bom_all
.stdout
.split("\n")
.map { |path| root.join(path) }
.reject(&MacOS.public_method(:undeletable?))
.reject { MacOS.undeletable?(_1) }
end

sig { returns(Pathname) }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cli/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def initialize(arg1, arg2, missing: false)

class OptionConflictError < UsageError
def initialize(args)
args_list = args.map(&Formatter.public_method(:option))
args_list = args.map { Formatter.option(_1) }
.join(" and ")
super "Options #{args_list} are mutually exclusive."
end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ def install_dependencies(deps)
puts "All dependencies for #{formula.full_name} are satisfied."
elsif !deps.empty?
oh1 "Installing dependencies for #{formula.full_name}: " \
"#{deps.map(&:first).map(&Formatter.method(:identifier)).to_sentence}",
"#{deps.map(&:first).map { Formatter.identifier(_1) }.to_sentence}",
truncate: false
deps.each { |dep, options| install_dependency(dep, options) }
end
Expand Down Expand Up @@ -1184,7 +1184,7 @@ def fetch_dependencies
return if deps.empty?

oh1 "Fetching dependencies for #{formula.full_name}: " \
"#{deps.map(&:first).map(&Formatter.method(:identifier)).to_sentence}",
"#{deps.map(&:first).map { Formatter.identifier(_1) }.to_sentence}",
truncate: false

deps.each { |(dep, _options)| fetch_dependency(dep) }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/keg_relocate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def replace_text_in_files(relocation, files: nil)
files ||= text_files | libtool_files

changed_files = T.let([], Array)
files.map(&path.method(:join)).group_by { |f| f.stat.ino }.each_value do |first, *rest|
files.map { path.join(_1) }.group_by { |f| f.stat.ino }.each_value do |first, *rest|
s = first.open("rb", &:read)

next unless relocation.replace_text(s)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/system_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def each_output_line(&block)

sig { params(raw_stdin: IO).void }
def write_input_to(raw_stdin)
input.each(&raw_stdin.method(:write))
input.each { raw_stdin.write(_1) }
end

sig { params(sources: T::Array[IO], _block: T.proc.params(type: Symbol, line: String).void).void }
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ def versions
end

def stable_version
versions["stable"]&.then(&Version.method(:new))
versions["stable"]&.then { Version.new(_1) }
end

def head_version
versions["head"]&.then(&Version.method(:new))
versions["head"]&.then { Version.new(_1) }
end

def version_scheme
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
let(:casks) { [caffeine, transmission] }

it "lists the installed files for those Casks" do
casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile))
casks.each { InstallHelper.install_without_artifacts_with_caskfile(_1) }

transmission.artifacts.select { |a| a.is_a?(Cask::Artifact::App) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/uninstall_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
before do
app.tap(&:mkpath)
.join("Contents").tap(&:mkpath)
.join("Info.plist").tap(&FileUtils.method(:touch))
.join("Info.plist").tap { FileUtils.touch(_1) }

caskroom_path.mkpath

Expand Down

0 comments on commit c5e7282

Please sign in to comment.