Skip to content

Commit

Permalink
[rubocop#169 rubocop#176] Acknowledge trailing . as a good style as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Bozhidar Batsov committed Feb 18, 2014
1 parent cf921bf commit 36ab365
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,33 @@ Translations of the guide are available in the following languages:
' and second part of the long string'
```

* When continuing a chained method invocation on another line keep the `.` on the second line.
* Adopt a consistent multi-line method chaining style. There are two
popular styles in the Ruby community, both of which are considered
good - leading `.` and trailing `.`.

```Ruby
# bad - need to consult first line to understand second line
one.two.three.
four
* When continuing a chained method invocation on another line keep the `.` on the second line.

# good - it's immediately clear what's going on the second line
one.two.three
.four
```
```Ruby
# bad - need to consult first line to understand second line
one.two.three.
four
# good - it's immediately clear what's going on the second line
one.two.three
.four
```

* When continuing a chained method invocation on another line, include the `.` on the first line to indicate that the expression continues.

```Ruby
# bad - need to read ahead to the second line to know that the chain continues
one.two.three
.four
# good - it's immediately clear that the expression continues beyond the first line
one.two.three.
four
```

* Align the parameters of a method call if they span more than one
line. When aligning parameters is not appropriate due to line-length
Expand Down

0 comments on commit 36ab365

Please sign in to comment.