BACK TO LIST

Kotlin rules

Codiga provides multiple sets of rules for 12+ languages. Below we provide a link and a description for all the rules supported by our platform. Note that not all the rules are being listed and described below.

detekt.ArrayPrimitive

Error prone
Informational

Using Array<Primitive> leads to implicit boxing and a performance hit

detekt.ClassNaming

Error prone
Informational

Class and Object names should match the pattern: [A-Z][a-zA-Z0-9]*

detekt.ComplexCondition

Error prone
Error

Condition is too complex

detekt.ComplexMethod

Error prone
Informational

Function too complex.

detekt.ConstructorParameterNaming

Error prone
Informational

Constructor private parameter names should match the pattern: [a-z][A-Za-z0-9]*

detekt.DuplicateCaseInWhenExpression

Error prone
Informational

When expression has multiple case statements for the same value

detekt.EmptyCatchBlock

Error prone
Informational

Empty catch block detected. If the exception can be safely ignored

detekt.EmptyClassBlock

Error prone
Informational

The class or object Attempts is empty.

detekt.EmptyDefaultConstructor

Error prone
Informational

An empty default constructor can be removed.

detekt.EmptyKtFile

Error prone
Informational

Detect empty files

detekt.EmptyWhenBlock

Error prone
Informational

This when block is empty.

detekt.EnumNaming

Error prone
Informational

Enum entry names should match the pattern: [A-Z][\_a-zA-Z0-9]*

detekt.ForEachOnRange

Error prone
Informational

Using the forEach method on ranges has a heavy performance cost. Prefer using simple for loops.

detekt.FunctionNaming

Error prone
Informational

Function names should match the pattern: ([a-z][a-zA-Z0-9]*)|(`.*`)

detekt.FunctionParameterNaming

Error prone
Informational

Function parameter names should match the pattern: [a-z][A-Za-z0-9]*

detekt.IteratorNotThrowingNoSuchElementException

Error prone
Informational

This implementation of Iterator does not correctly implement the next() method as it doesn't throw a NoSuchElementException when no elements remain in the Iterator.

detekt.LoopWithTooManyJumpStatements

Error prone
Warning

Too many jump statements

detekt.MagicNumber

Error prone
Warning

Replace magic numbers with a constant

detekt.MatchingDeclarationName

Error prone
Informational

The file name 'does not match the name of the single top-level declaration

detekt.ModifierOrder

Error prone
Informational

Incorrect modifier order

detekt.ObjectPropertyNaming

Error prone
Informational

Object constant names should match the pattern: [A-Za-z][\_A-Za-z0-9]*

detekt.OptionalAbstractKeyword

Error prone
Informational

The abstract keyword on this declaration is unnecessary.

detekt.PackageNaming

Error prone
Warning

Package name should match the pattern: [a-z]+(\\.[a-z][A-Za-z0-9]*)*

detekt.ProtectedMemberInFinalClass

Error prone
Informational

Member with protected visibility in final class is private. Consider using private or internal as modifier.

detekt.TooGenericExceptionCaught

Error prone
Warning

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

detekt.TooGenericExceptionThrown

Error prone
Informational

Throwable is a too generic Exception. Prefer throwing specific exceptions that indicate a specific error case.

detekt.UnreachableCode

Error prone
Informational

This expression is followed by unreachable code which should either be used or removed.

detekt.UtilityClassWithPublicConstructor

Error prone
Informational

The class only contains utility functions. Consider defining it as an object.

detekt.VariableNaming

Error prone
Informational

Private variable names should match the pattern: (\_)?[a-z][A-Za-z0-9]*

detekt.WildcardImport

Error prone
Informational

Use qualified import

detekt.EmptyElseBlock

Error prone
Error

Empty block of code can be removed.

Learn more

detekt.EmptyFunctionBlock

Error prone
Error

Empty function block can be removed

detekt.EmptyIfBlock

Error prone
Error

Empty if block can be removed

detekt.EmptySecondaryConstructor

Error prone
Error

Empty secondary constructor can be removed

detekt.EqualsWithHashCodeExist

Error prone
Error

A class should always override hashCode when overriding equals and the other way around.

detekt.ImplicitDefaultLocale

Error prone
Warning

String.format() uses implicitly default locale for string formatting.

detekt.SwallowedException

Error prone
Warning

Exceptions should not be swallowed.

detekt.ThrowingExceptionsWithoutMessageOrCause

Error prone
Error

Exceptions should always call one of the constructor overloads to provide a message or a cause.

We use cookies to improve your site experience, including analytics cookies to understand how you use our product and design better experiences. Please read our Cookie Policy.