Class: RuboCop::Cop::G2::Migrations::CheckExistence

Inherits:
Cop
  • Object
show all
Includes:
MigrationsHelper
Defined in:
lib/rubocop/cop/g2/migrations/check_existence.rb

Constant Summary collapse

CONSTRUCTIVE_METHODS =
method_map.keys.freeze
DESTRUCTIVE_METHODS =
method_map.values.freeze
IF_EXISTS_MSG =
'Use `if_exists: true` option'.freeze
IF_NOT_EXISTS_MSG =
'Use `if_not_exists: true` option'.freeze
WITH_OPTIONS_NODE_TYPES =
%i(block send).freeze
RESTRICT_ON_SEND =
(CONSTRUCTIVE_METHODS + DESTRUCTIVE_METHODS).freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/rubocop/cop/g2/migrations/check_existence.rb', line 30

def on_send(node)
  return unless in_migration?(node)

  error = check_for_errors(node)
  return unless error

  add_offense node, message: error
end