https://kotlinlang.org logo
#detekt
Title
# detekt
d

dimsuz

05/04/2022, 5:15 PM
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

gammax

05/04/2022, 5:47 PM
Did I miss something?
That's the expected behavior no? Or are you expecting something different
d

dimsuz

05/04/2022, 5:56 PM
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

Brais Gabin

05/05/2022, 6:59 AM
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

dimsuz

05/05/2022, 10:35 AM
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

Brais Gabin

05/05/2022, 10:40 AM
I'll take a look
d

dimsuz

05/05/2022, 10:44 AM
I prepared a sample project. Was about to create an issue on github. should I? 🙂
b

Brais Gabin

05/05/2022, 10:45 AM
Go ahead 🙂 that will help a lot
d

dimsuz

05/05/2022, 10:45 AM
but it's really basic though: simply applies a plugin, adds detektPlugins("..formatting") and that's all
Ok, one moment 🙂
❤️ 1
r

rocketraman

05/05/2022, 1:42 PM
I can confirm with 1.20 in my project none of the formatting rules are added with
detectGenerateConfig
.
123 Views