Hi! Finishing up a small set of detekt rules for C...
# detekt
d
Hi! Finishing up a small set of detekt rules for Compose (will publish on maven central soon) and I'm trying to use this default config feature. • created a file
src/main/resources/config/config.yml
• published to maven local • In a sample project added `detektPlugins("com.examplemy ruleset1.0.0") • In the
config/config.yml
set rules as
active:true
• didn't add anything to sample project's
detekt-config.yml
Result: rule set is not applied. but if I add in sample's `detekt-config.yml`:
Copy code
compose: 
  MyRule:
    active: true
Then rule gets applied and reports errors. Did I miss something?
Does it matter how i pass the config?
Copy code
class ReusedModifierInstance(config: Config = Config.empty) : Rule(config)
is this ok?
Here's the ruleset repo if you'd like to check out how everything is configured currently: https://github.com/appKODE/detekt-rules-compose
g
Did I miss something?
That's the expected behavior no? Or are you expecting something different
d
Hmm. I thought that expected behavior is that if I provide
config.yml
in my ruleset and enable rules there, they'll be applied without explicitly specifying them in
detekt-config.yml
. Detekt
1.20.0
changelog seemed to imply that this was done for the
formatting
ruleset.
I forgot to mention that in
config.yml
I've set rules as
active:true
. Edited steps above.
b
There's an easy way to check if it is working. Remove your configuration in the project that is using your rule set and execute detektGenerateConfig. You should see your configuration copied to the default configuration.
d
I doesn't get added when I run
detektGeneratedConfig
. By the way, neither is
formatting
. I have added both my and detekt-formatting rulesets to the config
Copy code
dependencies {
  detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.20.0"
  detektPlugins "ru.kode:detekt-rules-compose:1.0.0"
}
then removed
detekt-config.yml
, ran
detektGenerateConfig
and neither my ruleset nor formatting rules are appended.
b
I'll take a look
d
I prepared a sample project. Was about to create an issue on github. should I? 🙂
b
Go ahead 🙂 that will help a lot
d
but it's really basic though: simply applies a plugin, adds detektPlugins("..formatting") and that's all
Ok, one moment 🙂
❤️ 1
r
I can confirm with 1.20 in my project none of the formatting rules are added with
detectGenerateConfig
.
158 Views