Class: Rubocop::Cop::Style::Alias
- Defined in:
- lib/rubocop/cop/style/alias.rb
Overview
The purpose of the this cop is advise the use of alias_method over the alias keyword whenever possible.
Constant Summary collapse
- MSG =
'Use alias_method instead of alias.'
Constants inherited from Cop
Instance Attribute Summary
Attributes inherited from Cop
#config, #corrections, #offences, #processed_source
Instance Method Summary collapse
-
#on_alias(node) ⇒ Object
TODO: Make this check context aware - alias_method is not available outside of classes/modules.
Methods inherited from Cop
#add_offence, all, #autocorrect?, #autocorrect_action, #convention, #cop_config, #cop_name, cop_name, cop_type, #debug?, #ignore_node, inherited, #initialize, lint?, #message, rails?, style?, #warning
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#on_alias(node) ⇒ Object
TODO: Make this check context aware - alias_method is not available outside of classes/modules.
13 14 15 16 17 18 19 20 |
# File 'lib/rubocop/cop/style/alias.rb', line 13 def on_alias(node) # alias_method can't be used with global variables new, old = *node return if new.type == :gvar && old.type == :gvar convention(node, :keyword) end |