multiline-if-else
What it does
Section titled “What it does”Reports an if whose line breaks the formatter would change.
Why it matters
Section titled “Why it matters”An if and else that are split over lines in an arbitrary way are hard to read, and a line added to a branch that has no braces is not part of it. One layout for every if avoids both.
To fix, run the formatter.
Example
Section titled “Example”fun f(x: Int) { val a = if (x > 0) 1 else 2...Configuration
Section titled “Configuration”kotlin: lint: rules: multiline-if-else: warn # off (default), warn, errorEnabled by the presets: kotlin/ktlint.
Suppress one line with sudsy-disable-next-line multiline-if-else 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 | if-else-wrapping |
full |
| ktlint | multiline-if-else |
full |