no-empty-class-body
What it does
Section titled “What it does”Reports a class or interface with { } and nothing in it (class A {}).
Why it matters
Section titled “Why it matters”An empty body adds two characters and says nothing. Kotlin does not need the braces for a class without members.
To fix, delete the braces: class A.
Example
Section titled “Example”class A {}class B { }class C { val x = 1}interface D {}val o = object : Any() {}Configuration
Section titled “Configuration”kotlin: lint: rules: no-empty-class-body: warn # off (default), warn, errorEnabled by the presets: kotlin/ktlint.
Suppress one line with sudsy-disable-next-line no-empty-class-body in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| ktlint | no-empty-class-body |
partial | Comments inside the braces do not count as content. |