detekt

Join the chat at https://kotlinlang.slack.com/messages/C88E12QH4/convo/C0BQ5GZ0S-1511956674.000289/ Visit the website at https://arturbosch.github.io/detekt/ build status build status windows codecov Download gradle plugin

All Contributors Awesome Kotlin Badge

Meet detekt, a static code analysis tool for the Kotlin programming language. It operates on the abstract syntax tree provided by the Kotlin compiler.

detekt in action

Features

  • Code smell analysis for your Kotlin projects
  • Complexity report based on logical lines of code, McCabe complexity and amount of code smells
  • Highly configurable
  • Suppress findings with Kotlin’s @Suppress and Java’s @SuppressWarnings annotations
  • Specify code smell thresholds to break your build
  • Code Smell baseline and ignore lists for legacy projects
  • Gradle plugin for code analysis via Gradle builds
  • Gradle tasks to use local IntelliJ distribution for formatting and inspecting Kotlin code
  • SonarQube integration
  • Extensible by own rule sets, FileProcessListener's and OutputReport's
  • IntelliJ integration
  • Unofficial Maven plugin by Ozsie

Project Website

Visit https://arturbosch.github.io/detekt/ for installation guides, release notes, migration guides, rule descriptions and configuration options.

  • Changelog and migration guides: https://arturbosch.github.io/detekt/changelog.html
  • Available CLI options: https://arturbosch.github.io/detekt/cli.html
  • Rule set and rule descriptions: https://arturbosch.github.io/detekt/complexity.html
  • Writing custom rules and extending detekt: https://arturbosch.github.io/detekt/extensions.html
  • Suppressing findings? https://arturbosch.github.io/detekt/suppressing-rules.html https://arturbosch.github.io/detekt/baseline.html
  • Configuring detekt? https://arturbosch.github.io/detekt/configurations.html
  • Sample gradle integrations examples
    • multi project (kotlin dsl): https://github.com/arturbosch/detekt/blob/master/build.gradle.kts
    • single project (groovy dsl): https://github.com/arturbosch/kutils/blob/master/build.gradle
    • single project (unofficial maven plugin): https://github.com/arturbosch/sonar-kotlin/blob/master/pom.xml

Quick Start …

with command-line interface

  • git clone https://github.com/arturbosch/detekt
  • cd detekt
  • ./gradlew build shadowJar
  • java -jar detekt-cli/build/libs/detekt-cli-[version]-all.jar --help

with gradle

buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id("io.gitlab.arturbosch.detekt").version("[version]")
}

detekt {
    toolVersion = "[version]"
    input = files("src/main/kotlin")
    filters = ".*/resources/.*,.*/build/.*"
}

Adding more rule sets

detekt itself provides a wrapper over KtLint as a formatting rule set which can be easily added to the gradle configuration:

dependencies {
    detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:[version]"
}

Likewise custom extensions can be added to detekt.

Contributors

If you contributed to detekt but your name is not in the list, please feel free to add yourself to it!

Mentions

androidweekly androidweekly

As mentioned in…

Integrations:

Credits

compile "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0.RC9.2"

Related Libraries

kotlin-argparser

Last updated 3 mins ago

repoverse-kotlin

Last updated 3 mins ago

solid-kotlin-analytics

Last updated 3 mins ago

ktlint

Last updated 3 mins ago

ts2kt

Last updated 3 mins ago