class RuboCop::Cop::Style::TrailingCommaInArguments

)
2
1,
method(
# good if EnforcedStyleForMultiline is no_comma
)
2,
1,
method(
# good if EnforcedStyleForMultiline is comma or consistent_comma
)
3,
1, 2,
method(
# good if EnforcedStyleForMultiline is consistent_comma
method(1, 2,)
# always bad
@example
This cop checks for trailing comma in argument lists.

def avoid_autocorrect?(args)

def avoid_autocorrect?(args)
  args.last.hash_type? && args.last.braces? &&
    braces_will_be_removed?(args)
end

def braces_will_be_removed?(args)

of the last argument.
Returns true if running with --auto-correct would remove the braces
def braces_will_be_removed?(args)
  brace_config = config.for_cop('Style/BracesAroundHashParameters')
  return false unless brace_config.fetch('Enabled')
  return false if brace_config['AutoCorrect'] == false
  brace_style = brace_config['EnforcedStyle']
  return true if brace_style == 'no_braces'
  return false unless brace_style == 'context_dependent'
  args.one? || !args[-2].hash_type?
end

def on_send(node)

def on_send(node)
  return unless node.arguments? && node.parenthesized?
  check(node, node.arguments, 'parameter of %s method call',
        node.last_argument.source_range.end_pos,
        node.source_range.end_pos)
end