Merge pull request #14444 from dduugg/resolve-rubocop-todo

Resolve rubocop todo
This commit is contained in:
Mike McQuaid 2023-01-27 10:17:50 +00:00 committed by GitHub
commit 10845a1122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 78 additions and 54 deletions

View File

@ -1,6 +1,5 @@
inherit_from: inherit_from:
- ../.rubocop_rspec.yml - ../.rubocop_rspec.yml
- .rubocop_todo.yml
Homebrew/MoveToExtendOS: Homebrew/MoveToExtendOS:
Enabled: true Enabled: true
@ -20,9 +19,9 @@ Lint/NestedMethodDefinition:
# TODO: Try to bring down all metrics maximums. # TODO: Try to bring down all metrics maximums.
Metrics/AbcSize: Metrics/AbcSize:
Max: 280 Max: 241
Metrics/BlockLength: Metrics/BlockLength:
Max: 106 Max: 86
Exclude: Exclude:
# TODO: extract more of the bottling logic # TODO: extract more of the bottling logic
- "dev-cmd/bottle.rb" - "dev-cmd/bottle.rb"
@ -31,18 +30,18 @@ Metrics/BlockLength:
Metrics/BlockNesting: Metrics/BlockNesting:
Max: 5 Max: 5
Metrics/ClassLength: Metrics/ClassLength:
Max: 800 Max: 736
Exclude: Exclude:
- "formula.rb" - "formula.rb"
- "formula_installer.rb" - "formula_installer.rb"
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Max: 80 Max: 68
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Max: 90 Max: 84
Metrics/MethodLength: Metrics/MethodLength:
Max: 260 Max: 232
Metrics/ModuleLength: Metrics/ModuleLength:
Max: 500 Max: 463
Exclude: Exclude:
# TODO: extract more of the bottling logic # TODO: extract more of the bottling logic
- "dev-cmd/bottle.rb" - "dev-cmd/bottle.rb"
@ -57,6 +56,28 @@ Naming/PredicateName:
- is_32_bit? - is_32_bit?
- is_64_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: Style/HashAsLastArrayItem:
Exclude: Exclude:
- "test/utils/spdx_spec.rb" - "test/utils/spdx_spec.rb"

View File

@ -1,35 +0,0 @@
Style/Documentation:
Exclude:
- "compat/**/*.rb"
- "extend/**/*.rb"
- "cmd/**/*.rb"
- "dev-cmd/**/*.rb"
- "test/**/*.rb"
- "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"
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"

View File

@ -10,22 +10,30 @@ require "tap"
def with_monkey_patch def with_monkey_patch
BottleSpecification.class_eval do BottleSpecification.class_eval do
alias_method :old_method_missing, :method_missing if method_defined?(:method_missing) 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 end
Module.class_eval do Module.class_eval do
alias_method :old_method_missing, :method_missing if method_defined?(:method_missing) 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 end
Resource.class_eval do Resource.class_eval do
alias_method :old_method_missing, :method_missing if method_defined?(:method_missing) 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 end
DependencyCollector.class_eval do DependencyCollector.class_eval do
alias_method :old_parse_symbol_spec, :parse_symbol_spec if method_defined?(:parse_symbol_spec) 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 end
yield yield

View File

@ -13,7 +13,9 @@ describe CacheStoreDatabase do
cache_store = instance_double(described_class, "cache_store", write_if_dirty!: nil) 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(described_class).to receive(:new).with(type).and_return(cache_store)
expect(cache_store).to receive(:write_if_dirty!) expect(cache_store).to receive(:write_if_dirty!)
described_class.use(type) { |_db| } described_class.use(type) { |_db|
# do nothing
}
end end
end end

View File

@ -18,7 +18,9 @@ describe Formula do
sha256 TESTBALL_SHA256 sha256 TESTBALL_SHA256
end end
f.brew {} f.brew {
# do nothing
}
}.not_to raise_error }.not_to raise_error
end end
@ -28,7 +30,9 @@ describe Formula do
sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8" sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8"
end end
f.brew {} f.brew {
# do nothing
}
}.to raise_error(ChecksumMismatchError) }.to raise_error(ChecksumMismatchError)
end end
end end

