Rubocop-rspec: Still getting "RSpec/FilePath has the wrong namespace - should be Rails"

Created on 28 Apr 2017  路  5Comments  路  Source: rubocop-hq/rubocop-rspec

If I run rubocop from the command line with the option --only RSpec/FilePath I get the following:

$ rubocop --only RSpec/FilePath
--only option: RSpec/FilePath has the wrong namespace - should be Rails
Inspecting 21 files
.....................

$ rubocop -v
0.48.1

$ cat Gemfile.lock | grep rubocop-rspec
    rubocop-rspec (1.15.0)
  rubocop-rspec

My .rubocop.yml is as follows:

---
require: rubocop-rspec

AllCops:
  TargetRubyVersion: 2.2
  DisplayCopNames: true
  Exclude:
    - 'tmp/**/*'

Style/MixinGrouping:
  Exclude:
    - 'spec/**/*.rb'

Metrics/BlockLength:
  CountComments: false  # count full line comments?
  Exclude:
    - '**/*_spec.rb'

StringLiterals:
  EnforcedStyle: single_quotes
  Enabled: true

DotPosition:
  EnforcedStyle: leading
  Enabled: true

ClassAndModuleChildren:
  EnforcedStyle: nested
  Enabled: true

Documentation:
  Enabled: false

FileName:
  Enabled: true

LineLength:
  Max: 120
  Enabled: true

Style/ExtraSpacing:
  Enabled: true

Lint/LiteralInInterpolation:
  AutoCorrect: true

Style/ModuleFunction:
  EnforcedStyle: extend_self # Allows us to have private methods too

Style/PercentLiteralDelimiters:
  # Hound and CodeClimate are currently using an old version of Rubocop with
  # different defaults, so we set them explicitly here.
  PreferredDelimiters:
    default: ()
    '%i': '[]'
    '%I': '[]'
    '%r': '{}'
    '%w': '[]'
    '%W': '[]'

Most helpful comment

I can confirm @Darhazer's workaround works. As to the recommendation of adding require: rubocop-rspec to .rubocop_todo.yml: Since that's an auto-generated file, I think that would be quite tedious.

Is this bug caused because of a name conflict with another cop?

All 5 comments

This does not happen when rubocop-rspec is required manually.
rubocop --require rubocop-rspec --only RSpec/FilePath
Perhaps it's a bug in rubocop itself

Do you have a .rubocop_todo.yml file @dominicsayers? If so you might need to add require: rubocop-rspec to that as well

I can confirm @Darhazer's workaround works. As to the recommendation of adding require: rubocop-rspec to .rubocop_todo.yml: Since that's an auto-generated file, I think that would be quite tedious.

Is this bug caused because of a name conflict with another cop?

Wondering if it's still the case, since in the earliest RuboCop supported, 0.68.1, this cop is now named Naming/FileName.

I assume this has been fixed on RuboCop 1.x and RuboCop RSpec 2.x. If you still run into this issue @dominicsayers, please re-open the issue.

Was this page helpful?
0 / 5 - 0 ratings