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!
@geniou Any idea what's up here?
@dleve123 sorry for the delay. I tied to reproduce the problem but I had no success. It is strange because when the rubocop_todo.yml file was created rubocop-rspec seams to be there. Did you start rubocop with bundle - e.g. bundle exec rubocop? I'm just guessing.
@geniou Thanks for helping out!
We are not running rubocop in the context of our bundle. That could definitely be the explanation. Will amend our build script and get back to you!
@geniou - I work with @dleve123 and it appears we are running it within our bundle; however, I just noticed something else. When the RSPec cops are moved into the original .rubocop.yml file and not inherited from .rubocop_todo.yml it appears to no longer produce the warning.
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.
@GolfyMcG thanks that worked for me
Is this still an issue for anybody?
@nijikon we have not changed our .rubocop.yml or .rubocop_todo.yml files so I can't say for sure
No problems here anymore. Rubocop 0.37.2, rubocop-rspec 1.4.0.
However, when running with --only there is still a warning.
$ rubocop --only RSpec/AnyInstance
Running via Spring preloader in process 12894
Warning: unrecognized cop RSpec/DescribeClass found in /path/to/.rubocop_todo.yml
Warning: unrecognized cop RSpec/DescribedClass found in /path/to/.rubocop_todo.yml
Warning: unrecognized cop RSpec/FilePath found in /path/to/.rubocop_todo.yml
Warning: unrecognized cop RSpec/InstanceVariable found in /path/to/.rubocop_todo.yml
Warning: unrecognized cop RSpec/NotToNot found in /path/to/.rubocop_todo.yml
I'm running Rails 4.2.1 and Rubocop 0.37.2 and getting a ton of An error occurred while RSpec/FilePath cop was inspecting [file].
require: rubocop-rspec
AllCops:
Exclude:
- 'bin/**/*'
- 'config/**/*'
- 'db/**/*'
- 'spec/spec_helper.rb'
- 'spec/rails_helper.rb'
- 'Rakefile'
Documentation:
Enabled: false
Metrics/LineLength:
Max: 200
Metrics/ClassLength:
Max: 500
Metrics/ModuleLength:
Exclude:
- 'spec/**/*_spec.rb'
Rails:
Enabled: true
RSpec/DescribeClass:
Exclude:
- spec/requests/**/*
- spec/routes/**/*
- spec/support/**/*
Style/TrivialAccessors:
Exclude:
- spec/**/*
@kWhittington it should be Enabled: true, not Enable: true
@andyw8 that was just a typo in the comment, I've updated my sample .rubocop.yml. I'm getting the warning, Warning: unrecognized cop Rails found in . . ., with:
Rails:
Enabled: true
inside of .rubocop.yml with Rubocop v0.35.1. Upgrading Rubocop to v0.37.2 solves that warning but then produces the An error occurred while RSpec/FilePath cop was inspecting . . . error.
@nijikon we're still seeing warning
Warning: unrecognized cop Rspec/DescribeClass found in .../.rubocop.yml
With following entry in rubocop.yml:
Rspec/DescribeClass:
Enabled: false
rubocop-rspec (1.4.0)
rubocop (0.33.0)
@kowal: Try RSpec/DescribeClass instead of Rspec/DescribeClass
@andyw8 yup that was a typo :) thx!
Is anyone still experiencing this issue? It seems like the require: recommendation resolves the problems being described. If anyone follows up saying they are having the same problem I will reopen
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).
@aried3r thats currently out of rubocop-rspec's control. See https://github.com/bbatsov/rubocop/issues/3414
Most helpful comment
It works using
require: rubocop-rspecin both.rubocop.ymland.rubocop_todo.yml. But I'd argue that it's not ideal, since.rubocop_todo.ymlis an auto generated file that gets overwritten frequently (at least in our project, with every new rubocop release).