rubocop-rspec: "Warning: unrecognized cop RSpec/DescribeClass" on running `rubocop`

Some debugging info:

$ cat Gemfile.lock | grep rubocop
    rubocop (0.29.0)
    rubocop-rspec (1.2.1)
  rubocop
  rubocop-rspec
$ cat .rubocop.yml 
require: rubocop-rspec

inherit_from: .rubocop_todo.yml

AllCops:
  RunRailsCops: true
  Exclude:
    - 'bin/**/*'
    - 'vendor/**/*'
    - 'app/controllers/resource_sites_controller.rb'
Documentation:
  Enabled: false
$ cat .rubocop_todo.yml
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-02-12 16:50:06 -0500 using RuboCop version 0.29.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: 16
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
  Enabled: false

# Offense count: 5
Lint/Debugger:
  Enabled: false

# Offense count: 1
# Configuration parameters: AlignWith, SupportedStyles.
Lint/DefEndAlignment:
  Enabled: false

# Offense count: 4
# Configuration parameters: AlignWith, SupportedStyles.
Lint/EndAlignment:
  Enabled: false

# Offense count: 1
Lint/Eval:
  Enabled: false

# Offense count: 1
Lint/HandleExceptions:
  Enabled: false

# Offense count: 2
Lint/ParenthesesAsGroupedExpression:
  Enabled: false

# Offense count: 1
Lint/RescueException:
  Enabled: false

# Offense count: 1
Lint/ShadowingOuterLocalVariable:
  Enabled: false

# Offense count: 1
Lint/UselessAccessModifier:
  Enabled: false

# Offense count: 23
Lint/UselessAssignment:
  Enabled: false

# Offense count: 45
Metrics/AbcSize:
  Max: 87

# Offense count: 9
# Configuration parameters: CountComments.
Metrics/ClassLength:
  Max: 210

# Offense count: 7
Metrics/CyclomaticComplexity:
  Max: 9

# Offense count: 1809
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
  Max: 301

# Offense count: 40
# Configuration parameters: CountComments.
Metrics/MethodLength:
  Max: 97

# Offense count: 1
Metrics/PerceivedComplexity:
  Max: 9

# Offense count: 5
RSpec/DescribeClass:
  Enabled: false

# Offense count: 109
RSpec/DescribedClass:
  Enabled: false

# Offense count: 211
# Configuration parameters: CustomTransform, IgnoredWords.
RSpec/ExampleWording:
  Enabled: false

# Offense count: 2
# Configuration parameters: CustomTransform.
RSpec/FilePath:
  Enabled: false

# Offense count: 15
RSpec/InstanceVariable:
  Enabled: false

# Offense count: 1
RSpec/MultipleDescribes:
  Enabled: false

# Offense count: 10
# Configuration parameters: Include.
Rails/HasAndBelongsToMany:
  Enabled: false

# Offense count: 2
# Configuration parameters: Include.
Rails/Output:
  Enabled: false

# Offense count: 3
# Configuration parameters: Include.
Rails/Validation:
  Enabled: false

# Offense count: 11
Style/AccessorMethodName:
  Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
Style/AlignHash:
  Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AlignParameters:
  Enabled: false

# Offense count: 8
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
Style/CaseIndentation:
  Enabled: false

# Offense count: 13
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
  Enabled: false

# Offense count: 2
Style/EachWithObject:
  Enabled: false

# Offense count: 3
Style/EmptyElse:
  Enabled: false

# Offense count: 7
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
  Enabled: false

# Offense count: 63
# Configuration parameters: MinBodyLength.
Style/GuardClause:
  Enabled: false

# Offense count: 16
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
  Enabled: false

# Offense count: 13
# Cop supports --auto-correct.
Style/Lambda:
  Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
Style/LineEndConcatenation:
  Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MultilineOperationIndentation:
  Enabled: false

# Offense count: 2
Style/MultilineTernaryOperator:
  Enabled: false

# Offense count: 4
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
Style/Next:
  Enabled: false

# Offense count: 8
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
Style/PredicateName:
  Enabled: false

# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/RaiseArgs:
  Enabled: false

# Offense count: 1
# Configuration parameters: MaxSlashes.
Style/RegexpLiteral:
  Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/SelfAssignment:
  Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SignalException:
  Enabled: false

# Offense count: 1
# Configuration parameters: Methods.
Style/SingleLineBlockParams:
  Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
Style/SymbolProc:
  Enabled: false

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
Style/TrivialAccessors:
  Enabled: false

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

# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/VariableName:
  Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: WordRegex.
Style/WordArray:
  MinSize: 5

Looks like the rubocop-rspec cops are successfully being ignored (commenting out the disabling of them causes cop failures), so the warning is very odd.

RSpec/DescribeClass is failing because it is the first rubocop-rspec being encountered. In other words, if I reordered the declarations of rubocop-rspec’s cops in the TODO file, the very first rubocop-rspec cop will appear in the warning.

Please let me know if more information is needed!

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 19 (3 by maintainers)

Most upvoted comments

It works using require: rubocop-rspec in both .rubocop.yml and .rubocop_todo.yml. But I’d argue that it’s not ideal, since .rubocop_todo.yml is an auto generated file that gets overwritten frequently (at least in our project, with every new rubocop release).

Just figured out a semi-solution - for anyone looking at this in the future or if you think this is actually a bug and should be fixed or if this tells us the problem with our setup… Adding require rubocop-rspec to the .rubocop_todo.yml prevents the warning message despite require rubocop-rspec already being at the top of our .rubocop.yml before inheriting the todo.