Skip to content

Commit b4f25a4

Browse files
committed
Fix an error for unrecognized cop or department RSpecRails/HttpStatus when also using rubocop-rails
Fix: #8
1 parent ccd821e commit b4f25a4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Fix a `NameError` by Cross-Referencing. ([@ydah])
66
- Fix an error for `RSpecRails/HttpStatus` when no rack gem is loaded with rubocop-rspec. ([@ydah])
7+
- Fix an error for unrecognized cop or department `RSpecRails/HttpStatus` when also using rubocop-rails. ([@ydah])
78

89
## 2.28.1 (2024-03-29)
910

lib/rubocop-rspec_rails.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,20 @@
1616

1717
project_root = File.join(__dir__, '..')
1818
RuboCop::ConfigLoader.inject_defaults!(project_root)
19+
20+
# FIXME: This is a workaround for the following issue:
21+
# https://github.com/rubocop/rubocop-rspec_rails/issues/8
22+
module RuboCop
23+
module Cop
24+
class AmbiguousCopName # rubocop:disable Style/Documentation
25+
prepend(Module.new do
26+
def qualified_cop_name(name, path, warn: true)
27+
return super unless name == 'RSpec/Rails/HttpStatus'
28+
29+
badge = Badge.parse(name)
30+
resolve_badge(badge, qualify_badge(badge).first, path)
31+
end
32+
end)
33+
end
34+
end
35+
end

0 commit comments

Comments
 (0)