Kirill Zhukov
05/16/2023, 12:14 AMbuild-logic
custom Gradle module with various build conventions. In there I have a gradle plugin extension that applies and configures Detekt Gradle plugin (that works with existing rules). Now, I added my own custom rule set, following official guide, but the rule does not seem to be picked up, what am I missing?
1. create custom Detekt rule, say, MyRule
2. create custom rule set, say, MyRuleSetProvider
that includes MyRule
package com.example
class MyRuleSetProvider : RuleSetProvider {
override val ruleSetId: String = "MyRuleSet"
override fun instance(config: Config): RuleSet {
return RuleSet(
id = ruleSetId,
rules = listOf(
MyRule(config)
)
)
}
}
3. define build-logic/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider
com.example.MyRuleSetProvider
4. define detekt yml config build-logic/resources/config.yml
MyRuleSet:
MyRule:
active: true
detekt {
autoCorrect = false
parallel = true
config = files(
rootProject.file("detekt/config.yml"), // built-in rules
file("xyz.../build-logic/src/main/kotlin/resources/config.yml")
)
buildUponDefaultConfig = true
}
Property 'MyRuleSet' is misspelled or does not exist
Benoît Liessens
05/16/2023, 4:20 AMbuild-logic/src/main/resources/…
?Kirill Zhukov
05/16/2023, 5:44 PMYou need a resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider file which has as content the fully qualified name of your RuleSetProvider e.g. io.gitlab.arturbosch.detekt.sample.extensions.SampleProvider.