Skip to content

blank-line-between-declarations

Kotlinstyleno fixdefault: offkotlin/ktlint

Reports a declaration (function, property, class, object, typealias) with a blank line before it that the formatter would add or remove. Declarations with comments or annotations before them are included.

Blank lines show where one declaration ends and the next one begins. A file that is consistent shows the structure at a glance, and a formatter that keeps the same spacing does not turn up as a diff on each save.

To fix, run the formatter.

Reported
val a = 1
// about b
val b = 2
@Deprecated("x")
...
kotlin:
lint:
rules:
blank-line-between-declarations: warn # off (default), warn, error

Enabled by the presets: kotlin/ktlint.

Suppress one line with sudsy-disable-next-line blank-line-between-declarations 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 spacing-between-declarations-with-annotations full
ktlint spacing-between-declarations-with-comments full