Skip to content

when-entry-bracing

Kotlinstyleno fixdefault: offkotlin/ktlint

Reports a when entry whose first line the formatter would change.

Entries of one when that are written in different ways (some with braces, some without, in different line layouts) look as if the difference meant something. One layout for all entries makes a real difference stand out.

To fix, run the formatter.

Reported
...
else -> println(2)
}
foo(); bar()
...
kotlin:
lint:
rules:
when-entry-bracing: warn # off (default), warn, error

Enabled by the presets: kotlin/ktlint.

Suppress one line with sudsy-disable-next-line when-entry-bracing in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ktlint when-entry-bracing full