diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 4ef9d38704..351a9f71b7 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -110,7 +110,10 @@ Style/GuardClause: Style/HashSyntax: EnforcedStyle: hash_rockets Exclude: - - '**/cmd/*.rb' + - '**/Guardfile' + - '**/cmd/**/*.rb' + - '**/lib/**/*.rb' + - '**/spec/**/*.rb' # ruby style guide favorite Style/StringLiterals: diff --git a/Library/.rubocop_rspec.yml b/Library/.rubocop_rspec.yml new file mode 100644 index 0000000000..28ff7872e2 --- /dev/null +++ b/Library/.rubocop_rspec.yml @@ -0,0 +1,22 @@ +inherit_from: ./.rubocop.yml + +NewFormulaAudit: + Enabled: true + +# TODO: try to enable these +RSpec/AnyInstance: + Enabled: false +RSpec/ContextWording: + Enabled: false +RSpec/DescribeClass: + Enabled: false +RSpec/ExampleLength: + Enabled: false +RSpec/MessageSpies: + Enabled: false + +# TODO: try to reduce these +RSpec/MultipleExpectations: + Max: 26 +RSpec/NestedGroups: + Max: 5 diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index b2350c3b94..ebfcf6ca3b 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -1,4 +1,4 @@ -inherit_from: ../.rubocop.yml +inherit_from: ../.rubocop_rspec.yml AllCops: Include: diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index 8e6e7378c5..ca47f72043 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -60,8 +60,13 @@ module Homebrew File.expand_path(file).start_with? HOMEBREW_LIBRARY_PATH end - unless files.nil? || has_non_formula - args << "--config" << HOMEBREW_LIBRARY/".rubocop_audit.yml" + if files && !has_non_formula + config = if (files.first/"spec").exist? + HOMEBREW_LIBRARY/".rubocop_rspec.yml" + else + HOMEBREW_LIBRARY/".rubocop_audit.yml" + end + args << "--config" << config end if files.nil? diff --git a/Library/Homebrew/test/.rubocop_todo.yml b/Library/Homebrew/test/.rubocop_todo.yml index 6b7dcd94a9..ada16c8734 100644 --- a/Library/Homebrew/test/.rubocop_todo.yml +++ b/Library/Homebrew/test/.rubocop_todo.yml @@ -1,41 +1,16 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-10-08 06:47:14 +0200 using RuboCop version 0.59.2. +# on 2019-01-21 13:27:20 +0000 using RuboCop version 0.63.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 28 -RSpec/AnyInstance: +# Offense count: 1 +# Cop supports --auto-correct. +Lint/UnneededCopEnableDirective: Exclude: - - 'cask/artifact/uninstall_zap_shared_examples.rb' - - 'cask/cmd/create_spec.rb' - - 'cask/cmd/edit_spec.rb' - - 'cask/cmd/outdated_spec.rb' - - 'cask/cmd/upgrade_spec.rb' - - 'caveats_spec.rb' - - 'cleanup_spec.rb' - - 'download_strategies_spec.rb' - - 'formatter_spec.rb' - - 'os/linux/dependency_collector_spec.rb' - - 'utils/analytics_spec.rb' - - 'utils/git_spec.rb' - -# Offense count: 146 -# Configuration parameters: Prefixes. -# Prefixes: when, with, without -RSpec/ContextWording: - Enabled: false - -# Offense count: 69 -RSpec/DescribeClass: - Enabled: false - -# Offense count: 581 -# Configuration parameters: Max. -RSpec/ExampleLength: - Enabled: false + - 'cask/artifact/shared_examples/uninstall_zap.rb' # Offense count: 16 RSpec/ExpectActual: @@ -43,32 +18,21 @@ RSpec/ExpectActual: - 'spec/routing/**/*' - 'missing_formula_spec.rb' -# Offense count: 21 +# Offense count: 20 RSpec/ExpectInHook: Exclude: - 'cache_store_spec.rb' - 'cask/audit_spec.rb' - 'cmd/reinstall_spec.rb' - - 'download_strategies_spec.rb' - 'linkage_cache_store_spec.rb' - 'migrator_spec.rb' - 'os/mac/java_requirement_spec.rb' -# Offense count: 31 +# Offense count: 37 # Configuration parameters: CustomTransform, IgnoreMethods. RSpec/FilePath: Enabled: false -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: implicit, each, example -RSpec/HookArgument: - Exclude: - - 'cask/artifact/uninstall_zap_shared_examples.rb' - - 'spec_helper.rb' - - 'support/helper/cask/fake_system_command.rb' - # Offense count: 6 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: @@ -78,18 +42,6 @@ RSpec/InstanceVariable: - 'utils/git_spec.rb' - 'version_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. -RSpec/LeadingSubject: - Exclude: - - 'cask/artifact/uninstall_zap_shared_examples.rb' - -# Offense count: 122 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: have_received, receive -RSpec/MessageSpies: - Enabled: false - # Offense count: 1 RSpec/MissingExampleGroupArgument: Exclude: @@ -99,27 +51,19 @@ RSpec/MissingExampleGroupArgument: RSpec/MultipleDescribes: Enabled: false -# Offense count: 548 -# Configuration parameters: AggregateFailuresByDefault. -RSpec/MultipleExpectations: - Max: 26 - -# Offense count: 946 +# Offense count: 825 +# Configuration parameters: IgnoreSharedExamples. RSpec/NamedSubject: Enabled: false -# Offense count: 99 -RSpec/NestedGroups: - Max: 5 - -# Offense count: 11 +# Offense count: 7 RSpec/RepeatedDescription: Exclude: - 'inreplace_spec.rb' - 'migrator_spec.rb' - 'tab_spec.rb' -# Offense count: 31 +# Offense count: 25 RSpec/SubjectStub: Exclude: - 'cache_store_spec.rb' @@ -130,7 +74,7 @@ RSpec/SubjectStub: - 'language/python_spec.rb' - 'os/mac/java_requirement_spec.rb' -# Offense count: 65 -# Configuration parameters: IgnoreSymbolicNames. +# Offense count: 67 +# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Enabled: false diff --git a/Library/Homebrew/test/cask/artifact/shared_examples/uninstall_zap.rb b/Library/Homebrew/test/cask/artifact/shared_examples/uninstall_zap.rb index 6a6a54a9eb..dd034e041e 100644 --- a/Library/Homebrew/test/cask/artifact/shared_examples/uninstall_zap.rb +++ b/Library/Homebrew/test/cask/artifact/shared_examples/uninstall_zap.rb @@ -197,7 +197,6 @@ shared_examples "#uninstall_phase or #zap_phase" do end before do - # rubocop:disable RSpec/AnyInstance allow_any_instance_of(Cask::Artifact::AbstractUninstall).to receive(:trash_paths) .and_wrap_original do |method, *args| method.call(*args).tap do |result| diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 79365e1997..67e6f6cb87 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -137,7 +137,7 @@ RSpec.configure do |config| skip "unzip not installed." unless which("unzip") end - config.around(:each) do |example| + config.around do |example| def find_files Find.find(TEST_TMPDIR) .reject { |f| File.basename(f) == ".DS_Store" } diff --git a/Library/Homebrew/test/support/helper/cask/fake_system_command.rb b/Library/Homebrew/test/support/helper/cask/fake_system_command.rb index 457b64de61..dafb8a6473 100644 --- a/Library/Homebrew/test/support/helper/cask/fake_system_command.rb +++ b/Library/Homebrew/test/support/helper/cask/fake_system_command.rb @@ -63,7 +63,7 @@ class FakeSystemCommand end RSpec.configure do |config| - config.after(:each) do + config.after do begin FakeSystemCommand.verify_expectations! ensure