Bilgehan KALKAN
01/11/2023, 8:02 AMdetektDebug
But recently I’m trying to validate “.kts” files too. But when I configure DetektExtension
with that paths(for root settings.gradle.kts
files too), detektDebug
task does not validates that files. It only validates default paths. On CI environment application is validated only with detektDebug
task because of baseline files.
Is there any way to configure detektDebug
task inputs via Extensions? When I tried to reach the task via tasks.named<Detekt>("detektDebug")
call it was tricky, I had to do this call on doAfter
block. Also project uses published plugins to apply all required plugins, so ı didn’t want to add confusing tricks on there.
Also I tried to configure detektDebug
task to depend on detekt
task and configured DetektExtension
to only check “.kts” files but when I do that --continue
option become useless. (CI environment uses --continue
option and we would like to provide complete reports to developers so that they can fix all issues at once instead of waiting results for each validation errors commit by commit.)Bilgehan KALKAN
01/11/2023, 8:17 AMbuild.gradle
scripts.
• Create new “.kt” file under app/src/main/java
and put some validation errors.
• Add this extension configuration to :app
’s build.gradle
to clear detekt
’s validation check paths:
detekt {
source.from.clear()
}
After this when I run ./gradlew detekt
it passes because it does not check any files.
But when I run ./gradlew detektDebug
it still checks default paths and finds violations.ephemient
01/11/2023, 9:51 AMdetektDebug
is configured for type resolution (https://detekt.dev/docs/gettingstarted/type-resolution/#enabling-on-an-android-project) - it only works if it's using the same sources and dependencies as the compilerephemient
01/11/2023, 9:56 AMimport io.gitlab.arturbosch.detekt.Detekt
import org.gradle.language.base.plugins.LifecycleBasePlugin.VERIFICATION_GROUP
tasks.register<Detekt>("detektScripts") {
group = VERIFICATION_GROUP
description = "Run detekt analysis for Kotlin scripts"
source(files().apply { from(layout.projectDirectory.asFileTree.matching { include("*.kts") }) })
}
ephemient
01/11/2023, 10:00 AMephemient
01/11/2023, 10:04 AMcheck
) that depends on everything you want to run on CI - all its dependencies should try execute when you use --continue
, even if it can't due to some failed dependencies, but that doesn't matter because it doesn't do anything on its own anywayBilgehan KALKAN
01/11/2023, 10:54 AMdetekt
task to check only .kts
files right? Because we want to lover task count on the project to lower IDE Sync durations.ephemient
01/11/2023, 11:02 AMBilgehan KALKAN
01/11/2023, 11:06 AM.gradle.kts
files. Thats why I was trying to add this validations to Detekt.