|
| 1 | +import io.gitlab.arturbosch.detekt.Detekt |
| 2 | +import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask |
| 3 | + |
1 | 4 | // TODO: change the hardcoded 1.6.10 to kotlinVeresion that lives in project props
|
2 | 5 | // We could use a buildSrc script for this.
|
3 | 6 | // See: https://github.com/gradle/kotlin-dsl-samples/issues/802
|
4 | 7 | plugins {
|
5 | 8 | kotlin("jvm") version "1.8.10"
|
6 | 9 | `maven-publish`
|
| 10 | + id("io.gitlab.arturbosch.detekt") version "1.22.0" |
7 | 11 | }
|
8 | 12 |
|
9 | 13 | repositories {
|
@@ -33,3 +37,49 @@ configure(subprojects.filter { it.name != "grammars" }) {
|
33 | 37 | }
|
34 | 38 | }
|
35 | 39 | }
|
| 40 | + |
| 41 | +detekt { |
| 42 | + allRules = false // activate all available (even unstable) rules. |
| 43 | + buildUponDefaultConfig = true // preconfigure defaults |
| 44 | + parallel = true |
| 45 | + config = files("$rootDir/detekt.yml") |
| 46 | + baseline = file("$rootDir/detekt_baseline.xml") |
| 47 | + source = files(projectDir) |
| 48 | +} |
| 49 | + |
| 50 | +// Registers a baseline for Detekt. |
| 51 | +// |
| 52 | +// The way it works is that you set create "baseline" for Detekt |
| 53 | +// by running this task. It will then creatae a detekt-baseline.xml which |
| 54 | +// contains a list of current issues found within the project. |
| 55 | +// Then every time you run the "detekt" task it will only report errors |
| 56 | +// that are not in the baseline config. |
| 57 | +// |
| 58 | +// We should routinely run this task and commit the baseline file as we |
| 59 | +// fix detekt issues so that we can prevent regressions. |
| 60 | +tasks.register<DetektCreateBaselineTask>("createDetektBaseline") { |
| 61 | + description = "Overrides current baseline." |
| 62 | + buildUponDefaultConfig.set(true) |
| 63 | + ignoreFailures.set(true) |
| 64 | + parallel.set(true) |
| 65 | + setSource(files(projectDir)) |
| 66 | + config.setFrom(files("$rootDir/detekt.yml")) |
| 67 | + baseline.set(file("$rootDir/detekt_baseline.xml")) |
| 68 | + include("**/*.kt") |
| 69 | + include("**/*.kts") |
| 70 | + exclude("shared/build/**/*.*") |
| 71 | + exclude("server/build/**/*.*") |
| 72 | +} |
| 73 | + |
| 74 | +tasks.withType<Detekt>().configureEach { |
| 75 | + reports { |
| 76 | + html.required.set(true) |
| 77 | + md.required.set(true) |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +tasks.withType<Detekt>().configureEach { |
| 82 | + jvmTarget = "11" |
| 83 | +} |
| 84 | + |
| 85 | +tasks.check.get().dependsOn(tasks.detekt) |
0 commit comments