Skip to content

Commit 8dc9c17

Browse files
committed
build: replace custom detekt rules with official ones
This commit replaces our custom AvoidNonNullAssertionOperator detekt rule with the official rules such as UnsafeCallOnNullableType. These rules were not active because we executed detekt without type resolution. The GitHub workflow is now updated to use the detekt tasks that enable type resolution. As detekt runs with type resolution use source sets to find file to lint for, some manual exclusions for generated content or non-jar files in case of the MPS fileTree had to be added.
1 parent 854f72c commit 8dc9c17

File tree

12 files changed

+22
-148
lines changed

12 files changed

+22
-148
lines changed

.detekt.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
config:
2+
validation: true
3+
14
style:
25
# handled by ktlint
36
MaxLineLength:
@@ -26,7 +29,3 @@ comments:
2629
potential-bugs:
2730
CastNullableToNonNullableType:
2831
active: true
29-
30-
modelix:
31-
AvoidNonNullAssertionOperator:
32-
active: true

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Build
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
run: ./gradlew --build-cache build detekt detektJsMain detektJsTest detektJvmMain detektJvmTest :koverHtmlReport :koverXmlReport -PciBuild=true
35+
run: ./gradlew --build-cache build detektMain detektTest detektJsMain detektJsTest detektJvmMain detektJvmTest :koverHtmlReport :koverXmlReport -PciBuild=true
3636
- name: Publish test results
3737
uses: EnricoMi/publish-unit-test-result-action@v2
3838
# Also report in case the build failed

build.gradle.kts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,26 +153,20 @@ subprojects {
153153
}
154154

155155
// Configure detekt including our custom rule sets
156-
if (project.name != "detekt-rules") {
157-
apply(plugin = "io.gitlab.arturbosch.detekt")
158-
dependencies {
159-
detektPlugins(project(":detekt-rules"))
156+
apply(plugin = "io.gitlab.arturbosch.detekt")
157+
tasks.withType<Detekt> {
158+
reports {
159+
sarif.required.set(true)
160+
html.required.set(true)
160161
}
161-
tasks.withType<Detekt> {
162-
dependsOn(":detekt-rules:assemble")
163-
164-
parallel = true
165-
// For now, we only use the results here as hints
166-
ignoreFailures = true
167-
168-
buildUponDefaultConfig = true
169-
config.setFrom(parentProject.projectDir.resolve(".detekt.yml"))
162+
}
163+
detekt {
164+
parallel = true
165+
// For now, we only use the results here as hints
166+
ignoreFailures = true
170167

171-
reports {
172-
sarif.required.set(true)
173-
html.required.set(true)
174-
}
175-
}
168+
buildUponDefaultConfig = true
169+
config.setFrom(parentProject.projectDir.resolve(".detekt.yml"))
176170
}
177171
}
178172

detekt-rules/build.gradle.kts

Lines changed: 0 additions & 15 deletions
This file was deleted.

detekt-rules/src/main/kotlin/org/modelix/detekt/AvoidNonNullAssertionOperator.kt

Lines changed: 0 additions & 50 deletions
This file was deleted.

detekt-rules/src/main/kotlin/org/modelix/detekt/RuleSetProvider.kt

Lines changed: 0 additions & 32 deletions
This file was deleted.

detekt-rules/src/main/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider

Lines changed: 0 additions & 1 deletion
This file was deleted.

detekt-rules/src/main/resources/config.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

detekt-rules/src/test/kotlin/org/modelix/detekt/AvoidNonNullAssertionOperatorTest.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.

metamodel-export/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ group = "org.modelix.mps"
1010
dependencies {
1111
implementation(project(":model-api-gen-runtime"))
1212
implementation(project(":model-api-gen"))
13-
compileOnly(fileTree(mpsHomeDir.map { it.dir("lib") }))
13+
compileOnly(fileTree(mpsHomeDir.map { it.dir("lib") }).matching { include("**/*.jar") })
1414
compileOnly(
1515
mpsHomeDir.map {
1616
it.files(

0 commit comments

Comments
 (0)