Skip to content

Commit 66676eb

Browse files
author
Ivan Carballo
committed
Add more rules around line breaking
1 parent e5be6f5 commit 66676eb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

project_and_code_guidelines.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,24 @@ There are two __exceptions__ where is possible to have lines longer than 100:
431431

432432
There isn't an exact formula that explains how to line-wrap and quite often different solutions are valid. However there are a few rules that can be applied to common cases.
433433

434+
__Break at operators__
435+
436+
When the line is broken at an operator, the break comes __before__ the operator. For example:
437+
438+
```java
439+
int longName = anotherVeryLongVariable + anEvenLongerOne - thisRidiculousLongOne
440+
+ theFinalOne;
441+
```
442+
443+
__Assignment Operator Exception__
444+
445+
An exception to the break at operators rule is the assignment operator `=`, where the line break should happen __after__ the operator.
446+
447+
```java
448+
int longName =
449+
anotherVeryLongVariable + anEvenLongerOne - thisRidiculousLongOne + theFinalOne;
450+
```
451+
434452
__Method chain case__
435453

436454
When multiple methods are chained in the same line - for example when using Builders - every call to a method should go in its own line, breaking the line before the `.`

0 commit comments

Comments
 (0)