Fix Style/ObjectThen offences
This commit is contained in:
parent
8500c26419
commit
f5dc7a571f
@ -225,7 +225,7 @@ class URL < Delegator
|
||||
@raw_interpolated_url =
|
||||
Pathname(@caller_location.absolute_path)
|
||||
.each_line.drop(@caller_location.lineno - 1)
|
||||
.first&.yield_self { |line| line[/url\s+"([^"]+)"/, 1] }
|
||||
.first&.then { |line| line[/url\s+"([^"]+)"/, 1] }
|
||||
end
|
||||
private :raw_interpolated_url
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ module Homebrew
|
||||
def cleanup
|
||||
args = cleanup_args.parse
|
||||
|
||||
days = args.prune.presence&.yield_self do |prune|
|
||||
days = args.prune.presence&.then do |prune|
|
||||
case prune
|
||||
when /\A\d+\Z/
|
||||
prune.to_i
|
||||
|
||||
@ -121,7 +121,7 @@ module Homebrew
|
||||
# TODO: 3.6.0: odeprecate not specifying args.all?, require args.installed?
|
||||
|
||||
audit_formulae, audit_casks = if args.tap
|
||||
Tap.fetch(args.tap).yield_self do |tap|
|
||||
Tap.fetch(args.tap).then do |tap|
|
||||
[
|
||||
tap.formula_names.map { |name| Formula[name] },
|
||||
tap.cask_files.map { |path| Cask::CaskLoader.load(path) },
|
||||
|
||||
@ -98,7 +98,7 @@ module Homebrew
|
||||
return
|
||||
end
|
||||
|
||||
last_check_time = state["check_time"]&.yield_self { |t| Time.parse(t) }
|
||||
last_check_time = state["check_time"]&.then { |t| Time.parse(t) }
|
||||
|
||||
check_time = Time.now
|
||||
if last_check_time && check_time < (last_check_time + 1.day)
|
||||
@ -107,7 +107,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
last_sha256 = state["sha256"]
|
||||
last_time = state["time"]&.yield_self { |t| Time.parse(t) }
|
||||
last_time = state["time"]&.then { |t| Time.parse(t) }
|
||||
last_file_size = state["file_size"]
|
||||
|
||||
download = Cask::Download.new(cask)
|
||||
|
||||
@ -52,7 +52,7 @@ module Homebrew
|
||||
if (macos = args.macos&.compact_blank) && macos.present?
|
||||
runners += macos.map do |element|
|
||||
# We accept runner name syntax (11-arm64) or bottle syntax (arm64_big_sur)
|
||||
os, arch = element.yield_self do |s|
|
||||
os, arch = element.then do |s|
|
||||
tag = Utils::Bottles::Tag.from_symbol(s.to_sym)
|
||||
[tag.to_macos_version, tag.arch]
|
||||
rescue ArgumentError, MacOSVersionError
|
||||
|
||||
@ -110,7 +110,7 @@ module Homebrew
|
||||
version ||= item.elements["version"]&.text&.strip
|
||||
|
||||
title = item.elements["title"]&.text&.strip
|
||||
pub_date = item.elements["pubDate"]&.text&.strip&.presence&.yield_self do |date_string|
|
||||
pub_date = item.elements["pubDate"]&.text&.strip&.presence&.then do |date_string|
|
||||
Time.parse(date_string)
|
||||
rescue ArgumentError
|
||||
# Omit unparseable strings (e.g. non-English dates)
|
||||
|
||||
@ -56,7 +56,7 @@ HOMEBREW_CACHE_FORMULA = (HOMEBREW_CACHE/"Formula").freeze
|
||||
HOMEBREW_LOGS = Pathname(EnvVar["HOMEBREW_LOGS"]).expand_path.freeze
|
||||
|
||||
# Must use `/tmp` instead of `TMPDIR` because long paths break Unix domain sockets
|
||||
HOMEBREW_TEMP = Pathname(EnvVar["HOMEBREW_TEMP"]).yield_self do |tmp|
|
||||
HOMEBREW_TEMP = Pathname(EnvVar["HOMEBREW_TEMP"]).then do |tmp|
|
||||
tmp.mkpath unless tmp.exist?
|
||||
tmp.realpath
|
||||
end.freeze
|
||||
|
||||
@ -130,7 +130,7 @@ module Homebrew
|
||||
Dir.mktmpdir do |dir|
|
||||
dir = Pathname(dir)
|
||||
|
||||
installer.yield_self do |i|
|
||||
installer.then do |i|
|
||||
i.extract_primary_container(to: dir)
|
||||
rescue ErrorDuringExecution => e
|
||||
onoe e
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user