Class: RuboCop::Cop::Rails::IgnoredColumnsAssignment
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::IgnoredColumnsAssignment
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rails/ignored_columns_assignment.rb
Overview
Looks for assignments of ‘ignored_columns` that may override previous assignments.
Overwriting previous assignments is usually a mistake, since it will un-ignore the first set of columns. Since duplicate column names is not a problem, it is better to simply append to the list.
Constant Summary collapse
- MSG =
'Use `+=` instead of `=`.'
- RESTRICT_ON_SEND =
%i[ignored_columns=].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
42 43 44 45 46 |
# File 'lib/rubocop/cop/rails/ignored_columns_assignment.rb', line 42 def on_send(node) add_offense(node.loc.operator) do |corrector| corrector.replace(node.loc.operator, '+=') end end |