diff --git a/Library/Homebrew/cask/upgrade.rb b/Library/Homebrew/cask/upgrade.rb index b6a077de52..1a1715f884 100644 --- a/Library/Homebrew/cask/upgrade.rb +++ b/Library/Homebrew/cask/upgrade.rb @@ -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 diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index d512b65190..cb24586918 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -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? diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 2b5f46217a..e744d4d6ce 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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)}" diff --git a/Library/Homebrew/livecheck/skip_conditions.rb b/Library/Homebrew/livecheck/skip_conditions.rb index d1c5b7cc68..4ed474dea6 100644 --- a/Library/Homebrew/livecheck/skip_conditions.rb +++ b/Library/Homebrew/livecheck/skip_conditions.rb @@ -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]}" diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb index 47cdbc3ed3..bf4e2d66ee 100644 --- a/Library/Homebrew/rubocops/extend/formula_cop.rb +++ b/Library/Homebrew/rubocops/extend/formula_cop.rb @@ -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) diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index ada047d8e2..d4235ebb21 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -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? diff --git a/Library/Homebrew/uninstall.rb b/Library/Homebrew/uninstall.rb index c8d0e59ae8..cf0e9aa9f6 100644 --- a/Library/Homebrew/uninstall.rb +++ b/Library/Homebrew/uninstall.rb @@ -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 diff --git a/Library/Homebrew/unversioned_cask_checker.rb b/Library/Homebrew/unversioned_cask_checker.rb index 6570507469..195ecdd184 100644 --- a/Library/Homebrew/unversioned_cask_checker.rb +++ b/Library/Homebrew/unversioned_cask_checker.rb @@ -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