Skip to content

Commit 244652e

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

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,22 @@
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+
if name == 'RSpec/Rails/HttpStatus'
28+
badge = Badge.parse(name)
29+
return resolve_badge(badge, qualify_badge(badge).first, path)
30+
end
31+
32+
super
33+
end
34+
end)
35+
end
36+
end
37+
end

0 commit comments

Comments
 (0)