Skip to content

Commit

Permalink
Merge pull request #685 from ydah/fix-override-incompatible-cop
Browse files Browse the repository at this point in the history
Fix override RuboCop::Cop::Style::RedundantSelf.autocorrect_incompatible_with without breaking designation of future incompatible cop
  • Loading branch information
koic authored Apr 2, 2022
2 parents 2e0814b + e94894c commit e816cf1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 8 additions & 0 deletions lib/rubocop-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@
RuboCop::Rails::Inject.defaults!

require_relative 'rubocop/cop/rails_cops'

RuboCop::Cop::Style::RedundantSelf.singleton_class.prepend(
Module.new do
def autocorrect_incompatible_with
super.push(RuboCop::Cop::Rails::SafeNavigation)
end
end
)
9 changes: 0 additions & 9 deletions lib/rubocop/cop/rails/safe_navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ class SafeNavigation < Base
(send _ ${:try :try!} $_ ...)
PATTERN

# Monkey patching for `Style/RedundantSelf` of RuboCop core.
# rubocop:disable Style/ClassAndModuleChildren
class Style::RedundantSelf
def self.autocorrect_incompatible_with
[Rails::SafeNavigation]
end
end
# rubocop:enable Style/ClassAndModuleChildren

def self.autocorrect_incompatible_with
[Style::RedundantSelf]
end
Expand Down

0 comments on commit e816cf1

Please sign in to comment.