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

Style/TrailingCommaInBlockArgs #36

Open
shannonfuit opened this issue Jul 7, 2020 · 1 comment
Open

Style/TrailingCommaInBlockArgs #36

shannonfuit opened this issue Jul 7, 2020 · 1 comment

Comments

@shannonfuit
Copy link

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
@Raou1d
Copy link
Contributor

Raou1d commented Jul 16, 2020

Note the Unsafe autocorrect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants