Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Update to a version of Rubocop that is compatible with Ruby 2.4-3.1 #2927

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
inherit_from:
- .rubocop_rspec_base.yml
- .rubocop_todo.yml

AllCops:
Exclude:
Expand All @@ -10,17 +11,20 @@ AllCops:
Metrics/ClassLength:
Max: 330

Encoding:
Exclude:
- lib/rspec/core/formatters/exception_presenter.rb
# This can be addressed once Ruby 1.8 support is removed.
Style/Encoding:
Enabled: false

# This should go down over time.
Metrics/AbcSize:
Max: 40

# This should go down over time.
Metrics/LineLength:
Layout/LineLength:
Max: 130
Exclude:
- features/**/*
- spec/**/*

# This should go down over time.
Metrics/MethodLength:
Expand All @@ -33,7 +37,7 @@ Metrics/CyclomaticComplexity:
Metrics/PerceivedComplexity:
Max: 15

Lint/HandleExceptions:
Lint/SuppressedException:
Exclude:
- lib/rspec/core/example.rb
- lib/rspec/core/mocking_adapters/mocha.rb
Expand Down Expand Up @@ -89,22 +93,13 @@ Style/RaiseArgs:
- lib/rspec/core/hooks.rb
- lib/rspec/core/option_parser.rb
- lib/rspec/core/pending.rb

Performance/RedundantBlockCall:
Exclude:
- lib/rspec/core/rake_task.rb
- spec/rspec/core/formatters/base_text_formatter_spec.rb

Lint/IneffectiveAccessModifier:
Exclude:
- lib/rspec/core/memoized_helpers.rb # Fixing this file was too much of a diff

Performance/Caller:
Exclude:
# The suggested fix for this cop only works on more recent rubies. The
# speed up can be substantial (previous optimization work I've done on
# RSpec involved caller optimization) but I haven't benchmarked this
# particular case to see if it's worth introducing version branching.
- 'lib/rspec/core/example_group.rb'

Metrics/BlockLength:
Max: 193
Max: 206
Exclude:
- spec/**/*.rb
83 changes: 45 additions & 38 deletions .rubocop_rspec_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,73 @@
# This file contains defaults for RSpec projects. Individual projects
# can customize by inheriting this file and overriding particular settings.

AccessModifierIndentation:
Layout/AccessModifierIndentation:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally update this file using rspec-dev that can make multiple changes at once, I'd prefer to do that and then add the extra "version bump" commit to those prs by hand.

Enabled: false

# "Use alias_method instead of alias"
# We're fine with `alias`.
Alias:
Style/Alias:
Enabled: false

AlignParameters:
EnforcedStyle: with_first_parameter

# "Avoid the use of the case equality operator ==="
# We prefer using `Class#===` over `Object#is_a?` because `Class#===`
# is less likely to be monkey patched than `is_a?` on a user object.
CaseEquality:
Style/CaseEquality:
Enabled: false

# Warns when the class is excessively long.
ClassLength:
Metrics/ClassLength:
Max: 100

CollectionMethods:
Style/CollectionMethods:
PreferredMethods:
reduce: 'inject'

# Over time we'd like to get this down, but this is what we're at now.
CyclomaticComplexity:
Metrics/CyclomaticComplexity:
Max: 10

# We use YARD to enforce documentation. It works better than rubocop's
# enforcement...rubocop complains about the places we re-open
# `RSpec::Expectations` and `RSpec::Matchers` w/o having doc commments.
Documentation:
Style/Documentation:
Enabled: false

# We still support 1.8.7 which requires trailing dots
DotPosition:
Layout/DotPosition:
EnforcedStyle: trailing

DoubleNegation:
Style/DoubleNegation:
Enabled: false

# each_with_object is unavailable on 1.8.7 so we have to disable this one.
EachWithObject:
Style/EachWithObject:
Enabled: false

FormatString:
Style/FormatString:
EnforcedStyle: percent

