-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix an error for unrecognized cop or department RSpecRails/HttpStatus
when also using rubocop-rails
#14
Conversation
RSpecRails/HttpStatus
when also using rubocop-rails
bc7b36e
to
244652e
Compare
RSpecRails/HttpStatus
when also using rubocop-railsRSpecRails/HttpStatus
when also using rubocop-rails
module Cop | ||
class AmbiguousCopName # rubocop:disable Style/Documentation | ||
prepend(Module.new do | ||
def qualified_cop_name(name, path, warn: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memo) There are two possibilities: Rails/HttpStatus or RSpecRails/HttpStatus, which causes an AmbiguousCopName Error. So, as a work around, if name is' RSpec/Rails/HttpStatus', it is rigged so that an AmbiguousCopName Error does not occur.
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?
Added workaround. This is probably caused by the fact that rubocop-rails also has a cop name named |
…s` when also using rubocop-rails Fix: #8
I updated this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another temporary fix, right? We should consider keeping a written TODO list of things to revert in the future.
@bquorning Yes. Indeed it is. Then I will list it in Issues later. |
This PR prevents the following build error: ```console NoMethodError: undefined method `cop_name' for nil # ./lib/rubocop/cop/badge.rb:52:in `match?' # ./lib/rubocop/cop/registry.rb:300:in `resolve_badge' # ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name' ``` https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762 This error is due to a monkey patch in rubocop-rails_rails: rubocop/rubocop-rspec_rails#14 The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies. RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem. However, this is not possible currently because rubocop-rspec is still dependent on it.
This PR prevents the following build error: ```console NoMethodError: undefined method `cop_name' for nil # ./lib/rubocop/cop/badge.rb:52:in `match?' # ./lib/rubocop/cop/registry.rb:300:in `resolve_badge' # ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name' ``` https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762 This build error is due to a monkey patch in rubocop-rails_rails: rubocop/rubocop-rspec_rails#14 The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies. RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem. However, this is not possible currently because rubocop-rspec is still dependent on it.
This PR prevents the following build error: ```console NoMethodError: undefined method `cop_name' for nil # ./lib/rubocop/cop/badge.rb:52:in `match?' # ./lib/rubocop/cop/registry.rb:300:in `resolve_badge' # ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name' ``` https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762 This build error is due to a monkey patch in rubocop-rails_rails: rubocop/rubocop-rspec_rails#14 The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies. RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem. However, this is not possible currently because rubocop-rspec is still dependent on it.
This PR prevents the following build error: ```console NoMethodError: undefined method `cop_name' for nil # ./lib/rubocop/cop/badge.rb:52:in `match?' # ./lib/rubocop/cop/registry.rb:300:in `resolve_badge' # ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name' ``` https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762 This build error is due to a monkey patch in rubocop-rails_rails: rubocop/rubocop-rspec_rails#14 The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies. RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem. However, this is not possible currently because rubocop-rspec is still dependent on it.
This PR prevents the following build error: ```console NoMethodError: undefined method `cop_name' for nil # ./lib/rubocop/cop/badge.rb:52:in `match?' # ./lib/rubocop/cop/registry.rb:300:in `resolve_badge' # ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name' ``` https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762 This build error is due to a monkey patch in rubocop-rails_rails: rubocop/rubocop-rspec_rails#14 The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies. RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem. However, this is not possible currently because rubocop-rspec is still dependent on it.
This PR prevents the following build error: ```console NoMethodError: undefined method `cop_name' for nil # ./lib/rubocop/cop/badge.rb:52:in `match?' # ./lib/rubocop/cop/registry.rb:300:in `resolve_badge' # ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name' ``` https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762 This build error is due to a monkey patch in rubocop-rails_rails: rubocop/rubocop-rspec_rails#14 The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies. RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem. However, this is not possible currently because rubocop-rspec is still dependent on it.
@ydah It seems there is an issue with the workaround monkey patch. For more details, please see rubocop/rubocop#12836. |
Fix: #8
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).