class RuboCop::Cop::Migration::UpdatingDataInMigration

Constants

MSG

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/safe_migrations_cops.rb, line 8
def on_send(node)
  return if allowed_methods.include?(node.method_name.to_s)

  add_offense(node) if forbidden_methods.include?(node.method_name)
end

Private Instance Methods

allowed_methods() click to toggle source
# File lib/rubocop/cop/safe_migrations_cops.rb, line 16
def allowed_methods
  cop_config["AllowedMethods"] || []
end
forbidden_methods() click to toggle source
# File lib/rubocop/cop/safe_migrations_cops.rb, line 20
def forbidden_methods
  %i[
    update
    update!
    update_all
    update_attribute
    update_column
    update_columns
    toggle
    toggle!
    delete
    delete_all
    destroy
    destroy_all
    save
    save!
  ]
end