I've been trying to integrate Detekt into my Gradl...
# detekt
t
I've been trying to integrate Detekt into my Gradle setup and I've got it to the point where the base ruleset is being checked when building, but I can't seem to get it to check the custom (Compose) ruleset I've given it. Anyone that can help me out? More info in 🧵
My setup is as follows in my module's build.gradle.kts:
Copy code
plugins {
	alias(libs.plugins.detekt)
}

dependencies {
    detektPlugins("io.nlopez.compose.rules:detekt:${libs.versions.composeDetektRules.get()}")
}

// Run detekt before building
tasks.withType<KotlinCompile>().configureEach {
    dependsOn(tasks.detekt)
}
I've omitted some unrelated parts for brevity. Turning on Detekt's debug logging shows me that the plugin has been registered, but I do not get any compiler errors on rules from this ruleset while I do get them from those from the base ruleset. As an example, the following snippet should give me two errors. the parameter
foo
isn't used anywhere and should therefore give me an error from the base ruleset. This works as expected. The second error comes from the external ruleset and should be that I'm not passing a modifier into the TestComposable. In my editor (Android Studio) I'm also using the Detekt plugin which is able to correctly identify this as an error while the Gradle task fails to do this.
Copy code
@Composable
fun TestComposable(foo: String = "") {
    Box(
        contentAlignment = Alignment.Center,
        modifier = Modifier,
    ) {
        Text(
            text = "Hello, Compose!",
            style = MaterialTheme.typography.headlineLarge
        )
    }
}
Does anyone have any ideas where I could be going wrong? Thanks!
n
Do you have a config file generated? Does it also contain the rules from the Compose plugin? I would guess it doesn't, I think if you run the
detektGenerateConfig
task it will automatically add them since you've added the plugin, if it doesn't you'll just have to copy/paste them into your config from the plugins documentation
t
That was it, thank you very much!