Class: RuboCop::Cop::Rails::MigrationTableVariable

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

Constant Summary collapse

MSG =
'Use `t` as the variable name for table operations in migrations.'

Instance Method Summary collapse

Instance Method Details

#on_block(node) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/rubocop/cop/rails/migration_table_variable.rb', line 17

def on_block(node)
  return unless in_migration_file?

  variable_name = extract_table_variable(node)
  return unless variable_name
  return if variable_name == :t

  add_offense(node.arguments.first, message: MSG)
end