detekt API Documentation

website·Indexed 34 days ago

https://detekt.dev

Technical documentation for detekt, including the detekt-api, detekt-tooling, detekt-psi-utils, and testing utilities. Covers core components such as RuleSet, Config, Entity, and various specification builders for rules, reports, and extensions.

Tokens
669.3K
Snippets
5K
Records
6.3K
Agent score
60%

What's inside detekt

  1. Overview of detekt features

    detekt is a static code analysis tool for Kotlin projects that provides:

    • Code smell analysis and complexity reports (based on lines of code, cyclomatic complexity, and smell count).
    • Highly configurable rule sets and the ability to extend detekt with custom rule sets and reports.
    • Baseline generation to suppress existing issues in legacy projects.
    • Support for @Suppress annotations to ignore issues in specific source files.
    • Multiple report formats: HTML, Markdown, SARIF, and XML (Checkstyle).
    • First-party Gradle plugin integration and a community of third-party plugins.
  2. Overview of detekt features

    detekt is a static code analysis tool for Kotlin projects that provides:

    • Code smell analysis and complexity reports (lines of code, cyclomatic complexity).
    • Highly configurable rule sets and the ability to extend detekt with custom rule sets and reports.
    • Baseline generation to suppress existing issues in legacy projects.
    • Support for suppressing issues via @Suppress annotations.
    • Multiple report formats: HTML, Markdown, SARIF, XML (Checkstyle), and custom reports.
    • First-party Gradle integration and a community of third-party plugins.
  3. Overview of detekt features

    detekt is a static code analysis tool for Kotlin projects that provides the following capabilities:

    • Code smell analysis with highly configurable rule sets.
    • Baseline generation to suppress existing issues in legacy projects while preventing new ones.
    • Issue suppression within source files using @Suppress annotations.
    • Complexity reporting based on lines of code, cyclomatic complexity, and code smell counts.
    • Support for multiple report formats: HTML, Markdown, SARIF, XML (Checkstyle), and custom reports.
    • Extensibility via custom rule sets and reports.
    • First-party Gradle integration and a community of third-party plugins.
  4. Overview of default ktlint rules in detekt

    The following ktlint rules are active by default in detekt 2.0.0-alpha.2:

    • FunKeywordSpacing (since v1.23.0)
    • FunctionTypeModifierSpacing (since v2.0.0)
    • FunctionTypeReferenceSpacing (since v1.23.0)
    • FunctionStartOfBodySpacing (since v1.23.0)
    • Kdoc (since v2.0.0)
    • MixedConditionOperators (since v2.0.0)
    • ModifierOrdering (since v1.0.0)

    The following are disabled by default:

    • FunctionName
    • MultilineExpressionWrapping (Note: detekt uses intellij_idea style by default, whereas ktlint only enables this rule for ktlint_official style or when explicitly enabled).
  5. Overview of basic ktlint rules in detekt

    The following ktlint rules are integrated into detekt. Some are active by default, while others must be explicitly enabled:

    • FunKeywordSpacing: Active since v1.23.0
    • FunctionName: Inactive by default
    • FunctionStartOfBodySpacing: Active since v1.23.0
    • FunctionTypeModifierSpacing: Active since v2.0.0
    • FunctionTypeReferenceSpacing: Active since v1.23.0
    • Kdoc: Active since v2.0.0
    • MixedConditionOperators: Active since v2.0.0
    • ModifierOrdering: Active since v1.0.0 (overlaps with style > ModifierOrder, supports auto-correction)
  6. Overview of detekt features

    detekt is a static code analysis tool for Kotlin projects that provides:

    • Code smell analysis and complexity reports (lines of code, cyclomatic complexity).
    • Highly configurable rule sets and the ability to extend detekt with custom rule sets and reports.
    • Baseline generation to suppress existing issues in legacy projects.
    • Support for @Suppress annotations in source files.
    • Multiple report formats: HTML, Markdown, SARIF, and Checkstyle (XML).
    • First-party Gradle plugin integration and a community of third-party plugins.
  7. Overview of standard ktlint rules in detekt

    The following ktlint rules are available in detekt 2.0.0-alpha.2. Most are active by default since v1.0.0 or v2.0.0:

    • NoBlankLineBeforeRbrace (Active since v1.0.0)
    • NoBlankLineInList (Inactive by default)
    • NoBlankLinesInChainedMethodCalls (Active since v1.22.0)
    • NoConsecutiveBlankLines (Active since v1.0.0)
    • NoConsecutiveComments (Inactive by default)
    • NoEmptyFile (Active since v2.0.0)
    • NoEmptyFirstLineInMethodBlock (Active since v1.22.0)
    • NoLineBreakAfterElse (Active since v1.0.0)
    • NoLineBreakBeforeAssignment (Active since v1.0.0)
    • NoMultipleSpaces (Active since v1.0.0)
    • NoSemicolons (Active since v1.0.0)
    • NoTrailingSpaces (Active since v1.0.0)
    • NoUnitReturn (Active since v1.0.0)
    • NoUnusedImports (Active since v1.0.0)
    • NullableTypeSpacing (Active since v1.23.0)
    • PackageName (Active since v1.22.0)
    • SpacingAroundAngleBrackets (Active since v1.22.0)
    • SpacingAroundColon (Active since v1.0.0)
    • SpacingAroundComma (Active since v1.0.0)
  8. Overview of detekt features

    detekt is a static code analysis tool for Kotlin projects that provides:

    • Code smell analysis with highly configurable rule sets.
    • Baseline generation to suppress existing issues in legacy projects.
    • Issue suppression via @Suppress annotations in source files.
    • Complexity reports based on lines of code, cyclomatic complexity, and code smell counts.
    • Support for multiple report formats: HTML, Markdown, SARIF, and Checkstyle (XML).
    • Extensibility through custom rule sets and reports.
    • First-party Gradle plugin integration and a community of third-party plugins.
  9. Overview of detekt type resolution

    Type resolution is an experimental feature in detekt that allows the tool to perform advanced static analysis by accessing types and symbols available to the Kotlin compiler. While standard analysis only looks at the source code (e.g., detecting a magic number), type resolution allows detekt to understand return types and symbol definitions (e.g., determining if a safe call ?. is actually unnecessary because the return type is non-nullable). This is achieved by providing the compilation classpath to detekt.
  10. Overview of detekt features

    detekt is a static code analysis tool for Kotlin projects. Key capabilities include:

    • Code smell analysis and complexity reports (lines of code, cyclomatic complexity).
    • Highly configurable rule sets and support for custom rule sets and reports.
    • Baseline generation to suppress existing issues in legacy projects.
    • Issue suppression via @Suppress annotations in source files.
    • Multiple report formats: HTML, Markdown, SARIF, XML (Checkstyle), and custom reports.
    • First-party Gradle plugin integration and a community of third-party plugins.
  11. Overview of detekt features

    detekt is a static code analysis tool for Kotlin projects that provides the following capabilities:

    • Code smell analysis with highly configurable rule sets.
    • Baseline generation to suppress existing issues in legacy projects while preventing new ones.
    • Issue suppression via @Suppress annotations in source files.
    • Multiple report formats: HTML, Markdown, SARIF, and Checkstyle (XML).
    • Extensibility through custom rule sets and reports.
    • Complexity reporting based on lines of code, cyclomatic complexity, and code smell counts.
    • First-party Gradle plugin integration and a community of third-party plugins.
  12. Overview of ktlint rules with no configuration

    The following ktlint rules are integrated into detekt. Some are active by default, while others must be explicitly enabled.
    - FunKeywordSpacing: Active by default (v1.23.0)
    - FunctionName: Not active by default
    - FunctionStartOfBodySpacing: Active by default (v1.23.0)
    - FunctionTypeModifierSpacing: Active by default (v2.0.0)
    - FunctionTypeReferenceSpacing: Active by default (v1.23.0)
    - Kdoc: Not active by default
    - MixedConditionOperators: Not active by default
    - ModifierOrdering: Active by default (v1.0.0) - Overlaps with style > ModifierOrder