facebook pixelCodiga Analysis Kotlin Rules
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.EmptyWhileBlock

Design
Informational

This empty block of code can be removed.

detekt.EnumNaming

Error prone
Informational

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

detekt.ExplicitGarbageCollectionCall

Performance
Critical

An explicit call to the Garbage Collector as in System should not be made.

detekt.ForbiddenComment

Code style
Informational

This comment contains text that has been defined as forbidden in detekt.

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.FunctionOnlyReturningConstant

Design
Warning

Function is returning a constant. Prefer declaring a constant instead.

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.LargeClass

Design
Error

Detect classes that are too large

detekt.LongMethod

Design
Warning

Function is too long

detekt.LongParameterList

Design
Warning

Too many parameters

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.MaxLineLength

Design
Warning

Line is too long

detekt.MayBeConst

Design
Error

Refactor into a const

detekt.MemberNameEqualsClassName

Best practice
Warning

Name confusion

detekt.ModifierOrder

Error prone
Informational

Incorrect modifier order

detekt.NestedBlockDepth

Best practice
Warning

Function nested too deeply.

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.ReturnCount

Best practice
Informational

Function has 3 return statements which exceeds the limit of 2.

detekt.SpreadOperator

Best practice
Informational

In most cases using a spread operator causes a full copy of the array to be created before calling a method which has a very high performance penalty.

detekt.ThrowsCount

Best practice
Warning

Too many throw statements in function.

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.TooManyFunctions

Design
Warning

Too many functions in object

detekt.TopLevelPropertyNaming

Best practice
Warning

Top level constant names should match the pattern: [A-Z][\_A-Z0-9]*

detekt.UnnecessaryAbstractClass

Best practice
Warning

An abstract class without a concrete member can be refactored to an interface.

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.EmptyInitBlock

Best practice
Warning

Reports empty init expressions. Empty blocks of code serve no purpose and should be removed.

detekt.ImplicitDefaultLocale

Error prone
Warning

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

detekt.ExceptionRaisedInUnexpectedLocation

Safety
Warning

This method is not expected to throw exceptions. This can cause weird behavior.

detekt.UnusedPrivateMember

Best practice
Informational

Function parameter is unused

detekt.PrintStackTrace

Best practice
Warning

Instead of simply printing a stacktrace a better logging solution should be used.

detekt.SerialVersionUIDInSerializableClass

Code style
Error

Classes which implement the Serializable interface should also correctly declare a serialVersionUID

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.

detekt.EqualsAlwaysReturnsTrueOrFalse

Best practice
Warning

Equals methods should always report if some other object is equal to the current object