mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
various: correct Style/CollectionQuerying
Signed-off-by: Patrick Linnane <patrick@linnane.io>
This commit is contained in:
parent
b952ec1b0b
commit
cb15b67b8e
@ -134,7 +134,7 @@ module Cask
|
||||
|
||||
return true if caught_exceptions.empty?
|
||||
raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1
|
||||
raise caught_exceptions.fetch(0) if caught_exceptions.count == 1
|
||||
raise caught_exceptions.fetch(0) if caught_exceptions.one?
|
||||
|
||||
false
|
||||
end
|
||||
|
@ -723,7 +723,7 @@ module Homebrew
|
||||
all_bottle = !args.no_all_checks? &&
|
||||
(!old_bottle_spec_matches || bottle.rebuild != old_bottle_spec.rebuild) &&
|
||||
tag_hashes.count > 1 &&
|
||||
tag_hashes.uniq { |tag_hash| "#{tag_hash["cellar"]}-#{tag_hash["sha256"]}" }.count == 1
|
||||
tag_hashes.uniq { |tag_hash| "#{tag_hash["cellar"]}-#{tag_hash["sha256"]}" }.one?
|
||||
|
||||
old_all_bottle = old_bottle_spec.tag?(Utils::Bottles.tag(:all))
|
||||
if !all_bottle && old_all_bottle && !args.no_all_checks?
|
||||
|
@ -341,7 +341,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
|
||||
.reject { |path| path.extname.end_with?(".incomplete") }
|
||||
|
||||
@cached_location = T.let(
|
||||
if downloads.count == 1
|
||||
if downloads.one?
|
||||
downloads.fetch(0)
|
||||
else
|
||||
HOMEBREW_CACHE/"downloads/#{url_sha256}--#{Utils.safe_filename(resolved_basename)}"
|
||||
|
@ -323,7 +323,7 @@ module Homebrew
|
||||
end
|
||||
return unless name
|
||||
|
||||
if skip_hash[:messages].is_a?(Array) && skip_hash[:messages].count.positive?
|
||||
if skip_hash[:messages].is_a?(Array) && skip_hash[:messages].any?
|
||||
# TODO: Handle multiple messages, only if needed in the future
|
||||
if skip_hash[:status] == "skipped"
|
||||
puts "#{Tty.red}#{name}#{Tty.reset}: skipped - #{skip_hash[:messages][0]}"
|
||||
|
@ -228,13 +228,13 @@ module RuboCop
|
||||
rescue JSON::ParserError
|
||||
nil
|
||||
end
|
||||
next if list_contents.nil? || list_contents.count.zero?
|
||||
next if list_contents.nil? || list_contents.none?
|
||||
|
||||
@tap_style_exceptions[list_name] = list_contents
|
||||
end
|
||||
end
|
||||
|
||||
return false if @tap_style_exceptions.nil? || @tap_style_exceptions.count.zero?
|
||||
return false if @tap_style_exceptions.nil? || @tap_style_exceptions.none?
|
||||
return false unless @tap_style_exceptions.key? list
|
||||
|
||||
T.must(@tap_style_exceptions[list]).include?(formula || @formula_name)
|
||||
|
@ -176,7 +176,7 @@ module Homebrew
|
||||
|
||||
# Don't show the default formatter's progress dots
|
||||
# on CI or if only checking a single file.
|
||||
args << "--format" << "clang" if ENV["CI"] || files.count { |f| !f.directory? } == 1
|
||||
args << "--format" << "clang" if ENV["CI"] || files.one? { |f| !f.directory? }
|
||||
|
||||
args << "--color" if Tty.color?
|
||||
|
||||
|
@ -48,7 +48,7 @@ module Homebrew
|
||||
if rack.directory?
|
||||
versions = rack.subdirs.map(&:basename)
|
||||
puts <<~EOS
|
||||
#{keg.name} #{versions.to_sentence} #{(versions.count == 1) ? "is" : "are"} still installed.
|
||||
#{keg.name} #{versions.to_sentence} #{(versions.one?) ? "is" : "are"} still installed.
|
||||
To remove all versions, run:
|
||||
brew uninstall --force #{keg.name}
|
||||
EOS
|
||||
@ -133,7 +133,7 @@ module Homebrew
|
||||
def output
|
||||
ofail <<~EOS
|
||||
Refusing to uninstall #{reqs.to_sentence}
|
||||
because #{(reqs.count == 1) ? "it" : "they"} #{are_required_by_deps}.
|
||||
because #{(reqs.one?) ? "it" : "they"} #{are_required_by_deps}.
|
||||
You can override this and force removal with:
|
||||
#{sample_command}
|
||||
EOS
|
||||
@ -146,8 +146,8 @@ module Homebrew
|
||||
end
|
||||
|
||||
def are_required_by_deps
|
||||
"#{(reqs.count == 1) ? "is" : "are"} required by #{deps.to_sentence}, " \
|
||||
"which #{(deps.count == 1) ? "is" : "are"} currently installed"
|
||||
"#{(reqs.one?) ? "is" : "are"} required by #{deps.to_sentence}, " \
|
||||
"which #{(deps.one?) ? "is" : "are"} currently installed"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -72,17 +72,17 @@ module Homebrew
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def single_app_cask?
|
||||
apps.count == 1
|
||||
apps.one?
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def single_qlplugin_cask?
|
||||
qlplugins.count == 1
|
||||
qlplugins.one?
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def single_pkg_cask?
|
||||
pkgs.count == 1
|
||||
pkgs.one?
|
||||
end
|
||||
|
||||
# Filter paths to `Info.plist` files so that ones belonging
|
||||
@ -222,14 +222,14 @@ module Homebrew
|
||||
unique_info_plist_versions =
|
||||
top_level_info_plist_paths.filter_map { |i| BundleVersion.from_info_plist(i)&.nice_version }
|
||||
.uniq
|
||||
return unique_info_plist_versions.first if unique_info_plist_versions.count == 1
|
||||
return unique_info_plist_versions.first if unique_info_plist_versions.one?
|
||||
|
||||
package_info_path = extract_dir/"PackageInfo"
|
||||
if package_info_path.exist?
|
||||
if (version = BundleVersion.from_package_info(package_info_path))
|
||||
return version.nice_version
|
||||
end
|
||||
elsif packages.count == 1
|
||||
elsif packages.one?
|
||||
onoe "#{pkg_path.basename} does not contain a `PackageInfo` file."
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user