Skip to content

Commit

Permalink
Merge pull request rubocop#258 from jonas054/trailing_comma
Browse files Browse the repository at this point in the history
Add rules about trailing commas.
  • Loading branch information
bbatsov committed Jan 11, 2014
2 parents 0a9f590 + 6508a25 commit 0521975
Showing 1 changed file with 36 additions and 0 deletions.
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

0 comments on commit 0521975

Please sign in to comment.