GMachine
11/27/2024, 2:55 PMproductArgs.favoriteLink!!.id
as UnnecessaryNotNullOperator
, even though productArgs.favoriteLink
is in another module and cannot be smart casted (Android Studio confirms this).
if (productArgs.favoriteLink != null) {
println(productArgs.favoriteLink!!.id) // Reported as UnnecessaryNotNullOperator
println(productArgs.favoriteLink.id) // Compiler error: smart cast not possible
}
Here’s how I resolve my classpath using a Gradle task:
tasks.register("resolveClasspath") {
def resolvedClasspath = providers.provider {
def classpathFiles = files()
// Iterate over application variants during the configuration phase
android.applicationVariants.all { variant ->
classpathFiles += variant.javaCompileProvider.get().classpath.filter { it.exists() }
}
// Convert classpath to a comma-separated string for later use
classpathFiles.files.collect { it.absolutePath }.join(",")
}
doLast {
println(resolvedClasspath.get())
}
}
Any ideas why Detekt might generate false positives in this setup? Am I missing something in my configuration? 🤔Brais Gabin
11/28/2024, 6:06 AMGMachine
11/28/2024, 1:09 PMGMachine
12/01/2024, 4:53 AM./gradlew detektMain
gradle plugin works well. My only concern - it takes so many time to run on our CI.
I've placed ./gradlew detektMain
after app build on CI, so I believe some gradle caches is reusing, even so it takes about 15 minutes to run. Our app build process takes about 20 minutes, detekt cli
without type resolution takes about a minute to run
Is there any way to speed up execution of detekt with type resolution? unfortunately we can't use compiler plugin, cause We're using Kotlin 2.0.20 and we need it to be with K2 support.
I tried to get a classpath manually and run detekt cli
with type resolution, but I found it really hard to get a correct classpath from android project.Brais Gabin
12/04/2024, 7:50 PM