Skip to main content
Version: 2.0.0-alpha.0

Formatting Rule Set

This rule set provides wrappers for rules implemented by ktlint - https://ktlint.github.io/ktlint/.

Note: The formatting rule set is not included in the detekt-cli or Gradle plugin.

To enable this rule set, add detektPlugins "dev.detekt:detekt-rules-ktlint-wrapper:$version" to your gradle dependencies or reference the detekt-rules-ktlint-wrapper-jar with the --plugins option in the command line interface.

Note: Issues reported by this rule set can only be suppressed on file level (@file:Suppress("detekt.rule")).

AnnotationOnSeparateLine​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

AnnotationSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

ArgumentListWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

  • ignoreRuleParameterThreshold (default: 8)

    parameter threshold to ignore rule

BackingPropertyNaming​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

BinaryExpressionWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

  • indentSize (default: 4)

    indentation size

BlankLineBeforeDeclaration​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

BlankLineBetweenWhenConditions​

See ktlint docs for documentation.

Active by default: No

Configuration options:​

  • lineBreakAfterWhenEntries (default: true)

    require line breaks after multiline entries

BlockCommentInitialStarAlignment​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

ChainMethodContinuation​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

  • forceMultilineWhenChainOperatorCountGreaterOrEqualThan (default: 4)

    chain operator count means multiline threshold

ChainWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

ClassName​

See ktlint docs for documentation.

Active by default: No

ClassSignature​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

CommentSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

CommentWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

ConditionWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

ContextReceiverListWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

  • indentSize (default: 4)

    indentation size

ContextReceiverMapping​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

  • indentSize (default: 4)

    indentation size

EnumEntryNameCase​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

Aliases: EnumEntryName

Configuration options:​

  • enumEntryNameCasing (default: 'upper_or_camel_cases')

    enum entry naming casing

EnumWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

ExpressionOperandWrapping​

See ktlint docs for documentation.

Active by default: No

Configuration options:​

  • indentSize (default: 4)

    indentation size

Filename​

See ktlint docs for documentation.

This rules overlaps with naming>MatchingDeclarationName from the standard rules, make sure to enable just one.

Active by default: Yes - Since v1.0.0

FinalNewline​

See ktlint docs for documentation.

This rules overlaps with style>NewLineAtEndOfFile from the standard rules, make sure to enable just one. The pro of this rule is that it can auto-correct the issue.

Active by default: Yes - Since v1.0.0

Configuration options:​

  • insertFinalNewLine (default: true)

    report absence or presence of a newline

FunKeywordSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

FunctionExpressionBody​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

FunctionLiteral​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

FunctionName​

See ktlint docs for documentation.

Active by default: No

FunctionReturnTypeSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

Configuration options:​

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

FunctionSignature​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • forceMultilineWhenParameterCountGreaterOrEqualThan (default: 2147483647)

    parameter count means multiline threshold

  • functionBodyExpressionWrapping (default: 'default')

    indentation size

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

  • indentSize (default: 4)

    indentation size

FunctionStartOfBodySpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

FunctionTypeModifierSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

FunctionTypeReferenceSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

IfElseBracing​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

IfElseWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

ImportOrdering​

See ktlint docs for documentation.

For defining import layout patterns see the KtLint Source Code

Active by default: Yes - Since v1.19.0

Configuration options:​

  • layout (default: '*,java.**,javax.**,kotlin.**,^') (android default: '*')

    the import ordering layout

Indentation​

See ktlint docs for documentation.

Active by default: Yes - Since v1.19.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • indentWhenArrowOnNewLine (default: false)

    indent when arrow on new line

Kdoc​

See ktlint docs for documentation.

Active by default: No

KdocWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

MaximumLineLength​

See ktlint docs for documentation.

This rules overlaps with style>MaxLineLength from the standard rules, make sure to enable just one or keep them aligned.

Active by default: Yes - Since v1.0.0

Aliases: MaxLineLength

Configuration options:​

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

  • ignoreBackTickedIdentifier (default: false)

    ignore back ticked identifier

MixedConditionOperators​

See ktlint docs for documentation.

Active by default: No

ModifierListSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

ModifierOrdering​

