From 7a5d4256e57d16d8860addefb6210dc6595f3b51 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 28 Feb 2025 09:59:32 +0000 Subject: [PATCH] Fix Rubocop warnings (without `brew style --fix`) --- Library/Homebrew/diagnostic.rb | 14 ++++++-------- Library/Homebrew/formula_installer.rb | 7 ++----- Library/Homebrew/locale.rb | 8 +++----- Library/Homebrew/style.rb | 14 ++++---------- Library/Homebrew/utils/analytics.rb | 6 ------ Library/Homebrew/utils/pypi.rb | 7 ++----- 6 files changed, 17 insertions(+), 39 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 67c53b1f4f..45757ece68 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -748,14 +748,12 @@ module Homebrew def check_for_unlinked_but_not_keg_only unlinked = Formula.racks.reject do |rack| - if (HOMEBREW_LINKED_KEGS/rack.basename).directory? - true - else - begin - Formulary.from_rack(rack).keg_only? - rescue FormulaUnavailableError, TapFormulaAmbiguityError - false - end + next true if (HOMEBREW_LINKED_KEGS/rack.basename).directory? + + begin + Formulary.from_rack(rack).keg_only? + rescue FormulaUnavailableError, TapFormulaAmbiguityError + false end end.map(&:basename) return if unlinked.empty? diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index e87c14df85..1fab9334b9 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -809,11 +809,8 @@ on_request: installed_on_request?, options:) options |= inherited_options options &= df.options - installed_on_request = if df.any_version_installed? && tab.present? && tab.installed_on_request - true - else - false - end + installed_on_request = df.any_version_installed? && tab.present? && tab.installed_on_request + installed_on_request ||= false fi = FormulaInstaller.new( df, diff --git a/Library/Homebrew/locale.rb b/Library/Homebrew/locale.rb index 49b28c0795..040647f218 100644 --- a/Library/Homebrew/locale.rb +++ b/Library/Homebrew/locale.rb @@ -81,11 +81,9 @@ class Locale end [:language, :script, :region].all? do |var| - if other.public_send(var).nil? - true - else - public_send(var) == other.public_send(var) - end + next true if other.public_send(var).nil? + + public_send(var) == other.public_send(var) end end diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index e25271138b..8d9d99f366 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -85,21 +85,15 @@ module Homebrew run_shellcheck(shell_files, output_type, fix:) end - shfmt_result = if files.present? && shell_files.empty? - true - else - run_shfmt(shell_files, fix:) - end + shfmt_result = files.present? && shell_files.empty? + shfmt_result ||= run_shfmt(shell_files, fix:) has_actionlint_workflow = actionlint_files.any? do |path| path.to_s.end_with?("/.github/workflows/actionlint.yml") end odebug "actionlint workflow detected. Skipping actionlint checks." if has_actionlint_workflow - actionlint_result = if files.present? && (has_actionlint_workflow || actionlint_files.empty?) - true - else - run_actionlint(actionlint_files) - end + actionlint_result = files.present? && (has_actionlint_workflow || actionlint_files.empty?) + actionlint_result ||= run_actionlint(actionlint_files) if output_type == :json Offenses.new(rubocop_result + shellcheck_result) diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index fc38425a8f..54674b019f 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -71,9 +71,6 @@ module Utils def report_package_event(measurement, package_name:, tap_name:, on_request: false, options: "") return if not_this_run? || disabled? - # ensure on_request is a boolean - on_request = on_request ? true : false - # ensure options are removed (by `.compact` below) if empty options = nil if options.blank? @@ -137,9 +134,6 @@ module Utils return if not_this_run? || disabled? return if ENV["HOMEBREW_TEST_BOT_ANALYTICS"].blank? - # ensure passed is a boolean - passed = passed ? true : false - # Tags must have low cardinality. tags = { passed:, diff --git a/Library/Homebrew/utils/pypi.rb b/Library/Homebrew/utils/pypi.rb index d8920b3d75..9005162454 100644 --- a/Library/Homebrew/utils/pypi.rb +++ b/Library/Homebrew/utils/pypi.rb @@ -340,11 +340,8 @@ module PyPI show_info = !print_only && !silent ohai "Retrieving PyPI dependencies for \"#{input_packages.join(" ")}\"..." if show_info - print_stderr = if verbose && show_info - true - else - false - end + print_stderr = verbose && show_info + print_stderr ||= false found_packages = pip_report(input_packages, python_name:, print_stderr:) # Resolve the dependency tree of excluded packages to prune the above