Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useless block arg comma #789

Merged
merged 4 commits into from Jan 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.adoc
Expand Up @@ -2194,6 +2194,32 @@ with_tmp_dir do |dir|
end
----

=== No Trailing Argument Comma [[no-trailing-argument-comma]]

Avoid comma after the last argument in a block, except in cases where only a single argument is present and its removal would affect functionality (for instance, array destructuring).

[source,ruby]
----
# bad - easier to move/add/remove parameters, but still not preferred
[[1, 2, 3], [4, 5, 6]].each do |a, b, c,|
a + b + c
end

# good
[[1, 2, 3], [4, 5, 6]].each do |a, b, c|
a + b + c
end

# bad
[[1, 2, 3], [4, 5, 6]].each { |a, b, c,| a + b + c }

# good
[[1, 2, 3], [4, 5, 6]].each { |a, b, c| a + b + c }

# good - this comma is meaningful for array destructuring
[[1, 2, 3], [4, 5, 6]].map { |a,| a }
----


=== No Nested Methods [[no-nested-methods]]

Expand Down