Skip to content

Commit

Permalink
Merge pull request #14739 from issyl0/rubocop-disable-all-metrics
Browse files Browse the repository at this point in the history
rubocop: Entirely disable `Metrics` cops
  • Loading branch information
MikeMcQuaid authored Feb 21, 2023
2 parents f0fbeba + 298bb65 commit 98d9f28
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 42 deletions.
19 changes: 2 additions & 17 deletions Library/Homebrew/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,8 @@ Layout/MultilineMethodCallIndentation:
Exclude:
- "**/*_spec.rb"

# TODO: Try to bring down all metrics maximums.
Metrics/AbcSize:
Max: 241
Metrics/BlockLength:
Max: 86
Metrics/BlockNesting:
Max: 5
Metrics/ClassLength:
Max: 736
Metrics/CyclomaticComplexity:
Max: 68
Metrics/PerceivedComplexity:
Max: 84
Metrics/MethodLength:
Max: 232
Metrics/ModuleLength:
Max: 481
Metrics:
Enabled: false

Naming/PredicateName:
AllowedMethods:
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Homebrew

sig { returns(CLI::Parser) }
def install_args
Homebrew::CLI::Parser.new do # rubocop:disable Metrics/BlockLength
Homebrew::CLI::Parser.new do
description <<~EOS
Install a <formula> or <cask>. Additional options specific to a <formula> may be
appended to the command.
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/dev-cmd/bottle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
%r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Homebrew/os/(mac|linux)/pkgconfig},
].freeze

module Homebrew # rubocop:disable Metrics/ModuleLength
module Homebrew
extend T::Sig

module_function
Expand Down Expand Up @@ -591,7 +591,7 @@ def merge(args:)
bottles_hash = merge_json_files(parse_json_files(args.named))

any_cellars = ["any", "any_skip_relocation"]
bottles_hash.each do |formula_name, bottle_hash| # rubocop:disable Metrics/BlockLength
bottles_hash.each do |formula_name, bottle_hash|
ohai formula_name

bottle = BottleSpecification.new
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# system "make", "install"
# end
# end</pre>
class Formula # rubocop:disable Metrics/ClassLength
class Formula
extend T::Sig

include FileUtils
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Installer for a formula.
#
# @api private
class FormulaInstaller # rubocop:disable Metrics/ClassLength
class FormulaInstaller
extend T::Sig

include FormulaCellarChecks
Expand Down
18 changes: 4 additions & 14 deletions Library/Homebrew/livecheck/livecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
require "uri"

module Homebrew
# rubocop:disable Metrics/ModuleLength

# The {Livecheck} module consists of methods used by the `brew livecheck`
# command. These methods print the requested livecheck information
# for formulae.
Expand Down Expand Up @@ -158,8 +156,6 @@ def resolve_livecheck_reference(

# Executes the livecheck logic for each formula/cask in the
# `formulae_and_casks_to_check` array and prints the results.
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
sig {
params(
formulae_and_casks_to_check: T::Array[T.any(Formula, Cask::Cask)],
Expand Down Expand Up @@ -217,7 +213,6 @@ def run_checks(
)
end

# rubocop:disable Metrics/BlockLength
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)
cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask)
Expand Down Expand Up @@ -383,7 +378,10 @@ def run_checks(

if json
progress&.increment
status_hash(formula_or_cask, "error", [e.to_s], full_name: use_full_name, verbose: verbose) unless quiet
unless quiet
status_hash(formula_or_cask, "error", [e.to_s], full_name: use_full_name,
verbose: verbose)
end
elsif !quiet
name = package_or_resource_name(formula_or_cask, full_name: use_full_name)
name += " (cask)" if ambiguous_casks.include?(formula_or_cask)
Expand Down Expand Up @@ -627,7 +625,6 @@ def use_homebrew_curl?(formula_or_cask, url)

# Identifies the latest version of the formula/cask and returns a Hash containing
# the version information. Returns nil if a latest version couldn't be found.
# rubocop:disable Metrics/CyclomaticComplexity
sig {
params(
formula_or_cask: T.any(Formula, Cask::Cask),
Expand Down Expand Up @@ -685,7 +682,6 @@ def latest_version(
end

checked_urls = []
# rubocop:disable Metrics/BlockLength
urls.each_with_index do |original_url, i|
# Only preprocess the URL when it's appropriate
url = if STRATEGY_SYMBOLS_TO_SKIP_PREPROCESS_URL.include?(livecheck_strategy)
Expand Down Expand Up @@ -828,12 +824,8 @@ def latest_version(

return version_info
end
# rubocop:enable Metrics/BlockLength

nil
end
# rubocop:enable Metrics/CyclomaticComplexity

# Identifies the latest version of a resource and returns a Hash containing the
# version information. Returns nil if a latest version couldn't be found.
sig {
Expand Down Expand Up @@ -876,7 +868,6 @@ def resource_version(
urls ||= checkable_urls(resource)

checked_urls = []
# rubocop:disable Metrics/BlockLength
urls.each_with_index do |original_url, i|
url = original_url.gsub(Constants::LATEST_VERSION, formula_latest)

Expand Down Expand Up @@ -1020,7 +1011,6 @@ def resource_version(
nil
end
end
# rubocop:enable Metrics/BlockLength
resource_version_info
end
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/rubocops/lines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
install = find_method_def(body_node, :install)
return if install.blank?

correctable_shell_completion_node(install) do |node, shell, base_name, executable, subcmd, shell_parameter| # rubocop:disable Metrics/ParameterLists
correctable_shell_completion_node(install) do |node, shell, base_name, executable, subcmd, shell_parameter|
# generate_completions_from_executable only applicable if shell is passed
next unless shell_parameter.match?(/(bash|zsh|fish)/)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

require "benchmark"

shared_examples "#uninstall_phase or #zap_phase" do # rubocop:disable Metrics/BlockLength
shared_examples "#uninstall_phase or #zap_phase" do
subject { artifact }

let(:artifact_dsl_key) { described_class.dsl_key }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/dev-cmd/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def self.increment
end
end

module Homebrew # rubocop:disable Metrics/ModuleLength
module Homebrew
describe FormulaTextAuditor do
alias_matcher :have_data, :be_data
alias_matcher :have_end, :be_end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# work when type-checking is active.
RSpec::Sorbet.allow_doubles!

RSpec.configure do |config| # rubocop:disable Metrics/BlockLength
RSpec.configure do |config|
config.order = :random

config.raise_errors_for_deprecations!
Expand Down Expand Up @@ -181,7 +181,7 @@
skip "Unzip is not installed." unless which("unzip")
end

config.around do |example| # rubocop:disable Metrics/BlockLength
config.around do |example|
def find_files
return [] unless File.exist?(TEST_TMPDIR)

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/utils/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Wrapper functions for the GitHub API.
#
# @api private
module GitHub # rubocop:disable Metrics/ModuleLength
module GitHub
extend T::Sig

include SystemCommand::Mixin
Expand Down

0 comments on commit 98d9f28

Please sign in to comment.