detekt / detekt

Static code analysis for Kotlin

Home Page:https://detekt.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fail fast approach / configuration

vanniktech opened this issue · comments

I'd like to have a fail fast approach where I'd say in the configuration file that I want every rule to be automatically turned on with the default values. That would also include rules that are maybe turned off by default such as in #174.

The motivation behind this is that I want to fail fast and have every rule activated and then customize some rules to my needs. E.g. For instance changing the MaxLineLength to 100 instead of the default 120. Also with this approach the size of the configuration file would be reduced dramatically which is in favor when trying to keep them in sync across multiple projects.

Interesting in hearing opinions about this.

Hmm sounds interesting, basically a flag in the config like failFast=true which creates a WrapperConfig around the DefaultConfig which intercept all calls to active and return true ?

Yes something like that.

failFast: true where warningThreshold & failThreshold will be automatically set to 0. Weights can then be ignored and left untouched.

And if I want to adjust the maxLineLength value I just simply use this configuration file:

autoCorrect: true

style:
  MaxLineLength:
    maxLineLength: 100

All rules are turned on by default and the value of maxLineLength is adjusted to 100. Now if I don't want to have the CommentOverPrivateMethod turned on I append:

comments:
  CommentOverPrivateMethod:
    active: false

As of M12 you can override configuration values by passing two config paths to --config. So basically you can have this feature now. Create a config file with everything turned on and with default thresholds and override some values with the second config. (--config path/to/base,path/to/overridden)

While this is nice it won't work well with different projects and version controlling. The base file would need to be checked into each project.

I'm also happy to take over the implementation of the failfast feature if you approve of it.

Well it won't hurt, I would also use this option :)

Give it a try! Just my tipps:

Main.loadConfiguration-function in cli builds the config object
There is a CompositeConfig class which allows you to combine two configs

commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics.