Skip to content

Commit 0f8ba66

Browse files
committed
include '.' on first line of multiline chained method invocations
This changes where the '.' lives from the second line to the first line in the expression. Having no '.' at the end of the first line makes that line appear to be complete, but you must read ahead to the next line in order to see that the expression continues. This closes issue rubocop#169
1 parent 2529667 commit 0f8ba66

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,16 @@ Translations of the guide are available in the following languages:
309309
- 2
310310
```
311311

312-
* When continuing a chained method invocation on another line keep the `.` on the second line.
312+
* When continuing a chained method invocation on another line, include the `.` on the first line to indicate that the expression continues.
313313

314314
```Ruby
315-
# bad - need to consult first line to understand second line
316-
one.two.three.
317-
four
318-
319-
# good - it's immediately clear what's going on the second line
315+
# bad - need to read ahead to the second line to know that the chain continues
320316
one.two.three
321317
.four
318+
319+
# good - it's immediately clear that the expression continues beyond the first line
320+
one.two.three.
321+
four
322322
```
323323

324324
* Align the parameters of a method call if they span more than one line.

0 commit comments

Comments
 (0)