Tom De Decker
07/11/2023, 9:55 AMTom De Decker
07/11/2023, 9:56 AMplugins {
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.
@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!Nicholas Doglio
07/11/2023, 12:09 PMdetektGenerateConfig
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 documentationTom De Decker
07/11/2023, 12:53 PM