Merge pull request #5572 from MikeMcQuaid/rubocop-rspec-tweaks

Update RuboCop RSpec rules
This commit is contained in:
Mike McQuaid 2019-01-21 13:55:47 +00:00 committed by GitHub
commit 80509d1198
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 76 deletions

View File

@ -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:

View 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

View File

@ -1,4 +1,4 @@
inherit_from: ../.rubocop.yml
inherit_from: ../.rubocop_rspec.yml
AllCops:
Include:

View File

@ -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?

View File

@ -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

View File

@ -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|

View File

@ -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" }

View File

@ -63,7 +63,7 @@ class FakeSystemCommand
end
RSpec.configure do |config|
config.after(:each) do
config.after do
begin
FakeSystemCommand.verify_expectations!
ensure