class RuboCop::Cop::Style::TrailingCommaInArguments
)
2
1,
method(
# good
object[1, 2]
# good
method(1, 2)
# good
object[1, 2,]
# bad
method(1, 2,)
# bad
@example EnforcedStyleForMultiline: no_comma (default)
)
2,
1,
method(
# good
)
1, 2, 3
method(
# good
)
1, 2, 3,
method(
# bad
)
3
1, 2,
method(
# good
)
3,
1, 2,
method(
# bad
method(1, 2)
# good
method(1, 2,)
# bad
@example EnforcedStyleForMultiline: comma
)
2,
1,
method(
# good
)
1, 2, 3,
method(
# good
)
3,
1, 2,
method(
# good
method(1, 2)
# good
method(1, 2,)
# bad
@example EnforcedStyleForMultiline: consistent_comma
single-line method calls.
Regardless of style, trailing commas are not allowed in
argument.
* ‘no_comma`: Requires that there is no comma after the last
parenthesized method calls where each argument is on its own line.
* `comma`: Requires a comma after the last argument, but only for
for all parenthesized multi-line method calls with arguments.
* `consistent_comma`: Requires a comma after the last argument,
The supported styles are:
Checks for trailing comma in argument lists.
def self.autocorrect_incompatible_with
def self.autocorrect_incompatible_with [Layout::HeredocArgumentClosingParenthesis] end
def on_send(node)
def on_send(node) return unless node.arguments? && (node.parenthesized? || node.method?(:[])) check(node, node.arguments, 'parameter of %<article>s method call', node.last_argument.source_range.end_pos, node.source_range.end_pos) end