See ktlint docs for documentation.

This rules overlaps with style>ModifierOrder from the standard rules, make sure to enable just one. The pro of this rule is that it can auto-correct the issue.

Active by default: Yes - Since v1.0.0

MultiLineIfElse​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

MultilineExpressionWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • functionBodyExpressionWrapping (default: 'multiline')

    function body expression wrapping

MultilineLoop​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

NoBlankLineBeforeRbrace​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

NoBlankLineInList​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

NoBlankLinesInChainedMethodCalls​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

NoConsecutiveBlankLines​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

NoConsecutiveComments​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

NoEmptyClassBody​

See ktlint docs for documentation.

This rules overlaps with empty-blocks>EmptyClassBlock from the standard rules, make sure to enable just one.

Active by default: Yes - Since v1.0.0

NoEmptyFile​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

NoEmptyFirstLineInClassBody​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

NoEmptyFirstLineInMethodBlock​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

NoLineBreakAfterElse​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

NoLineBreakBeforeAssignment​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

NoMultipleSpaces​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

NoSemicolons​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

NoSingleLineBlockComment​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

NoTrailingSpaces​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

NoUnitReturn​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

NoUnusedImports​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

NoWildcardImports​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

Configuration options:​

  • packagesToUseImportOnDemandProperty (default: 'java.util.*,kotlinx.android.synthetic.**')

    Defines allowed wildcard imports

NullableTypeSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

PackageName​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

ParameterListSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

ParameterListWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

Configuration options:​

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

  • indentSize (default: 4)

    indentation size

ParameterWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

PropertyName​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • constantNamingStyle (default: 'screaming_snake_case')

    The naming style ('screaming_snake_case', or 'pascal_case') to be applied on constant properties.

PropertyWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • maxLineLength (default: 120) (android default: 100)

    maximum line length

SpacingAroundAngleBrackets​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

SpacingAroundColon​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

SpacingAroundComma​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

SpacingAroundCurly​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

SpacingAroundDot​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

SpacingAroundDoubleColon​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

SpacingAroundKeyword​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

SpacingAroundOperators​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

SpacingAroundParens​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

SpacingAroundRangeOperator​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

SpacingAroundSquareBrackets​

See ktlint docs for documentation.

Active by default: No

SpacingAroundUnaryOperator​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

SpacingBetweenDeclarationsWithAnnotations​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

SpacingBetweenDeclarationsWithComments​

See ktlint docs for documentation.

Active by default: Yes - Since v1.22.0

SpacingBetweenFunctionNameAndOpeningParenthesis​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

StatementWrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

StringTemplate​

See ktlint docs for documentation.

Active by default: Yes - Since v1.0.0

StringTemplateIndent​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

TrailingCommaOnCallSite​

See ktlint docs for documentation.

The default config comes from ktlint and follows these conventions:

Active by default: Yes - Since v2.0.0

Configuration options:​

  • useTrailingCommaOnCallSite (default: true) (android default: false)

    Defines whether trailing commas are required (true) or forbidden (false) at call sites

TrailingCommaOnDeclarationSite​

See ktlint docs for documentation.

The default config comes from ktlint and follows these conventions:

Active by default: Yes - Since v2.0.0

Configuration options:​

  • useTrailingCommaOnDeclarationSite (default: true) (android default: false)

    Defines whether trailing commas are required (true) or forbidden (false) at declaration sites

TryCatchFinallySpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

TypeArgumentComment​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

TypeArgumentListSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

TypeParameterComment​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

TypeParameterListSpacing​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

UnnecessaryParenthesesBeforeTrailingLambda​

See ktlint docs for documentation.

Active by default: Yes - Since v1.23.0

ValueArgumentComment​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

ValueParameterComment​

See ktlint docs for documentation.

Active by default: Yes - Since v2.0.0

WhenEntryBracing​

See ktlint docs for documentation.

Active by default: No

Configuration options:​

  • indentSize (default: 4)

    indentation size

Wrapping​

See ktlint docs for documentation.

Active by default: Yes - Since v1.20.0

Configuration options:​

  • indentSize (default: 4)

    indentation size

  • maxLineLength (default: 120) (android default: 100)

    maximum line length