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

Add rules about trailing commas. #258

Merged
merged 1 commit into from
Jan 11, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,24 @@ Translations of the guide are available in the following languages:
end
```

* Avoid comma after the last parameter in a method definition or call,
especially when the parameters are not on separate lines.

```Ruby
# bad - easier to move/add/remove parameters, but still not preferred
def some_method(
size,
count,
color,
)

# bad
def some_method(size, count, color, )

# good
def some_method(size, count, color)
```

* Use spaces around the `=` operator when assigning default values to method parameters:

```Ruby
Expand Down Expand Up @@ -2104,6 +2122,24 @@ this rule only to arrays with two or more elements.
STATES = %i(draft open closed)
```

* Avoid comma after the last item of an `Array` or `Hash` literal, especially
when the items are not on separate lines.

```Ruby
# bad - easier to move/add/remove items, but still not preferred
VALUES = [
1001,
2020,
3333,
]

# bad
VALUES = [1001, 2020, 3333, ]

# good
VALUES = [1001, 2020, 3333]
```

* Avoid the creation of huge gaps in arrays.

```Ruby
Expand Down