Skip to content

class-naming

Kotlinstyleno fixdefault: offkotlin/ktlint

Reports a class, interface or object whose name starts with a lowercase letter or an underscore.

Kotlin follows the convention that types are in PascalCase, so a lowercase name reads as a variable or a function and is mistaken for one at the call site.

To fix, rename the class to PascalCase.

Reported
class my_class
class Good
interface other
object lower
object Fine
class `a name`
kotlin:
lint:
rules:
class-naming: warn # off (default), warn, error

Enabled by the presets: kotlin/ktlint.

Suppress one line with sudsy-disable-next-line class-naming in a comment of the file’s language.

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 class-naming partial Names in backticks are accepted; no test-file exceptions.