mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
Allow to turn off whole rulesets in configuration file - Closes#7
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -18,4 +18,7 @@ style:
|
||||
WildcardImport:
|
||||
active: true
|
||||
NoElseInWhenExpression:
|
||||
active: true
|
||||
active: true
|
||||
|
||||
comments:
|
||||
active: false
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user