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

Design
Warning

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

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

Design
Warning

Line is too long

detekt.MemberNameEqualsClassName

Best practice
Warning

Name confusion

detekt.NestedBlockDepth

Best practice
Warning

Function nested too deeply.

detekt.PackageNaming

Error prone
Warning

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

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

Best practice
Warning

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

Learn more

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

Best practice
Warning

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

detekt.SwallowedException

Error prone
Warning

Exceptions should not be swallowed.

detekt.EqualsAlwaysReturnsTrueOrFalse

Best practice
Warning

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

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.