From dead4de3fc68360cf902563440c11d4c22c3d8a7 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Thu, 26 Jan 2023 21:18:24 -0800 Subject: [PATCH 1/5] Resolve Lint/EmptyBlock todos --- Library/Homebrew/.rubocop_todo.yml | 11 ----------- Library/Homebrew/dev-cmd/extract.rb | 16 ++++++++++++---- Library/Homebrew/test/cache_store_spec.rb | 4 +++- .../Homebrew/test/checksum_verification_spec.rb | 8 ++++++-- Library/Homebrew/test/compiler_failure_spec.rb | 4 +++- Library/Homebrew/test/formula_spec.rb | 6 +++++- Library/Homebrew/test/formula_validation_spec.rb | 6 +++++- Library/Homebrew/test/pathname_spec.rb | 4 +++- .../fixtures/cask/Casks/with-postflight-multi.rb | 2 ++ .../fixtures/cask/Casks/with-postflight.rb | 1 + .../fixtures/cask/Casks/with-preflight-multi.rb | 2 ++ .../fixtures/cask/Casks/with-preflight.rb | 1 + .../Casks/with-uninstall-postflight-multi.rb | 2 ++ .../cask/Casks/with-uninstall-postflight.rb | 1 + .../cask/Casks/with-uninstall-preflight-multi.rb | 2 ++ .../cask/Casks/with-uninstall-preflight.rb | 1 + 16 files changed, 49 insertions(+), 22 deletions(-) diff --git a/Library/Homebrew/.rubocop_todo.yml b/Library/Homebrew/.rubocop_todo.yml index bcb1247506..202c187f07 100644 --- a/Library/Homebrew/.rubocop_todo.yml +++ b/Library/Homebrew/.rubocop_todo.yml @@ -22,14 +22,3 @@ Style/Documentation: - "utils/popen.rb" - "utils/shell.rb" - "version.rb" - -Lint/EmptyBlock: - Exclude: - - "dev-cmd/extract.rb" - - "test/cache_store_spec.rb" - - "test/checksum_verification_spec.rb" - - "test/compiler_failure_spec.rb" - - "test/formula_spec.rb" - - "test/formula_validation_spec.rb" - - "test/pathname_spec.rb" - - "test/support/fixtures/cask/Casks/*flight*.rb" diff --git a/Library/Homebrew/dev-cmd/extract.rb b/Library/Homebrew/dev-cmd/extract.rb index 91ade54b16..6207ac7702 100644 --- a/Library/Homebrew/dev-cmd/extract.rb +++ b/Library/Homebrew/dev-cmd/extract.rb @@ -10,22 +10,30 @@ require "tap" def with_monkey_patch BottleSpecification.class_eval do alias_method :old_method_missing, :method_missing if method_defined?(:method_missing) - define_method(:method_missing) { |*| } + define_method(:method_missing) do |*| + # do nothing + end end Module.class_eval do alias_method :old_method_missing, :method_missing if method_defined?(:method_missing) - define_method(:method_missing) { |*| } + define_method(:method_missing) do |*| + # do nothing + end end Resource.class_eval do alias_method :old_method_missing, :method_missing if method_defined?(:method_missing) - define_method(:method_missing) { |*| } + define_method(:method_missing) do |*| + # do nothing + end end DependencyCollector.class_eval do alias_method :old_parse_symbol_spec, :parse_symbol_spec if method_defined?(:parse_symbol_spec) - define_method(:parse_symbol_spec) { |*| } + define_method(:parse_symbol_spec) do |*| + # do nothing + end end yield diff --git a/Library/Homebrew/test/cache_store_spec.rb b/Library/Homebrew/test/cache_store_spec.rb index 91df263a74..3506b7922b 100644 --- a/Library/Homebrew/test/cache_store_spec.rb +++ b/Library/Homebrew/test/cache_store_spec.rb @@ -13,7 +13,9 @@ describe CacheStoreDatabase do cache_store = instance_double(described_class, "cache_store", write_if_dirty!: nil) expect(described_class).to receive(:new).with(type).and_return(cache_store) expect(cache_store).to receive(:write_if_dirty!) - described_class.use(type) { |_db| } + described_class.use(type) { |_db| + # do nothing + } end end diff --git a/Library/Homebrew/test/checksum_verification_spec.rb b/Library/Homebrew/test/checksum_verification_spec.rb index b1a7a7f624..a2028e2603 100644 --- a/Library/Homebrew/test/checksum_verification_spec.rb +++ b/Library/Homebrew/test/checksum_verification_spec.rb @@ -18,7 +18,9 @@ describe Formula do sha256 TESTBALL_SHA256 end - f.brew {} + f.brew { + # do nothing + } }.not_to raise_error end @@ -28,7 +30,9 @@ describe Formula do sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8" end - f.brew {} + f.brew { + # do nothing + } }.to raise_error(ChecksumMismatchError) end end diff --git a/Library/Homebrew/test/compiler_failure_spec.rb b/Library/Homebrew/test/compiler_failure_spec.rb index f24c6f3536..2144837a7d 100644 --- a/Library/Homebrew/test/compiler_failure_spec.rb +++ b/Library/Homebrew/test/compiler_failure_spec.rb @@ -22,7 +22,9 @@ describe CompilerFailure do end it "can be given an empty block" do - failure = described_class.create(:clang) {} + failure = described_class.create(:clang) { + # do nothing + } expect(failure).to fail_with( instance_double(CompilerSelector::Compiler, "Compiler", type: :clang, name: :clang, version: 600), ) diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index 723efa62b9..59b344e37b 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -872,7 +872,11 @@ describe Formula do end expect(Set.new(f2.recursive_requirements)).to eq(Set[]) - expect(Set.new(f2.recursive_requirements {})).to eq(Set[xcode]) + expect( + f2.recursive_requirements { + # do nothing + }.to_set, + ).to eq(Set[xcode]) requirements = f2.recursive_requirements do |_dependent, requirement| Requirement.prune if requirement.is_a?(XcodeRequirement) diff --git a/Library/Homebrew/test/formula_validation_spec.rb b/Library/Homebrew/test/formula_validation_spec.rb index 30077967f0..8f4b052e2f 100644 --- a/Library/Homebrew/test/formula_validation_spec.rb +++ b/Library/Homebrew/test/formula_validation_spec.rb @@ -80,7 +80,11 @@ describe Formula do end it "fails when Formula is empty" do - expect { formula {} }.to raise_error(FormulaSpecificationError) + expect { + formula { + # do nothing + } + }.to raise_error(FormulaSpecificationError) end end end diff --git a/Library/Homebrew/test/pathname_spec.rb b/Library/Homebrew/test/pathname_spec.rb index 0611260c7f..98a20f3629 100644 --- a/Library/Homebrew/test/pathname_spec.rb +++ b/Library/Homebrew/test/pathname_spec.rb @@ -93,7 +93,9 @@ describe Pathname do end it "preserves permissions" do - File.open(file, "w", 0100777) {} + File.open(file, "w", 0100777) { + # do nothing + } file.atomic_write("CONTENT") expect(file.stat.mode.to_s(8)).to eq((~File.umask & 0100777).to_s(8)) end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight-multi.rb index f0b82d4716..7fb1bec476 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight-multi.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight-multi.rb @@ -8,7 +8,9 @@ cask "with-postflight-multi" do pkg "MyFancyPkg/Fancy.pkg" postflight do + # do nothing end postflight do + # do nothing end end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight.rb index b14223ccbd..a4b3bf701c 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight.rb @@ -8,5 +8,6 @@ cask "with-postflight" do pkg "MyFancyPkg/Fancy.pkg" postflight do + # do nothing end end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight-multi.rb index c62bfdcebc..3732c141ba 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight-multi.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight-multi.rb @@ -8,7 +8,9 @@ cask "with-preflight-multi" do pkg "MyFancyPkg/Fancy.pkg" preflight do + # do nothing end preflight do + # do nothing end end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight.rb index 29bc0b0c16..1da7ed88e6 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight.rb @@ -8,5 +8,6 @@ cask "with-preflight" do pkg "MyFancyPkg/Fancy.pkg" preflight do + # do nothing end end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight-multi.rb index 52e5e6420b..4da9516966 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight-multi.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight-multi.rb @@ -8,7 +8,9 @@ cask "with-uninstall-postflight-multi" do pkg "MyFancyPkg/Fancy.pkg" uninstall_postflight do + # do nothing end uninstall_postflight do + # do nothing end end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight.rb index c400a7edd1..b07760d099 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight.rb @@ -8,5 +8,6 @@ cask "with-uninstall-postflight" do pkg "MyFancyPkg/Fancy.pkg" uninstall_postflight do + # do nothing end end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight-multi.rb index d743984fde..7bf6bbf9fa 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight-multi.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight-multi.rb @@ -8,7 +8,9 @@ cask "with-uninstall-preflight-multi" do pkg "MyFancyPkg/Fancy.pkg" uninstall_preflight do + # do nothing end uninstall_preflight do + # do nothing end end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight.rb index b4d73a0e6c..2af130cca8 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight.rb @@ -8,5 +8,6 @@ cask "with-uninstall-preflight" do pkg "MyFancyPkg/Fancy.pkg" uninstall_preflight do + # do nothing end end From 9578fc66650c74ac5584ed313cf20848d77d7038 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Thu, 26 Jan 2023 21:53:50 -0800 Subject: [PATCH 2/5] Remove completed todos --- Library/Homebrew/.rubocop_todo.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Library/Homebrew/.rubocop_todo.yml b/Library/Homebrew/.rubocop_todo.yml index 202c187f07..7f1af4c62c 100644 --- a/Library/Homebrew/.rubocop_todo.yml +++ b/Library/Homebrew/.rubocop_todo.yml @@ -1,6 +1,5 @@ Style/Documentation: Exclude: - - "compat/**/*.rb" - "extend/**/*.rb" - "cmd/**/*.rb" - "dev-cmd/**/*.rb" @@ -8,17 +7,14 @@ Style/Documentation: - "cask/macos.rb" - "cli/args.rb" - "cli/parser.rb" - - "default_prefix.rb" - "global.rb" - "keg_relocate.rb" - "os/mac/keg.rb" - "reinstall.rb" - "software_spec.rb" - - "upgrade.rb" - "utils.rb" - "utils/fork.rb" - "utils/gems.rb" - "utils/git_repository.rb" - "utils/popen.rb" - "utils/shell.rb" - - "version.rb" From 863c1b505b02f2c981d8631593db86553db7ec56 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Thu, 26 Jan 2023 22:02:35 -0800 Subject: [PATCH 3/5] Allow Homebrew nodoc --- Library/Homebrew/.rubocop_todo.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/.rubocop_todo.yml b/Library/Homebrew/.rubocop_todo.yml index 7f1af4c62c..0a8636976f 100644 --- a/Library/Homebrew/.rubocop_todo.yml +++ b/Library/Homebrew/.rubocop_todo.yml @@ -1,20 +1,21 @@ Style/Documentation: + AllowedConstants: + - Homebrew Exclude: - "extend/**/*.rb" - - "cmd/**/*.rb" - - "dev-cmd/**/*.rb" - "test/**/*.rb" - "cask/macos.rb" - "cli/args.rb" - "cli/parser.rb" - - "global.rb" + - "cmd/list.rb" + - "cmd/update-report.rb" + - "dev-cmd/irb.rb" + - "dev-cmd/pr-pull.rb" - "keg_relocate.rb" - "os/mac/keg.rb" - - "reinstall.rb" - "software_spec.rb" - "utils.rb" - "utils/fork.rb" - - "utils/gems.rb" - "utils/git_repository.rb" - "utils/popen.rb" - "utils/shell.rb" From a836793e62002af7bc036cb93bdb634ea01ccd8d Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Thu, 26 Jan 2023 22:04:39 -0800 Subject: [PATCH 4/5] Move Style/Documentation config --- Library/Homebrew/.rubocop.yml | 23 ++++++++++++++++++++++- Library/Homebrew/.rubocop_todo.yml | 21 --------------------- 2 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 Library/Homebrew/.rubocop_todo.yml diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index 5897f0a641..8cb6dfe991 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -1,6 +1,5 @@ inherit_from: - ../.rubocop_rspec.yml - - .rubocop_todo.yml Homebrew/MoveToExtendOS: Enabled: true @@ -57,6 +56,28 @@ Naming/PredicateName: - is_32_bit? - is_64_bit? +Style/Documentation: + AllowedConstants: + - Homebrew + Exclude: + - "extend/**/*.rb" + - "test/**/*.rb" + - "cask/macos.rb" + - "cli/args.rb" + - "cli/parser.rb" + - "cmd/list.rb" + - "cmd/update-report.rb" + - "dev-cmd/irb.rb" + - "dev-cmd/pr-pull.rb" + - "keg_relocate.rb" + - "os/mac/keg.rb" + - "software_spec.rb" + - "utils.rb" + - "utils/fork.rb" + - "utils/git_repository.rb" + - "utils/popen.rb" + - "utils/shell.rb" + Style/HashAsLastArrayItem: Exclude: - "test/utils/spdx_spec.rb" diff --git a/Library/Homebrew/.rubocop_todo.yml b/Library/Homebrew/.rubocop_todo.yml deleted file mode 100644 index 0a8636976f..0000000000 --- a/Library/Homebrew/.rubocop_todo.yml +++ /dev/null @@ -1,21 +0,0 @@ -Style/Documentation: - AllowedConstants: - - Homebrew - Exclude: - - "extend/**/*.rb" - - "test/**/*.rb" - - "cask/macos.rb" - - "cli/args.rb" - - "cli/parser.rb" - - "cmd/list.rb" - - "cmd/update-report.rb" - - "dev-cmd/irb.rb" - - "dev-cmd/pr-pull.rb" - - "keg_relocate.rb" - - "os/mac/keg.rb" - - "software_spec.rb" - - "utils.rb" - - "utils/fork.rb" - - "utils/git_repository.rb" - - "utils/popen.rb" - - "utils/shell.rb" From 97a7d26255c812aa2cffec87c9bd14a3cbba992b Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Thu, 26 Jan 2023 22:08:40 -0800 Subject: [PATCH 5/5] Clamp metrics --- Library/Homebrew/.rubocop.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index 8cb6dfe991..93171a34df 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -19,9 +19,9 @@ Lint/NestedMethodDefinition: # TODO: Try to bring down all metrics maximums. Metrics/AbcSize: - Max: 280 + Max: 241 Metrics/BlockLength: - Max: 106 + Max: 86 Exclude: # TODO: extract more of the bottling logic - "dev-cmd/bottle.rb" @@ -30,18 +30,18 @@ Metrics/BlockLength: Metrics/BlockNesting: Max: 5 Metrics/ClassLength: - Max: 800 + Max: 736 Exclude: - "formula.rb" - "formula_installer.rb" Metrics/CyclomaticComplexity: - Max: 80 + Max: 68 Metrics/PerceivedComplexity: - Max: 90 + Max: 84 Metrics/MethodLength: - Max: 260 + Max: 232 Metrics/ModuleLength: - Max: 500 + Max: 463 Exclude: # TODO: extract more of the bottling logic - "dev-cmd/bottle.rb"