Class: RuboCop::Cop::Rails::PostgresTimestamp

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/rails/postgres_timestamp.rb

Constant Summary collapse

MSG =
'Use t.timestamptz for better timezone support.'
RESTRICT_ON_SEND =
[:datetime, :timestamps].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



18
19
20
21
22
23
# File 'lib/rubocop/cop/rails/postgres_timestamp.rb', line 18

def on_send(node)
  return unless in_migration_file?
  return unless node.receiver&.name == :t

  add_offense(node, message: MSG) if table_datetime_usage(node) || table_timestamps_usage(node)
end