View File

@ -22,7 +22,9 @@ describe CompilerFailure do
end end
it "can be given an empty block" do 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( expect(failure).to fail_with(
instance_double(CompilerSelector::Compiler, "Compiler", type: :clang, name: :clang, version: 600), instance_double(CompilerSelector::Compiler, "Compiler", type: :clang, name: :clang, version: 600),
) )

View File

@ -872,7 +872,11 @@ describe Formula do
end end
expect(Set.new(f2.recursive_requirements)).to eq(Set[]) 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| requirements = f2.recursive_requirements do |_dependent, requirement|
Requirement.prune if requirement.is_a?(XcodeRequirement) Requirement.prune if requirement.is_a?(XcodeRequirement)

View File

@ -80,7 +80,11 @@ describe Formula do
end end
it "fails when Formula is empty" do it "fails when Formula is empty" do
expect { formula {} }.to raise_error(FormulaSpecificationError) expect {
formula {
# do nothing
}
}.to raise_error(FormulaSpecificationError)
end end
end end
end end

View File

@ -93,7 +93,9 @@ describe Pathname do
end end
it "preserves permissions" do it "preserves permissions" do
File.open(file, "w", 0100777) {} File.open(file, "w", 0100777) {
# do nothing
}
file.atomic_write("CONTENT") file.atomic_write("CONTENT")
expect(file.stat.mode.to_s(8)).to eq((~File.umask & 0100777).to_s(8)) expect(file.stat.mode.to_s(8)).to eq((~File.umask & 0100777).to_s(8))
end end

View File

@ -8,7 +8,9 @@ cask "with-postflight-multi" do
pkg "MyFancyPkg/Fancy.pkg" pkg "MyFancyPkg/Fancy.pkg"
postflight do postflight do
# do nothing
end end
postflight do postflight do
# do nothing
end end
end end

View File

@ -8,5 +8,6 @@ cask "with-postflight" do
pkg "MyFancyPkg/Fancy.pkg" pkg "MyFancyPkg/Fancy.pkg"
postflight do postflight do
# do nothing
end end
end end

View File

@ -8,7 +8,9 @@ cask "with-preflight-multi" do
pkg "MyFancyPkg/Fancy.pkg" pkg "MyFancyPkg/Fancy.pkg"
preflight do preflight do
# do nothing
end end
preflight do preflight do
# do nothing
end end
end end

View File

@ -8,5 +8,6 @@ cask "with-preflight" do
pkg "MyFancyPkg/Fancy.pkg" pkg "MyFancyPkg/Fancy.pkg"
preflight do preflight do
# do nothing
end end
end end

View File

@ -8,7 +8,9 @@ cask "with-uninstall-postflight-multi" do
pkg "MyFancyPkg/Fancy.pkg" pkg "MyFancyPkg/Fancy.pkg"
uninstall_postflight do uninstall_postflight do
# do nothing
end end
uninstall_postflight do uninstall_postflight do
# do nothing
end end
end end

View File

@ -8,5 +8,6 @@ cask "with-uninstall-postflight" do
pkg "MyFancyPkg/Fancy.pkg" pkg "MyFancyPkg/Fancy.pkg"
uninstall_postflight do uninstall_postflight do
# do nothing
end end
end end

View File

@ -8,7 +8,9 @@ cask "with-uninstall-preflight-multi" do
pkg "MyFancyPkg/Fancy.pkg" pkg "MyFancyPkg/Fancy.pkg"
uninstall_preflight do uninstall_preflight do
# do nothing
end end
uninstall_preflight do uninstall_preflight do
# do nothing
end end
end end

View File

@ -8,5 +8,6 @@ cask "with-uninstall-preflight" do
pkg "MyFancyPkg/Fancy.pkg" pkg "MyFancyPkg/Fancy.pkg"
uninstall_preflight do uninstall_preflight do
# do nothing
end end
end end