class RuboCop::Cop::Rails::SchemaComment


end
t.type :column, comment: ‘Number of offenses’
create_table :table, comment: ‘Table of offenses data’ do |t|
add_column :table, :column, :integer, comment: ‘Number of offenses’
# good
end
t.type :column
create_table :table do |t|
add_column :table, :column, :integer
# bad (no comment for a new column or table)
@example
to the database during a migration.
Enforces the use of the ‘comment` option when adding a new table or column

def add_column_without_comment?(node)

def add_column_without_comment?(node)
  add_column?(node) && !add_column_with_comment?(node)
end

def check_column_within_create_table_block(node)

def check_column_within_create_table_block(node)
  if node.begin_type?
    node.child_nodes.each do |child_node|
      add_offense(child_node, message: COLUMN_MSG) if t_column_without_comment?(child_node)
    end
  elsif t_column_without_comment?(node)
    add_offense(node, message: COLUMN_MSG)
  end
end

def create_table_without_comment?(node)

def create_table_without_comment?(node)
  create_table?(node) && !create_table_with_comment?(node)
end

def on_send(node)

def on_send(node)
  if add_column_without_comment?(node)
    add_offense(node, message: COLUMN_MSG)
  elsif create_table_without_comment?(node)
    add_offense(node, message: TABLE_MSG)
  elsif create_table_with_block?(node.parent)
    check_column_within_create_table_block(node.parent.body)
  end
end

def t_column_without_comment?(node)

def t_column_without_comment?(node)
  t_column?(node) && !t_column_with_comment?(node)
end