A cop
| Enabled by default |
Safe |
Supports autocorrection |
VersionAdded |
VersionChanged |
| Disabled |
No |
Yes (Unsafe) |
0.81 |
- |
This cop checks whether trailing commas in block arguments are required. Blocks with only one argument and a trailing comma require that comma to be present. Blocks with more than one argument never require a trailing comma.
Examples
# bad
add { |foo, bar,| foo + bar }
# good
add { |foo, bar| foo + bar }
# good
add { |foo,| foo }
# good
add { foo }
# bad
add do |foo, bar,|
foo + bar
end
# good
add do |foo, bar|
foo + bar
end
# good
add do |foo,|
foo
end
# good
add do
foo + bar
end
A cop
This cop checks whether trailing commas in block arguments are required. Blocks with only one argument and a trailing comma require that comma to be present. Blocks with more than one argument never require a trailing comma.
Examples