Manually resolve Style/SafeNavigationChainLength violations

This commit is contained in:
Douglas Eichelberger 2024-11-02 15:03:10 -07:00 committed by Mike McQuaid
parent ffb15ffcf5
commit 521c463e36
No known key found for this signature in database
7 changed files with 28 additions and 16 deletions

View File

@ -173,8 +173,8 @@ module Cask
sig { returns(T.nilable(Time)) } sig { returns(T.nilable(Time)) }
def install_time def install_time
# <caskroom_path>/.metadata/<version>/<timestamp>/Casks/<token>.{rb,json} -> <timestamp> # <caskroom_path>/.metadata/<version>/<timestamp>/Casks/<token>.{rb,json} -> <timestamp>
time = installed_caskfile&.dirname&.dirname&.basename&.to_s caskfile = installed_caskfile
Time.strptime(time, Metadata::TIMESTAMP_FORMAT) if time caskfile ? Time.strptime(caskfile.dirname.dirname.basename.to_s, Metadata::TIMESTAMP_FORMAT) : nil
end end
sig { returns(T.nilable(Pathname)) } sig { returns(T.nilable(Pathname)) }

View File

@ -152,10 +152,11 @@ module Homebrew
resource_name = basename_str[/\A.*?--(.*?)--?(?:#{Regexp.escape(version.to_s)})/, 1] resource_name = basename_str[/\A.*?--(.*?)--?(?:#{Regexp.escape(version.to_s)})/, 1]
stable = formula.stable
if resource_name == "patch" if resource_name == "patch"
patch_hashes = formula.stable&.patches&.select(&:external?)&.map(&:resource)&.map(&:version) patch_hashes = stable&.patches&.filter_map { _1.resource.version if _1.external }
return true unless patch_hashes&.include?(Checksum.new(version.to_s)) return true unless patch_hashes&.include?(Checksum.new(version.to_s))
elsif resource_name && (resource_version = formula.stable&.resources&.dig(resource_name)&.version) elsif resource_name && stable && (resource_version = stable.resources[resource_name]&.version)
return true if resource_version != version return true if resource_version != version
elsif (formula.latest_version_installed? && formula.pkg_version.to_s != version) || elsif (formula.latest_version_installed? && formula.pkg_version.to_s != version) ||
formula.pkg_version.to_s > version formula.pkg_version.to_s > version

View File

@ -593,7 +593,11 @@ class Formula
# @api internal # @api internal
sig { returns(T::Array[String]) } sig { returns(T::Array[String]) }
def aliases def aliases
@aliases ||= tap&.alias_reverse_table&.dig(full_name)&.map { _1.split("/").last } || [] @aliases ||= if (tap = self.tap)
tap.alias_reverse_table.fetch(full_name, []).map { _1.split("/").last }
else
[]
end
end end
# The {Resource}s for the currently active {SoftwareSpec}. # The {Resource}s for the currently active {SoftwareSpec}.

View File

@ -418,10 +418,12 @@ module Formulary
@caveats_string = json_formula["caveats"] @caveats_string = json_formula["caveats"]
def caveats def caveats
self.class.instance_variable_get(:@caveats_string) caveats_string = self.class.instance_variable_get(:@caveats_string)
&.gsub(HOMEBREW_PREFIX_PLACEHOLDER, HOMEBREW_PREFIX) return unless caveats_string
&.gsub(HOMEBREW_CELLAR_PLACEHOLDER, HOMEBREW_CELLAR)
&.gsub(HOMEBREW_HOME_PLACEHOLDER, Dir.home) caveats_string.gsub(HOMEBREW_PREFIX_PLACEHOLDER, HOMEBREW_PREFIX)
.gsub(HOMEBREW_CELLAR_PLACEHOLDER, HOMEBREW_CELLAR)
.gsub(HOMEBREW_HOME_PLACEHOLDER, Dir.home)
end end
@tap_git_head_string = if Homebrew::API.internal_json_v3? @tap_git_head_string = if Homebrew::API.internal_json_v3?

View File

@ -195,8 +195,13 @@ module Homebrew
extract_plist = true if formulae_and_casks_total == 1 extract_plist = true if formulae_and_casks_total == 1
formulae_checked = formulae_and_casks_to_check.map.with_index do |formula_or_cask, i| formulae_checked = formulae_and_casks_to_check.map.with_index do |formula_or_cask, i|
formula = formula_or_cask if formula_or_cask.is_a?(Formula) case formula_or_cask
cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask) when Formula
formula = formula_or_cask
formula.head&.downloader&.quiet!
when Cask::Cask
cask = formula_or_cask
end
use_full_name = full_name || ambiguous_names.include?(formula_or_cask) use_full_name = full_name || ambiguous_names.include?(formula_or_cask)
name = package_or_resource_name(formula_or_cask, full_name: use_full_name) name = package_or_resource_name(formula_or_cask, full_name: use_full_name)
@ -238,8 +243,6 @@ module Homebrew
next next
end end
formula&.head&.downloader&.quiet!
# Use the `stable` version for comparison except for installed # Use the `stable` version for comparison except for installed
# head-only formulae. A formula with `stable` and `head` that's # head-only formulae. A formula with `stable` and `head` that's
# installed using `--head` will still use the `stable` version for # installed using `--head` will still use the `stable` version for

View File

@ -524,7 +524,7 @@ class Tap
Commands.rebuild_commands_completion_list Commands.rebuild_commands_completion_list
link_completions_and_manpages link_completions_and_manpages
formatted_contents = contents.presence&.to_sentence&.dup&.prepend(" ") formatted_contents = contents.presence&.to_sentence&.prepend(" ")
$stderr.puts "Tapped#{formatted_contents} (#{path.abv})." unless quiet $stderr.puts "Tapped#{formatted_contents} (#{path.abv})." unless quiet
require "description_cache_store" require "description_cache_store"
@ -622,7 +622,7 @@ class Tap
$stderr.puts "Untapping #{name}..." $stderr.puts "Untapping #{name}..."
abv = path.abv abv = path.abv
formatted_contents = contents.presence&.to_sentence&.dup&.prepend(" ") formatted_contents = contents.presence&.to_sentence&.prepend(" ")
require "description_cache_store" require "description_cache_store"
CacheStoreDatabase.use(:descriptions) do |db| CacheStoreDatabase.use(:descriptions) do |db|

View File

@ -154,7 +154,9 @@ module SPDX
if with_parts.length > 1 if with_parts.length > 1
{ with_parts.first => { with: with_parts.second } } { with_parts.first => { with: with_parts.second } }
else else
license_sym = result[/^#{LICENSEREF_PREFIX}(.+)/o, 1]&.downcase&.tr("-", "_")&.to_sym return result unless result.start_with?(LICENSEREF_PREFIX)
license_sym = result.delete_prefix(LICENSEREF_PREFIX).downcase.tr("-", "_").to_sym
ALLOWED_LICENSE_SYMBOLS.include?(license_sym) ? license_sym : result ALLOWED_LICENSE_SYMBOLS.include?(license_sym) ? license_sym : result
end end
end end