Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Done
-
None
-
None
Description
Breaking the line of too long statements (line longness is yet to be fully defined) to improve code readability in case of
- Long function argument lists (declaration or call): void func(type1 arg1, type2 arg2, ...)
- Long sequence of chained calls: list.stream().map(...).reduce(...).collect(...)...
Rules:
- Break the list of arguments/calls if the line exceeds limit or earlier if you believe that the breaking would improve the code readability
- If you break the line then each argument/call should have a separate line, including the first one
- Each new line argument/call should have one extra indentation relative to the line of the parent function name or called entity
- The opening parenthesis always stays on the line of the parent function name
- The possible thrown exception list is never broken and stays on the same last line
- The dot of a chained call is always on the line of that chained call proceeding the call at the beginning
Examples of breaking:
- Function arguments
public void func( int arg1, int arg2, ...) throws E1, E2, E3 { }
- Chained method calls:
values .stream() .map(...) .collect(...);