Allow to turn off whole rulesets in configuration file - Closes#7

This commit is contained in:
ArtiSmarti
2016-10-22 19:37:14 +02:00
parent b5cf9dd959
commit 16713b2b6f
3 changed files with 14 additions and 4 deletions

View File

@@ -4,5 +4,12 @@ package io.gitlab.arturbosch.detekt.api
* @author Artur Bosch
*/
interface RuleSetProvider {
fun buildRuleset(config: Config): RuleSet? {
val ruleSet = instance(config)
val subConfig = config.subConfig(ruleSet.id)
val active = subConfig.valueOrDefault("active") { true }
return if (active) ruleSet else null
}
fun instance(config: Config): RuleSet
}

View File

@@ -18,4 +18,7 @@ style:
WildcardImport:
active: true
NoElseInWhenExpression:
active: true
active: true
comments:
active: false

View File

@@ -27,9 +27,9 @@ class Detekt(project: Path,
fun run(): Map<String, List<Finding>> {
val ktFiles = compiler.compile()
val providers = loadProviders()
val futures = providers.map {
task { it.instance(config).acceptAll(ktFiles) }
}
val futures = providers.map { it.buildRuleset(config) }
.filterNotNull()
.map { task { it.acceptAll(ktFiles) } }
return awaitAll(futures).toMap()
}