Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized cop or department RSpecRails/HttpStatus #8

Closed
bestwebua opened this issue Mar 29, 2024 · 11 comments · Fixed by #14
Closed

Unrecognized cop or department RSpecRails/HttpStatus #8

bestwebua opened this issue Mar 29, 2024 · 11 comments · Fixed by #14

Comments

@bestwebua
Copy link

Hello! Today I have faced with interesting issue:

Error: unrecognized cop or department RSpecRails/HttpStatus found in /home/circleci/vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.1/config/default.yml
Did you mean `RSpecRails/HaveHttpStatus`?

Current stack:
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22]
'rubocop', '~> 1.62', '>= 1.62.1'
'rubocop-performance', '~> 1.20', '>= 1.20.2'
'rubocop-rspec', '~> 2.28'

Here is failed step on CI:
https://app.circleci.com/pipelines/github/on-strum/ruby-on-strum-logs/79/workflows/112f2214-e921-4cc7-8fde-1ee8952a157e/jobs/627

Here is my current Rubocop configuration:
https://github.com/on-strum/ruby-on-strum-logs/blob/master/.circleci/linter_configs/.rubocop.yml

What am I doing wrong? Thanks!

@mjankowski
Copy link

Similar issue in other repo: #9

I'm curious if the release notes are correct and the names should be aliased ... or if that's wrong and we need to rename these with this version bump.

@pboling
Copy link

pboling commented Mar 29, 2024

I am getting the same error. For now rolling back to version 2.27.1.

@mjankowski that is the same repo. 😄

@ydah
Copy link
Member

ydah commented Mar 30, 2024

I realized it's a strange phenomenon.

When rubocop-rails and rubocop-rspec are present, the setting RSpec/Rails/HttpStatus causes an Ambiguous cop name error.

❯ rubocop -V
1.62.1 (using Parser 3.3.0.5, rubocop-ast 1.31.2, running on ruby 3.3.0) [arm64-darwin23]
  - rubocop-rails 2.24.1
  - rubocop-rspec 2.28.0

The following do not cause an error:

# .rubocop.yml
require:
  - rubocop-rspec

RSpec/Rails/HttpStatus:
  EnforcedStyle: numeric
❯ bundle exec rubocop
.rubocop.yml: RSpec/Rails/HttpStatus has the wrong namespace - replace it with Rails/HttpStatus
Inspecting 4 files
....

4 files inspected, no offenses detected

However, the following do cause an error:

require:
  - rubocop-rails
  - rubocop-rspec

RSpec/Rails/HttpStatus:
  EnforcedStyle: numeric
❯ bundle exec rubocop
Error: Ambiguous cop name `RSpec/Rails/HttpStatus` used in /ydah/sandbox_capybara_with_rspec/.rubocop.yml needs department qualifier. Did you mean Rails/HttpStatus or RSpecRails/HttpStatus?

@bquorning
Copy link
Contributor

What if you change the configuration key from RSpec/Rails/HttpStatus: to RSpecRails/HttpStatus:?

@ydah
Copy link
Member

ydah commented Mar 30, 2024

No errors or warnings are raised.

require:
  - rubocop-rails
  - rubocop-rspec

RSpecRails/HttpStatus:
  EnforcedStyle: numeric
❯ bundle exec rubocop  
Inspecting 4 files
..C.

@bestwebua
Copy link
Author

bestwebua commented Mar 30, 2024

What if you change the configuration key from RSpec/Rails/HttpStatus: to RSpecRails/HttpStatus:?

rubocop -V
1.62.1 (using Parser 3.3.0.5, rubocop-ast 1.31.2, running on ruby 3.3.0) [arm64-darwin22]

rubocop-rspec (2.28.0)
rubocop-performance (1.21.0)
require:
  - rubocop-rspec
  - rubocop-performance

AllCops:
  DisplayCopNames: true
  DisplayStyleGuide: true
  TargetRubyVersion: 2.5
  SuggestExtensions: false
  NewCops: enable

I don't understand why this message is produces, I didn't use rubocop-rails at all. For me it's not an expected behavior.

@ydah
Copy link
Member

ydah commented Mar 30, 2024

Is rack included in the Gemfile? If no, this is probably resolved by the latest master rubocop-rsec_rails. Correct by following PR.

@bestwebua
Copy link
Author

bestwebua commented Mar 30, 2024

@ydah No. Here is an example what actually have been used: https://github.com/on-strum/ruby-on-strum-logs/blob/010d14f09e20e0aa3dc9c65ceaa4dad2962f8992/.circleci/gemspecs/latest The same issue with rubocop-rspec_rails (2.28.1).

@ydah
Copy link
Member

ydah commented Mar 30, 2024

I see.The following PR will probably solve the problem.

If you add rubocop-rspec_rails to the Gemfile with the master branch specified, the error should go away. If so, wait for the next release.

ydah added a commit that referenced this issue Mar 30, 2024
@ydah ydah closed this as completed in #14 Mar 30, 2024
@ydah
Copy link
Member

ydah commented Mar 30, 2024

FYI, A fixed version has been released:
https://github.com/rubocop/rubocop-rspec_rails/releases/tag/v2.28.2

Thank you for your report.

@bestwebua
Copy link
Author

@ydah Thanks! With this latest release all works as expected. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants