AI Decision System
Replayable, offline-verifiable records for AI-assisted go/no-go decisions: experiment promotions, typed model answers and human-approved actions.
翻譯準備中
正在載入完整 README。 以下為已儲存的摘錄。
Meet detekt, a static code analysis tool for the Kotlin programming language.
Visit the project website for installation guides, rule descriptions, configuration options and more.檢視完整 README ↗Meet detekt, a static code analysis tool for the Kotlin programming language. Visit the project website for installation guides, rule descriptions, configuration options and more.
@Suppress annotations.curl -sSLO https://github.com/detekt/detekt/releases/download/v[version]/detekt-cli-[version]-all.jar
java -jar detekt-cli-[version]-all.jar --help
You can find other ways to install detekt here
detekt 2.0 is recommended for its new features, but it is still available only as a pre-release. Use the stable 1.x setup below if your project cannot adopt an alpha release yet.
This example uses the current 2.0.0-alpha.6 release and the Kotlin DSL:
plugins {
id("dev.detekt") version "2.0.0-alpha.6"
}
repositories {
mavenCentral()
}
detekt {
buildUponDefaultConfig = true // preconfigure defaults
allRules = false // do not activate every rule by default
config.setFrom("$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
}
tasks.withType<dev.detekt.gradle.Detekt>().configureEach {
reports {
html.required.set(true) // observe findings in your browser with structure and code snippets
checkstyle.required.set(true) // checkstyle(xml) like format mainly for integrations like Jenkins
sarif.required.set(true) // standardized SARIF format (https://sarifweb.azurewebsites.net/) to support integrations with GitHub Code Scanning
markdown.required.set(true) // simple Markdown format
}
jvmTarget.set("1.8")
}
tasks.withType<dev.detekt.gradle.DetektCreateBaselineTask>().configureEach {
jvmTarget.set("1.8")
}
Use this setup for the latest final 1.x release, 1.23.8:
plugins {
id("io.gitlab.arturbosch.detekt") version "1.23.8"
}
repositories {
mavenCentral()
}
detekt {
buildUponDefaultConfig = true // preconfigure defaults
allRules = false // do not activate every rule by default
config.setFrom("$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
}
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
reports {
html.required.set(true) // observe findings in your browser with structure and code snippets
xml.required.set(true) // checkstyle-compatible XML format, mainly for integrations like Jenkins
sarif.required.set(true) // standardized SARIF format (https://sarifweb.azurewebsites.net/) to support integrations with GitHub Code Scanning
md.required.set(true) // simple Markdown format
}
jvmTarget = "1.8"
}
tasks.withType<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>().configureEach {
jvmTarget = "1.8"
}
See Maven Central for 2.0 releases, Maven Central for 1.x releases, and Sonatype for snapshots.
If you want to use a SNAPSHOT version, you can find more info on this documentation page.
detekt 2.0 requires Gradle 8.14.3 or newer. detekt 1.23.8 requires Gradle 6.8.3 or newer. The recommended versions together with the other tools recommended versions are:
| Detekt Version | Gradle | Kotlin | AGP | Java Target Level | JDK Max Version |
|---|---|---|---|---|---|
2.0.0-alpha.6 | 9.6.1 | 2.4.10 | 9.3.1 | 1.8 | 25 |
2.0.0-alpha.5 | 9.5.1 | 2.4.0 | 9.2.1 | 1.8 | 25 |
2.0.0-alpha.3 | 9.3.1 | 2.3.21 | 9.1.1 | 1.8 | 25 |
2.0.0-alpha.2 | 9.3.0 | 2.3.0 | 9.0.0 | 1.8 | 25 |
2.0.0-alpha.1 | 9.1.0 | 2.2.20 | 8.13.0 | 1.8 | 25 |
2.0.0-alpha.0 | 8.13.0 | 2.2.10 | 8.13.0 | 1.8 | 21 |
1.23.8 | 8.12.1 | 2.0.21 | 8.8.1 | 1.8 | 21 |
The list of recommended versions for previous detekt version is listed here.
Java 17 or higher is required to build detekt.
detekt itself provides a wrapper over ktlint as the ktlint rule set
which can be easily added to the Gradle configuration:
For detekt 2.0.0-alpha.6:
dependencies {
detektPlugins("dev.detekt:detekt-rules-ktlint-wrapper:2.0.0-alpha.6")
}
Similarly, there are extra rule sets available for detekt from detekt:
dependencies {
detektPlugins("dev.detekt:detekt-rules-libraries:2.0.0-alpha.6")
detektPlugins("dev.detekt:detekt-rules-ruleauthors:2.0.0-alpha.6")
}
For detekt 1.23.8, the ktlint wrapper keeps its former detekt-formatting artifact name:
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-libraries:1.23.8")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-ruleauthors:1.23.8")
}
For more info visit the Detekt Marketplace.
Likewise custom extensions can be added to detekt.
See CONTRIBUTING
Thanks to all the people who contributed to detekt!
As mentioned in...
Integrations:
Custom rules and reports from 3rd parties can be found on our Detekt Marketplace.