detekt

用于 Kotlin 的静态代码分析。「Static code analysis for Kotlin」

Github星跟蹤圖

detekt

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

build status
build status windows
codecov
CodeFactor
FOSSA Status
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 reports based on lines of code, cyclomatic complexity and amount of code smells
  • Highly configurable rule sets
  • Suppression of findings with Kotlin's @Suppress and Java's @SuppressWarnings annotations
  • Specification of quality gates which will break your build
  • Code Smell baseline and whitelisting 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
  • Extensibility by enabling incorporation of personal rule sets, FileProcessListener's and OutputReport's
  • IntelliJ integration
  • Unofficial Maven plugin by Ozsie

Project Website

Visit the project website for installation guides, release notes, migration guides, rule descriptions and configuration options.

Quick Start ...

with the 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

Gradle 5.0+ is required:

buildscript {
    repositories {
        jcenter()
    }

    // or

    mavenCentral()
    jcenter {
        content {
            // just allow to include kotlinx projects
            // detekt needs 'kotlinx-html' for the html report
            includeGroup "org.jetbrains.kotlinx"
        }
    }
}

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

detekt {
    failFast = true // fail build on any finding
    buildUponDefaultConfig = true // preconfigure defaults
    config = files("$projectDir/config/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior
    baseline = file("$projectDir/config/baseline.xml") // a way of suppressing issues before introducing detekt

    reports {
        html.enabled = true // observe findings in your browser with structure and code snippets
        xml.enabled = true // checkstyle like format mainly for integrations like Jenkins
        txt.enabled = true // similar to the console output, contains issue signature to manually edit baseline files
    }
}

tasks {
    withType<Detekt> {
        // Target version of the generated JVM bytecode. It is used for type resolution.
        this.jvmTarget = "1.8"
    }
}

See bintray for releases and artifactory for snapshots.

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

主要指標

概覽
名稱與所有者detekt/detekt
主編程語言Kotlin
編程語言Kotlin (語言數: 7)
平台Linux, Mac, Windows
許可證Apache License 2.0
所有者活动
創建於2016-10-23 21:04:45
推送於2025-04-24 03:49:52
最后一次提交
發布數129
最新版本名稱v1.23.8 (發布於 )
第一版名稱M1 (發布於 2016-10-29 21:15:21)
用户参与
星數6.5k
關注者數60
派生數794
提交數6.3k
已啟用問題?
問題數2682
打開的問題數190
拉請求數4648
打開的拉請求數19
關閉的拉請求數457
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?