Skip to content

Instantly share code, notes, and snippets.

@laithnurie
Created August 18, 2022 15:07
Show Gist options
  • Save laithnurie/71f0cfa75b2bd81655f62d3d930b0965 to your computer and use it in GitHub Desktop.
Save laithnurie/71f0cfa75b2bd81655f62d3d930b0965 to your computer and use it in GitHub Desktop.
Detekt gradle methods
tasks.register('detektFix', io.gitlab.arturbosch.detekt.Detekt) {
description = "Runs over whole code base without the starting overhead for each module."
autoCorrect = true
parallel = true
setSource(files(projectDir))
include("**/*.kt")
include("**/*.kts")
exclude("**/resources/**")
exclude("**/build/**")
exclude("**/test/**/*.kt")
config.from(files("$rootDir/config/detekt/detekt.yml"))
// point to your custom config defining rules to run, overwriting default behavior
baseline.set(file("$rootDir/config/detekt/detekt-baseline.xml"))
// a way of suppressing issues before introducing detekt
failFast = true // fail build on any finding
buildUponDefaultConfig = true // preconfigure defaults
reports {
xml.enabled = false
html.enabled = true
}
}
tasks.register('detektCheck', io.gitlab.arturbosch.detekt.Detekt) {
description = "Runs over whole code base without the starting overhead for each module."
autoCorrect = false
parallel = true
setSource(files(projectDir))
include("**/*.kt")
include("**/*.kts")
exclude("**/resources/**")
exclude("**/build/**")
exclude("**/test/**/*.kt")
config.from(files("$rootDir/config/detekt/detekt.yml"))
// point to your custom config defining rules to run, overwriting default behavior
baseline.set(file("$rootDir/config/detekt/detekt-baseline.xml"))
// a way of suppressing issues before introducing detekt
failFast = true // fail build on any finding
buildUponDefaultConfig = true // preconfigure defaults
reports {
xml.enabled = false
html.enabled = true
}
}
tasks.register('detektAllBaseline', io.gitlab.arturbosch.detekt.DetektCreateBaselineTask) {
description = "Overrides current baseline."
ignoreFailures.set(true)
parallel.set(true)
setSource(files(rootDir))
config.from(files("$rootDir/config/detekt/detekt.yml"))
// point to your custom config defining rules to run, overwriting default behavior
baseline.set(file("$rootDir/config/detekt/detekt-baseline.xml"))
// a way of suppressing issues before introducing detekt
include("**/*.kt")
include("**/*.kts")
exclude("**/build/**")
exclude("**/buildSrc/**")
exclude("**/test/**/*.kt")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment