Stanislav Kral
03/17/2024, 11:23 AMdetekt
and detektMain
give me different violations in one source file for a multimodule project?
topnax@topnax-ryzen:<workdir>$ ./gradlew detekt
> Task :core-service:detekt FAILED
<workdir>/core-service/src/main/kotlin/cz/ayeto/backend/CoreApplication.kt:14:33: In most cases using a spread operator causes a full copy of the array to be created before calling a method. This may result in a performance penalty. [SpreadOperator]
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core-service:detekt'.
> Analysis failed with 1 weighted issues.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
BUILD FAILED in 1s
1 actionable task: 1 executed
topnax@topnax-ryzen:<workdir>$ ./gradlew detektMain
> Task :core-service:detektMain FAILED
<workdir>/core-service/src/main/kotlin/cz/ayeto/backend/CoreApplication.kt:14:33: Used in this way a spread operator causes a full copy of the array to be created before calling a method. This may result in a performance penalty. [SpreadOperator]
<workdir>/core-service/src/main/kotlin/cz/ayeto/backend/CoreApplication.kt:11:5: Calling !! on a nullable type will throw a NullPointerException at runtime in case the value is null. It should be avoided. [UnsafeCallOnNullableType]
<workdir>/core-service/src/main/kotlin/cz/ayeto/backend/CoreApplication.kt:18:13: Calling !! on a nullable type will throw a NullPointerException at runtime in case the value is null. It should be avoided. [UnsafeCallOnNullableType]
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core-service:detektMain'.
> Analysis failed with 3 weighted issues.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
BUILD FAILED in 1s
6 actionable tasks: 4 executed, 2 up-to-date
Root buildscript:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import io.gitlab.arturbosch.detekt.Detekt
plugins {
val kotlinVersion = "1.9.22"
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
id("io.gitlab.arturbosch.detekt") version "1.23.5"
kotlin("jvm") version kotlinVersion apply true
}
allprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")
detekt {
buildUponDefaultConfig = true
}
tasks.withType<Detekt>().configureEach {
buildUponDefaultConfig = true
reports {
html.required = true
// disabled until GitLab adds SARIF support
// sarif.required = true
}
}
repositories {
mavenLocal()
mavenCentral()
}
}
subprojects {
apply {
...
Any help would be appreciated.
Thanksmarschwar
03/17/2024, 11:38 AMStanislav Kral
03/17/2024, 1:27 PMUnsafeCallOnNullableType
is found with detektMain
but not with detekt
? How to make it so that both tasks find the violation?Stanislav Kral
03/17/2024, 1:33 PMmarschwar
03/17/2024, 1:35 PMStanislav Kral
03/17/2024, 1:35 PM