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
Rails/HttpStatus not working after requiring rubocop-rspec #611
Comments
I think there is a conflict of cops name between I'm not sure how we can fix that 🤔 |
could we rename |
Since this is still a problem and it's hard to find out how to fix this maybe it would be better to rename |
Any news/plans on fixing this? |
Right now I have to switch orders of requires to check both cops worked... |
I have fixed this issue locally with following hacks: # file: rubocop/fixes/http_status.rb
# frozen_string_literal: true
require "rubocop/cop/rails/http_status"
require "rubocop/cop/rspec/rails/http_status"
RuboCop::Cop::Cop.registry.instance_eval do
[
RuboCop::Cop::Rails::HttpStatus,
RuboCop::Cop::RSpec::Rails::HttpStatus
].each do |cop|
@registry.delete cop.badge
@departments[cop.department].delete cop
@cops_by_cop_name[cop.cop_name].delete cop
end
end
module RuboCop
module Cop
module RSpec
module Rails
class HttpStatus < Cop
def self.badge
*departament, cop_name = name.split("::").last(3)
Badge.new(departament.join("/"), cop_name)
end
end
end
end
end
end
[RuboCop::Cop::Rails::HttpStatus, RuboCop::Cop::RSpec::Rails::HttpStatus]
.each { |cop| RuboCop::Cop::Cop.registry.enlist cop } # file: rubocop/fixes/http_status.yml
RSpec/Rails/HttpStatus:
Description: Enforces use of symbolic or numeric value to describe HTTP status.
Enabled: true
EnforcedStyle: symbolic
SupportedStyles:
- numeric
- symbolic
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus # file: .rubocop.yml
require:
- ./rubocop/fixes/http_status.rb
inherit:
- ./rubocop/fixes/http_status.yml |
I've added initial work to fix this issue: |
@ixti the code required to support sub-departments looks non-trivial, I'm not sure if it will have a warm welcome in RuboCop. WDYT of renaming this cop to |
@pirj Yeah, I thought that it won't be welcomed :D It was more like a "what about" example to have some input ideas on. And I totally love your renaming idea. |
Did someone end up opening an issue to fix this on the RuboCop side (#834 (comment))? I can't find one. |
@haines Unfortunately not. Would you like to handle this? |
Opened rubocop/rubocop#8044 |
Thanks @haines ! |
This should be fixed in #1019 that is part of the release 2.0. |
After adding
require: rubocop-rspec
to the.rubocop.yml
, theRails/HttpStatus
doesn't check the code, only the specsfirst reported here: rubocop/rubocop#5738 (comment)
rubocop-rspec 1.25.1
The text was updated successfully, but these errors were encountered: