Update RuboCop RSpec rules
Create a new, seperate RuboCop file that uses our RSpec rule configuration if a specified tap has a `spec` directory. Also, while we're here, fix up the various rules so that we don't have any outdated TODOs, disable some rules for good and fix `brew style` for Homebrew/bundle.
This commit is contained in:
		
							parent
							
								
									902e058f3e
								
							
						
					
					
						commit
						5c7fbaf259
					
				@ -110,7 +110,10 @@ Style/GuardClause:
 | 
				
			|||||||
Style/HashSyntax:
 | 
					Style/HashSyntax:
 | 
				
			||||||
  EnforcedStyle: hash_rockets
 | 
					  EnforcedStyle: hash_rockets
 | 
				
			||||||
  Exclude:
 | 
					  Exclude:
 | 
				
			||||||
  - '**/cmd/*.rb'
 | 
					  - '**/Guardfile'
 | 
				
			||||||
 | 
					  - '**/cmd/**/*.rb'
 | 
				
			||||||
 | 
					  - '**/lib/**/*.rb'
 | 
				
			||||||
 | 
					  - '**/spec/**/*.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ruby style guide favorite
 | 
					# ruby style guide favorite
 | 
				
			||||||
Style/StringLiterals:
 | 
					Style/StringLiterals:
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										22
									
								
								Library/.rubocop_rspec.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Library/.rubocop_rspec.yml
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
				
			||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
inherit_from: ../.rubocop.yml
 | 
					inherit_from: ../.rubocop_rspec.yml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AllCops:
 | 
					AllCops:
 | 
				
			||||||
  Include:
 | 
					  Include:
 | 
				
			||||||
 | 
				
			|||||||
@ -60,8 +60,13 @@ module Homebrew
 | 
				
			|||||||
        File.expand_path(file).start_with? HOMEBREW_LIBRARY_PATH
 | 
					        File.expand_path(file).start_with? HOMEBREW_LIBRARY_PATH
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      unless files.nil? || has_non_formula
 | 
					      if files && !has_non_formula
 | 
				
			||||||
        args << "--config" << HOMEBREW_LIBRARY/".rubocop_audit.yml"
 | 
					        config = if (files.first/"spec").exist?
 | 
				
			||||||
 | 
					          HOMEBREW_LIBRARY/".rubocop_rspec.yml"
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          HOMEBREW_LIBRARY/".rubocop_audit.yml"
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        args << "--config" << config
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if files.nil?
 | 
					      if files.nil?
 | 
				
			||||||
 | 
				
			|||||||
@ -1,41 +1,16 @@
 | 
				
			|||||||
# This configuration was generated by
 | 
					# This configuration was generated by
 | 
				
			||||||
# `rubocop --auto-gen-config`
 | 
					# `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
 | 
					# The point is for the user to remove these configuration records
 | 
				
			||||||
# one by one as the offenses are removed from the code base.
 | 
					# one by one as the offenses are removed from the code base.
 | 
				
			||||||
# Note that changes in the inspected code, or installation of new
 | 
					# Note that changes in the inspected code, or installation of new
 | 
				
			||||||
# versions of RuboCop, may require this file to be generated again.
 | 
					# versions of RuboCop, may require this file to be generated again.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Offense count: 28
 | 
					# Offense count: 1
 | 
				
			||||||
RSpec/AnyInstance:
 | 
					# Cop supports --auto-correct.
 | 
				
			||||||
 | 
					Lint/UnneededCopEnableDirective:
 | 
				
			||||||
  Exclude:
 | 
					  Exclude:
 | 
				
			||||||
    - 'cask/artifact/uninstall_zap_shared_examples.rb'
 | 
					    - 'cask/artifact/shared_examples/uninstall_zap.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
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Offense count: 16
 | 
					# Offense count: 16
 | 
				
			||||||
RSpec/ExpectActual:
 | 
					RSpec/ExpectActual:
 | 
				
			||||||
@ -43,32 +18,21 @@ RSpec/ExpectActual:
 | 
				
			|||||||
    - 'spec/routing/**/*'
 | 
					    - 'spec/routing/**/*'
 | 
				
			||||||
    - 'missing_formula_spec.rb'
 | 
					    - 'missing_formula_spec.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Offense count: 21
 | 
					# Offense count: 20
 | 
				
			||||||
RSpec/ExpectInHook:
 | 
					RSpec/ExpectInHook:
 | 
				
			||||||
  Exclude:
 | 
					  Exclude:
 | 
				
			||||||
    - 'cache_store_spec.rb'
 | 
					    - 'cache_store_spec.rb'
 | 
				
			||||||
    - 'cask/audit_spec.rb'
 | 
					    - 'cask/audit_spec.rb'
 | 
				
			||||||
    - 'cmd/reinstall_spec.rb'
 | 
					    - 'cmd/reinstall_spec.rb'
 | 
				
			||||||
    - 'download_strategies_spec.rb'
 | 
					 | 
				
			||||||
    - 'linkage_cache_store_spec.rb'
 | 
					    - 'linkage_cache_store_spec.rb'
 | 
				
			||||||
    - 'migrator_spec.rb'
 | 
					    - 'migrator_spec.rb'
 | 
				
			||||||
    - 'os/mac/java_requirement_spec.rb'
 | 
					    - 'os/mac/java_requirement_spec.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Offense count: 31
 | 
					# Offense count: 37
 | 
				
			||||||
# Configuration parameters: CustomTransform, IgnoreMethods.
 | 
					# Configuration parameters: CustomTransform, IgnoreMethods.
 | 
				
			||||||
