Programming Search⌘K

Kotlin lints, page 1 of 2

The lint rules of Kotlin, with what each one finds. This page has 219 cards.

Mark forbidden imports. ForbiddenImport

A forbidden import could be an import for an unstable / experimental api and hence you might want to mark it as forbidden in order to get warned about the usage. It is in the style rule set. detekt does not run it by default.

Code
ForbiddenImport

Source: github.com, detekt.dev. JSON record. This entry is a card. Help write this page.

Mark forbidden methods. ForbiddenMethodCall

A forbidden method could be an invocation of an unstable / experimental method and hence you might want to mark it as forbidden in order to get warned about the usage. It is in the style rule set. detekt does not run it by default. It needs type resolution.

Code
ForbiddenMethodCall

Source: github.com, detekt.dev. JSON record. This entry is a card. Help write this page.

Report magic numbers. MagicNumber

Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. It is in the style rule set. detekt runs it by default since 1.0.0.

Code
MagicNumber

Source: github.com, detekt.dev. JSON record. This entry is a card. Help write this page.

Exceptions that cannot be recreated by the coroutine stack trace recovery mechanism lose their original stack trace when rethrown from another coroutine. MissingStackTraceRecoverable

Avoid instance fields, provide a public constructor taking only a message, a cause, both or no arguments, or implement kotlin.coroutines.debug.StackTraceRecoverable. It is in the coroutines rule set. detekt does not run it by default. It needs type resolution.

Code
MissingStackTraceRecoverable

Source: github.com, detekt.dev. JSON record. This entry is a card. Help write this page.

An object should not extend any type of Throwable. ObjectExtendsThrowable

Throwables are stateful and should be instantiated only when needed for when a specific error occurs. An object, being a singleton, that extends any type of Throwable consequently introduces a global singleton exception whose instance may be inadvertently reused from multiple places, thus introducing shared mutable state. It is in the exceptions rule set. detekt runs it by default since 2.0.0. It needs type resolution.

Code
ObjectExtendsThrowable

Source: github.com, detekt.dev. JSON record. This entry is a card. Help write this page.