Class: RuboCop::Cop::Rails::CreateTableWithTimestamps
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Rails::CreateTableWithTimestamps
- Defined in:
- lib/rubocop/cop/rails/create_table_with_timestamps.rb
Overview
This cop checks the migration for which timestamps are not included when creating a new table. In many cases, timestamps are useful information and should be added.
Constant Summary collapse
- MSG =
'Add timestamps when creating a new table.'
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rubocop/cop/rails/create_table_with_timestamps.rb', line 67 def on_send(node) return unless node.command?(:create_table) parent = node.parent if create_table_with_block?(parent) add_offense(parent) if parent.body.nil? || !time_columns_included?(parent.body) elsif (node) # nothing to do else add_offense(node) end end |