Class: RuboCop::Cop::Carwow::AddColumnWithComment
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Carwow::AddColumnWithComment
- Defined in:
- lib/rubocop/cop/carwow/add_column_with_comment.rb
Overview
Checks the migration to confirm that new columns have a comment.
Constant Summary collapse
- MSG =
"Missing 'comment' parameter for new column."
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rubocop/cop/carwow/add_column_with_comment.rb', line 40 def on_send(node) return unless add_column?(node) || inside_create_table_block?(node.parent.parent) # Timestamps and indexes do not need comments return if i[ index].include?(node.method_name) # Extract arguments _receiver, _method_name, *args = *node # Check if there is a 'comment' argument comment_arg = find_comment_arg(args) return if comment_arg add_offense(node, location: :expression, message: MSG) end |