Skip to content
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

Prefer numbered block params over proc conversion #16807

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
.stdout
.split("\n")
.map { |path| root.join(path) }
.reject(&MacOS.public_method(:undeletable?))
.reject { MacOS.undeletable?(_1) }

Check warning on line 93 in Library/Homebrew/cask/pkg.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cask/pkg.rb#L93

Added line #L93 was not covered by tests
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 @@
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}",

Check warning on line 667 in Library/Homebrew/formula_installer.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_installer.rb#L667

Added line #L667 was not covered by tests
truncate: false
deps.each { |dep, options| install_dependency(dep, options) }
end
Expand Down Expand Up @@ -1184,7 +1184,7 @@
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}",

Check warning on line 1187 in Library/Homebrew/formula_installer.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_installer.rb#L1187

Added line #L1187 was not covered by tests
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