Skip to content

Commit e816cf1

Browse files
authored
Merge pull request #685 from ydah/fix-override-incompatible-cop
Fix override RuboCop::Cop::Style::RedundantSelf.autocorrect_incompatible_with without breaking designation of future incompatible cop
2 parents 2e0814b + e94894c commit e816cf1

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lib/rubocop-rails.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@
1313
RuboCop::Rails::Inject.defaults!
1414

1515
require_relative 'rubocop/cop/rails_cops'
16+
17+
RuboCop::Cop::Style::RedundantSelf.singleton_class.prepend(
18+
Module.new do
19+
def autocorrect_incompatible_with
20+
super.push(RuboCop::Cop::Rails::SafeNavigation)
21+
end
22+
end
23+
)

lib/rubocop/cop/rails/safe_navigation.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ class SafeNavigation < Base
4747
(send _ ${:try :try!} $_ ...)
4848
PATTERN
4949

50-
# Monkey patching for `Style/RedundantSelf` of RuboCop core.
51-
# rubocop:disable Style/ClassAndModuleChildren
52-
class Style::RedundantSelf
53-
def self.autocorrect_incompatible_with
54-
[Rails::SafeNavigation]
55-
end
56-
end
57-
# rubocop:enable Style/ClassAndModuleChildren
58-
5950
def self.autocorrect_incompatible_with
6051
[Style::RedundantSelf]
6152
end

0 commit comments

Comments
 (0)