Module: RuboCop::Cop::EnforceSuperclass Deprecated Private
Do not use. This module is for internal use only.
Relationships & Source Files | |
Defined in: | lib/rubocop/cop/mixin/enforce_superclass.rb |
Overview
Deprecated.
This module is deprecated and will be removed by RuboCop 2.0.
Common functionality for enforcing a specific superclass.
Important
|
RuboCop core depended on this module when it supported Rails department. Rails department has been extracted to RuboCop Rails gem. |
It will not be updated to Base
v1 API to maintain compatibility
with existing RuboCop Rails 2.8 or lower.
Class Method Summary
- .included(base) Internal use only
Instance Method Summary
- #on_class(node) Internal use only
- #on_send(node) Internal use only
Class Method Details
.included(base)
[ GitHub ]# File 'lib/rubocop/cop/mixin/enforce_superclass.rb', line 16
def self.included(base) warn Rainbow( '`RuboCop::Cop::EnforceSuperclass` is deprecated and will be removed in RuboCop 2.0. ' \ 'Please upgrade to RuboCop Rails 2.9 or newer to continue.' ).yellow # @!method class_definition(node) base.def_node_matcher :class_definition, <<~PATTERN (class (const _ !:#{base::SUPERCLASS}) #{base::BASE_PATTERN} ...) PATTERN # @!method class_new_definition(node) base.def_node_matcher :class_new_definition, <<~PATTERN [!^(casgn {nil? cbase} :#{base::SUPERCLASS} ...) !^^(casgn {nil? cbase} :#{base::SUPERCLASS} (block ...)) (send (const {nil? cbase} :Class) :new #{base::BASE_PATTERN})] PATTERN end
Instance Method Details
#on_class(node)
[ GitHub ]# File 'lib/rubocop/cop/mixin/enforce_superclass.rb', line 35
def on_class(node) class_definition(node) { add_offense(node.children[1]) } end
#on_send(node)
[ GitHub ]# File 'lib/rubocop/cop/mixin/enforce_superclass.rb', line 39
def on_send(node) class_new_definition(node) { add_offense(node.children.last) } end