statement-wrapping
What it does
Section titled “What it does”Reports a block whose line breaks the formatter would change, such as several statements on one line ({ a(); b() }).
Why it matters
Section titled “Why it matters”One statement to a line is the layout every Kotlin reader expects, and a second statement after a ; is easily missed. It also makes a diff show a change to the statement and not to its neighbour.
To fix, run the formatter.
Example
Section titled “Example”fun f(x: Int) { val a = if (x > 0)... val b = when (x) { 1 -> { println(1) }... } foo(); bar() val c = someVeryLongReceiverName.firstFunctionCall(argumentNumberOne).secondFunctionCall(argumentNumberTwo).thirdFunctionCall(argumentNumberThree) callTheFunction(argumentNumberOne, argumentNumberTwo, argumentNumberThree, argumentNumberFour, argumentNumberFive, argumentNumberSix, argumentNumberSeven)}Configuration
Section titled “Configuration”kotlin: lint: rules: statement-wrapping: warn # off (default), warn, errorEnabled by the presets: kotlin/ktlint.
Suppress one line with sudsy-disable-next-line statement-wrapping in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ktlint | statement-wrapping |
full |