From f5dc7a571f2659324ca66598de9ce228804da82a Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Sat, 23 Apr 2022 01:47:37 +0100 Subject: [PATCH] Fix Style/ObjectThen offences --- Library/Homebrew/cask/url.rb | 2 +- Library/Homebrew/cmd/cleanup.rb | 2 +- Library/Homebrew/dev-cmd/audit.rb | 2 +- Library/Homebrew/dev-cmd/bump-unversioned-casks.rb | 4 ++-- Library/Homebrew/dev-cmd/dispatch-build-bottle.rb | 2 +- Library/Homebrew/livecheck/strategy/sparkle.rb | 2 +- Library/Homebrew/startup/config.rb | 2 +- Library/Homebrew/unversioned_cask_checker.rb | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cask/url.rb b/Library/Homebrew/cask/url.rb index d88e8dbc8c..fa09e3a0a5 100644 --- a/Library/Homebrew/cask/url.rb +++ b/Library/Homebrew/cask/url.rb @@ -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 diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index c61fbb1175..dbdde224cd 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -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 diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 746a6d7fad..c0b791056d 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -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) }, diff --git a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb index 3caf75982b..fad44a815f 100644 --- a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb +++ b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb @@ -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) diff --git a/Library/Homebrew/dev-cmd/dispatch-build-bottle.rb b/Library/Homebrew/dev-cmd/dispatch-build-bottle.rb index ae9dfe0bb9..4fd2780245 100644 --- a/Library/Homebrew/dev-cmd/dispatch-build-bottle.rb +++ b/Library/Homebrew/dev-cmd/dispatch-build-bottle.rb @@ -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 diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index bddb6bc8ef..ae1e30567e 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -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) diff --git a/Library/Homebrew/startup/config.rb b/Library/Homebrew/startup/config.rb index 29d3088bff..26470cc464 100644 --- a/Library/Homebrew/startup/config.rb +++ b/Library/Homebrew/startup/config.rb @@ -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 diff --git a/Library/Homebrew/unversioned_cask_checker.rb b/Library/Homebrew/unversioned_cask_checker.rb index 0f68c67a10..af6a659573 100644 --- a/Library/Homebrew/unversioned_cask_checker.rb +++ b/Library/Homebrew/unversioned_cask_checker.rb @@ -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