Is there a way to overwrite only a few config properties for detekt, and preserve most props from default-detekt-config.yml
?
Yes there is!
I assume you are using the gradle-plugin
. Actually you can specify more than one config file in the config
property:
gradle
detekt {
defaultProfile {
...
# config = "path/to/default.yml, path/to/my/config.yml"
config = files(file("default-config"), file("my-config"))
}
}
The config property can be a FileCollection, a File or just a String with comma-separated path entries. Make sure that the default configuration file is listed first. Now you can override each rule setting and property in your custom detekt configuration file.
Take a look how we @detekt configure two configs here https://github.com/arturbosch/detekt/blob/master/build.gradle.kts#L206 and this is how our custom config file looks like: https://github.com/arturbosch/detekt/blob/master/reports/failfast.yml.
Edit: If you are using just the CLI, you may write java -jar detekt.jar --config "first-config.yml,second-config.yml" ....