Skip to content

Commit

Permalink
Update to a version of Rubocop that is compatible with Ruby 2.4-3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
petergoldstein authored and JonRowe committed Sep 12, 2022
1 parent 71d904b commit 68d3e0d
Show file tree
Hide file tree
Showing 8 changed files with 401 additions and 62 deletions.
17 changes: 7 additions & 10 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
inherit_from:
- .rubocop_todo.yml
- .rubocop_rspec_base.yml

AllCops:
TargetRubyVersion: 2.1
TargetRubyVersion: 2.4
DisplayCopNames: true
Exclude:
- bin/*
- tmp/**/*

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

# Offense count: 1
Style/BlockComments:
Enabled: false

Style/BracesAroundHashParameters:
Exclude:
- spec/**/*

Style/ClassAndModuleChildren:
Exclude:
- spec/**/*
Expand Down Expand Up @@ -67,7 +64,7 @@ Security/Eval:
- Gemfile

Metrics/AbcSize:
Max: 26
Max: 27

# Offense count: 2
# Configuration parameters: CountComments, ExcludedMethods.
Expand All @@ -87,12 +84,12 @@ Metrics/ModuleLength:
Metrics/PerceivedComplexity:
Max: 14

AccessModifierIndentation:
Layout/AccessModifierIndentation:
Exclude:
- 'lib/rspec/expectations/syntax.rb' # Too much diff to fix

# Offense count: 7
Layout/AlignParameters:
Layout/ParameterAlignment:
Enabled: false

Layout/SpaceInsideArrayLiteralBrackets:
Expand All @@ -111,7 +108,7 @@ Lint/AmbiguousRegexpLiteral:
Exclude:
- 'features/step_definitions/*'

Lint/HandleExceptions:
Lint/SuppressedException:
Exclude:
- benchmarks/**/*

Expand Down
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:
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

0 comments on commit 68d3e0d

Please sign in to comment.