Skip to content

Commit 2c65962

Browse files
authored
Merge pull request rubocop#1466 from davidrunger/avoid-warnings-about-redefined-methods
Avoid warnings about redefined methods in EnforceSuperclass module
2 parents 332ef79 + f5c8ee8 commit 2c65962

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1465](https://github.com/rubocop/rubocop-rails/issues/1465): Avoid warnings about methods of `RuboCop::Cop::EnforceSuperclass` being redefined. ([@davidrunger][])

lib/rubocop/cop/mixin/enforce_superclass.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# frozen_string_literal: true
22

33
module RuboCop
4-
module Cop
4+
module Cop # rubocop:disable Style/Documentation
5+
# The EnforceSuperclass module is also defined in `rubocop` (for backwards
6+
# compatibility), so here we remove it before (re)defining it, to avoid
7+
# warnings about methods in the module being redefined.
8+
remove_const(:EnforceSuperclass) if defined?(EnforceSuperclass)
9+
510
# Common functionality for enforcing a specific superclass.
611
module EnforceSuperclass
712
def self.included(base)

0 commit comments

Comments
 (0)