RSpec/FilePath:
 | 
					RSpec/FilePath:
 | 
				
			||||||
  Enabled: false
 | 
					  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
 | 
					# Offense count: 6
 | 
				
			||||||
# Configuration parameters: AssignmentOnly.
 | 
					# Configuration parameters: AssignmentOnly.
 | 
				
			||||||
RSpec/InstanceVariable:
 | 
					RSpec/InstanceVariable:
 | 
				
			||||||
@ -78,18 +42,6 @@ RSpec/InstanceVariable:
 | 
				
			|||||||
    - 'utils/git_spec.rb'
 | 
					    - 'utils/git_spec.rb'
 | 
				
			||||||
    - 'version_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
 | 
					# Offense count: 1
 | 
				
			||||||
RSpec/MissingExampleGroupArgument:
 | 
					RSpec/MissingExampleGroupArgument:
 | 
				
			||||||
  Exclude:
 | 
					  Exclude:
 | 
				
			||||||
@ -99,27 +51,19 @@ RSpec/MissingExampleGroupArgument:
 | 
				
			|||||||
RSpec/MultipleDescribes:
 | 
					RSpec/MultipleDescribes:
 | 
				
			||||||
  Enabled: false
 | 
					  Enabled: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Offense count: 548
 | 
					# Offense count: 825
 | 
				
			||||||
# Configuration parameters: AggregateFailuresByDefault.
 | 
					# Configuration parameters: IgnoreSharedExamples.
 | 
				
			||||||
RSpec/MultipleExpectations:
 | 
					 | 
				
			||||||
  Max: 26
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Offense count: 946
 | 
					 | 
				
			||||||
RSpec/NamedSubject:
 | 
					RSpec/NamedSubject:
 | 
				
			||||||
  Enabled: false
 | 
					  Enabled: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Offense count: 99
 | 
					# Offense count: 7
 | 
				
			||||||
RSpec/NestedGroups:
 | 
					 | 
				
			||||||
  Max: 5
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Offense count: 11
 | 
					 | 
				
			||||||
RSpec/RepeatedDescription:
 | 
					RSpec/RepeatedDescription:
 | 
				
			||||||
  Exclude:
 | 
					  Exclude:
 | 
				
			||||||
    - 'inreplace_spec.rb'
 | 
					    - 'inreplace_spec.rb'
 | 
				
			||||||
    - 'migrator_spec.rb'
 | 
					    - 'migrator_spec.rb'
 | 
				
			||||||
    - 'tab_spec.rb'
 | 
					    - 'tab_spec.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Offense count: 31
 | 
					# Offense count: 25
 | 
				
			||||||
RSpec/SubjectStub:
 | 
					RSpec/SubjectStub:
 | 
				
			||||||
  Exclude:
 | 
					  Exclude:
 | 
				
			||||||
    - 'cache_store_spec.rb'
 | 
					    - 'cache_store_spec.rb'
 | 
				
			||||||
@ -130,7 +74,7 @@ RSpec/SubjectStub:
 | 
				
			|||||||
    - 'language/python_spec.rb'
 | 
					    - 'language/python_spec.rb'
 | 
				
			||||||
    - 'os/mac/java_requirement_spec.rb'
 | 
					    - 'os/mac/java_requirement_spec.rb'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Offense count: 65
 | 
					# Offense count: 67
 | 
				
			||||||
# Configuration parameters: IgnoreSymbolicNames.
 | 
					# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
 | 
				
			||||||
RSpec/VerifiedDoubles:
 | 
					RSpec/VerifiedDoubles:
 | 
				
			||||||
  Enabled: false
 | 
					  Enabled: false
 | 
				
			||||||
 | 
				
			|||||||
@ -197,7 +197,6 @@ shared_examples "#uninstall_phase or #zap_phase" do
 | 
				
			|||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      before do
 | 
					      before do
 | 
				
			||||||
        # rubocop:disable RSpec/AnyInstance
 | 
					 | 
				
			||||||
        allow_any_instance_of(Cask::Artifact::AbstractUninstall).to receive(:trash_paths)
 | 
					        allow_any_instance_of(Cask::Artifact::AbstractUninstall).to receive(:trash_paths)
 | 
				
			||||||
          .and_wrap_original do |method, *args|
 | 
					          .and_wrap_original do |method, *args|
 | 
				
			||||||
            method.call(*args).tap do |result|
 | 
					            method.call(*args).tap do |result|
 | 
				
			||||||
 | 
				
			|||||||
@ -137,7 +137,7 @@ RSpec.configure do |config|
 | 
				
			|||||||
    skip "unzip not installed." unless which("unzip")
 | 
					    skip "unzip not installed." unless which("unzip")
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  config.around(:each) do |example|
 | 
					  config.around do |example|
 | 
				
			||||||
    def find_files
 | 
					    def find_files
 | 
				
			||||||
      Find.find(TEST_TMPDIR)
 | 
					      Find.find(TEST_TMPDIR)
 | 
				
			||||||
          .reject { |f| File.basename(f) == ".DS_Store" }
 | 
					          .reject { |f| File.basename(f) == ".DS_Store" }
 | 
				
			||||||
 | 
				
			|||||||
@ -63,7 +63,7 @@ class FakeSystemCommand
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RSpec.configure do |config|
 | 
					RSpec.configure do |config|
 | 
				
			||||||
  config.after(:each) do
 | 
					  config.after do
 | 
				
			||||||
    begin
 | 
					    begin
 | 
				
			||||||
      FakeSystemCommand.verify_expectations!
 | 
					      FakeSystemCommand.verify_expectations!
 | 
				
			||||||
    ensure
 | 
					    ensure
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user