class RuboCop::Cop::Rails::ActiveRecordAliases
Checks that ActiveRecord aliases are not used. The direct method names are more clear and easier to read.
@example
#bad Book.update_attributes!(author: 'Alice') #good Book.update!(author: 'Alice')
Constants
- ALIASES
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/rails/active_record_aliases.rb, line 27 def on_send(node) method_name = node.method_name alias_method = ALIASES[method_name] add_offense( node.loc.selector, message: format(MSG, prefer: alias_method, current: method_name), severity: :warning ) do |corrector| corrector.replace(node.loc.selector, alias_method) end end
Also aliased as: on_csend