# As long as we support ruby 1.8.7 we have to use hash rockets.
HashSyntax:
Style/HashSyntax:
EnforcedStyle: hash_rockets

# We can't use the new lambda syntax, since we still support 1.8.7.
Lambda:
Style/Lambda:
Enabled: false

# Over time we'd like to get this down, but this is what we're at now.
LineLength:
Layout/LineLength:
Max: 100

# Over time we'd like to get this down, but this is what we're at now.
MethodLength:
Metrics/MethodLength:
Max: 15

# Who cares what we call the argument for binary operator methods?
BinaryOperatorParameterName:
Naming/BinaryOperatorParameterName:
Enabled: false

PercentLiteralDelimiters:
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': () # double-quoted string
'%i': '[]' # array of symbols
Expand All @@ -87,41 +84,44 @@ PercentLiteralDelimiters:

# We have too many special cases where we allow generator methods or prefer a
# prefixed predicate due to it's improved readability.
PredicateName:
Naming/PredicateName:
Enabled: false

# On 1.8 `proc` is `lambda`, so we use `Proc.new` to ensure we get real procs on all supported versions.
# http://batsov.com/articles/2014/02/04/the-elements-of-style-in-ruby-number-12-proc-vs-proc-dot-new/
Proc:
Style/Proc:
Enabled: false

# Exceptions should be rescued with `Support::AllExceptionsExceptOnesWeMustNotRescue`
RescueException:
Lint/RescueException:
Enabled: true

# We haven't adopted the `fail` to signal exceptions vs `raise` for re-raises convention.
SignalException:
Style/SignalException:
Enabled: false

# We've tended to use no space, so it's less of a change to stick with that.
SpaceAroundEqualsInParameterDefault:
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space

# We don't care about single vs double qoutes.
StringLiterals:
Style/StringLiterals:
Enabled: false

# This rule favors constant names from the English standard library which we don't load.
Style/SpecialGlobalVars:
Enabled: false

Style/TrailingCommaInLiteral:
Style/TrailingCommaInArrayLiteral:
Enabled: false

Style/TrailingCommaInHashLiteral:
Enabled: false

Style/TrailingCommaInArguments:
Enabled: false

TrivialAccessors:
Style/TrivialAccessors:
AllowDSLWriters: true
AllowPredicates: true
ExactNameMatch: true
Expand All @@ -135,6 +135,15 @@ Layout/EmptyLineBetweenDefs:
Layout/FirstParameterIndentation:
Enabled: false

Layout/ParameterAlignment:
EnforcedStyle: with_first_parameter

Layout/SpaceInsideBlockBraces:
Enabled: false

Layout/SpaceInsideParens:
Enabled: false

Naming/ConstantName:
Enabled: false

Expand Down Expand Up @@ -162,7 +171,10 @@ Style/IfUnlessModifier:
Style/IfUnlessModifierOfIfUnless:
Enabled: false

Style/MethodMissing:
Lint/MissingSuper:
Enabled: false

Style/MissingRespondToMissing:
Enabled: false

Style/MixinUsage:
Expand Down Expand Up @@ -243,24 +255,19 @@ Style/StderrPuts:
Style/TernaryParentheses:
Enabled: false

# This could likely be enabled, but it had a false positive on rspec-mocks
# (suggested change was not behaviour preserving) so I don't trust it.
Performance/HashEachMethods:
Enabled: false

Naming/HeredocDelimiterNaming:
Enabled: false

Layout/EmptyLineAfterMagicComment:
Layout/AssignmentIndentation:
Enabled: false

Layout/IndentArray:
Layout/EmptyLineAfterMagicComment:
Enabled: false

Layout/IndentAssignment:
Layout/FirstArrayElementIndentation:
Enabled: false

Layout/IndentHeredoc:
Layout/HeredocIndentation:
Enabled: false

Layout/SpaceInsidePercentLiteralDelimiters:
Expand Down
Loading