Class: Gitlab::Styles::Rubocop::Cop::Migration::ReversibleAddColumnWithDefault
- Inherits:
-
RuboCop::Cop::Cop
- Object
- RuboCop::Cop::Cop
- Gitlab::Styles::Rubocop::Cop::Migration::ReversibleAddColumnWithDefault
- Includes:
- MigrationHelpers
- Defined in:
- lib/gitlab/styles/rubocop/cop/migration/reversible_add_column_with_default.rb
Overview
Cop that checks if ‘add_column_with_default` is used with `up`/`down` methods and not `change`.
Constant Summary collapse
- MSG =
'`add_column_with_default` is not reversible so you must manually define ' \ 'the `up` and `down` methods in your migration class, using `remove_column` in `down`'.freeze
Instance Method Summary collapse
Methods included from MigrationHelpers
Instance Method Details
#on_send(node) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlab/styles/rubocop/cop/migration/reversible_add_column_with_default.rb', line 24 def on_send(node) return unless in_migration?(node) return unless add_column_with_default?(node) node.each_ancestor(:def) do |def_node| next unless defines_change?(def_node) add_offense(def_node, :name) end end |