All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gitlab.arturbosch.detekt.cli.config.DefaultPropertiesConfigValidator.kt Maven / Gradle / Ivy

There is a newer version: 1.23.7
Show newest version
package io.gitlab.arturbosch.detekt.cli.config

import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.ConfigValidator
import io.gitlab.arturbosch.detekt.api.Notification
import io.gitlab.arturbosch.detekt.api.internal.CommaSeparatedPattern
import io.gitlab.arturbosch.detekt.api.internal.DEFAULT_PROPERTY_EXCLUDES
import io.gitlab.arturbosch.detekt.api.internal.DefaultRuleSetProvider
import io.gitlab.arturbosch.detekt.api.internal.validateConfig
import io.gitlab.arturbosch.detekt.cli.loadDefaultConfig
import io.gitlab.arturbosch.detekt.core.ProcessingSettings
import io.gitlab.arturbosch.detekt.core.RuleSetLocator

class DefaultPropertiesConfigValidator(
    private val settings: ProcessingSettings
) : ConfigValidator {

    override fun validate(config: Config): Collection {
        fun patterns(): Set {
            val pluginExcludes = RuleSetLocator(settings).load()
                .filter { it !is DefaultRuleSetProvider }
                .joinToString(",") { "${it.ruleSetId}.*" }
            val configExcludes = config.subConfig("config").valueOrDefault("excludes", "")
            val allExcludes = "$configExcludes,$DEFAULT_PROPERTY_EXCLUDES,$pluginExcludes"
            return CommaSeparatedPattern(allExcludes).mapToRegex()
        }
        return validateConfig(config, loadDefaultConfig(), patterns())
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy