Repository: detekt/detekt (kotlin)

Issue:
allRules = true has no effect when buildUponDefaultConfig = true
<!-- The bug you're experiencing might have already be reported! -->
<!-- Please search in the [issues](https://github.com/detekt/detekt/issues) before creating one. -->

## Expected Behavior
One of:
 * `allRules` enables all rules on top of using the default config (which seems to be the code (`AllRulesConfig`) anyway.
 * A build failure is triggered because the CLI throws an exception that conflicting flags were passed in.

## Observed Behavior
When configuring `DetektExtension`
```
buildUponDefaultConfig = true
allRules = true
```
bahaves the same as
```
buildUponDefaultConfig = true
```

## Steps to Reproduce
Will produce if necessary.

## Context
I want to go all in, making a reusable strictest configuration I can make, by enabling all checks, but keeping it open that any new Detekt improvements are automatically added.

## Your Environment
<!-- Include as many relevant details about the environment you experienced the bug in -->
* Version of detekt used: 1.20.0
* Version of Gradle used (if applicable): 7.4.2
* Gradle scan link (add `--scan` option when running the gradle task): N/A
* Operating System and version: Windows 10
* Link to your project (if it's a public repository): N/A

Pull request:
Fixes #4926 while it simplifies how all the configuration is handled.

I recommend to review this PR commit by commit.

I think that @TWiStErRob is going to be happy with this one ;)

~Blocked by #6841 and #6782~

Patch:
diff --git a/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/SetupContext.kt b/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/SetupContext.kt
index 124b9670eff9..80b50a678bcd 100644
--- a/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/SetupContext.kt
+++ b/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/SetupContext.kt
@@ -12,7 +12,7 @@ interface SetupContext : PropertiesAware {
     val configUris: Collection<URI>
 
     /**
-     * Configuration which is used to setup detekt.
+     * Configuration which is used to set up detekt.
      */
     val config: Config
 
diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt
index 4409d8170ae7..acd8709c05d7 100644
--- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt
+++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt
@@ -1,7 +1,6 @@
 package io.gitlab.arturbosch.detekt.core
 
 import io.github.detekt.psi.absolutePath
-import io.github.detekt.tooling.api.spec.ProcessingSpec
 import io.gitlab.arturbosch.detekt.api.CodeSmell
 import io.gitlab.arturbosch.detekt.api.CompilerResources
 import io.gitlab.arturbosch.detekt.api.Config
@@ -20,13 +19,8 @@ import io.gitlab.arturbosch.detekt.api.internal.whichDetekt
 import io.gitlab.arturbosch.detekt.api.internal.whichJava
 import io.gitlab.arturbosch.detekt.api.internal.whichOS
 import io.gitlab.arturbosch.detekt.api.ruleId
-import io.gitlab.arturbosch.detekt.core.config.AllRulesConfig
-import io.gitlab.arturbosch.detekt.core.config.DisabledAutoCorrectConfig
-import io.gitlab.arturbosch.detekt.core.config.validation.DeprecatedRule
-import io.gitlab.arturbosch.detekt.core.config.validation.loadDeprecations
 import io.gitlab.arturbosch.detekt.core.rules.associateRuleIdsToRuleSetIds
 import io.gitlab.arturbosch.detekt.core.suppressors.buildSuppressors
-import io.gitlab.arturbosch.detekt.core.tooling.getDefaultConfiguration
 import io.gitlab.arturbosch.detekt.core.util.isActiveOrDefault
 import io.gitlab.arturbosch.detekt.core.util.shouldAnalyzeFile
 import org.jetbrains.kotlin.config.languageVersionSettings
@@ -42,9 +36,6 @@ internal class Analyzer(
     private val providers: List<RuleSetProvider>,
     private val processors: List<FileProcessListener>
 ) {
-
-    private val config: Config = settings.spec.workaroundConfiguration(settings.config)
-
     fun run(
         ktFiles: Collection<KtFile>,
         bindingContext: BindingContext = BindingContext.EMPTY
@@ -108,7 +99,7 @@ internal class Analyzer(
         compilerResources: CompilerResources
     ): Map<RuleSet.Id, List<Finding2>> {
         val activeRuleSetsToRuleSetConfigs = providers.asSequence()
-            .map { it to config.subConfig(it.ruleSetId.value) }
+            .map { it to settings.config.subConfig(it.ruleSetId.value) }
             .filter { (_, ruleSetConfig) -> ruleSetConfig.isActiveOrDefault(true) }
             .map { (provider, ruleSetConfig) -> provider.instance() to ruleSetConfig }
             .filter { (_, ruleSetConfig) -> ruleSetConfig.shouldAnalyzeFile(file) }
@@ -157,7 +148,7 @@ internal class Analyzer(
 
     private fun warnAboutEnabledRequiresTypeResolutionRules() {
         providers.asSequence()
-            .map { it to config.subConfig(it.ruleSetId.value) }
+            .map { it to settings.config.subConfig(it.ruleSetId.value) }
             .filter { (_, ruleSetConfig) -> ruleSetConfig.isActiveOrDefault(true) }
             .map { (provider, ruleSetConfig) -> provider.instance() to ruleSetConfig }
             .flatMap { (ruleSet, ruleSetConfig) ->
@@ -200,31 +191,6 @@ private fun throwIllegalStateException(file: KtFile, error: Throwable): Nothing
     throw IllegalStateException(message, error)
 }
 
-internal fun ProcessingSpec.workaroundConfiguration(config: Config): Config = with(configSpec) {
-    var declaredConfig: Config? = when {
-        configPaths.isNotEmpty() -> config
-        resources.isNotEmpty() -> config
-        useDefaultConfig -> config
-        else -> null
-    }
-
-    if (rulesSpec.activateAllRules) {
-        val defaultConfig = getDefaultConfiguration()
-        val deprecatedRules = loadDeprecations().filterIsInstance<DeprecatedRule>().toSet()
-        declaredConfig = AllRulesConfig(
-            originalConfig = declaredConfig ?: defaultConfig,
-            defaultConfig = defaultConfig,
-            deprecatedRules = deprecatedRules
-        )
-    }
-
-    if (!rulesSpec.autoCorrect) {
-        declaredConfig = DisabledAutoCorrectConfig(declaredConfig ?: getDefaultConfiguration())
-    }
-
-    return declaredConfig ?: getDefaultConfiguration()
-}
-
 private fun Finding.toFinding2(rule: Finding2.RuleInfo, severity: Severity): Finding2 {
     return when (this) {
         is CorrectableCodeSmell -> Finding2Impl(rule, entity, message, references, severity, autoCorrectEnabled)
diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/ProcessingSettings.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/ProcessingSettings.kt
index 062147dc0bb3..8c32f8cfde1b 100644
--- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/ProcessingSettings.kt
+++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/ProcessingSettings.kt
@@ -25,7 +25,7 @@ import java.net.URI
  */
 class ProcessingSettings(
     val spec: ProcessingSpec,
-    override val config: Config
+    override val config: Config,
 ) : AutoCloseable,
     Closeable,
     LoggingAware by LoggingFacade(spec.loggingSpec),
diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfig.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfig.kt
index 41d77fecf1c6..745bd8990415 100644
--- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfig.kt
+++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfig.kt
@@ -7,38 +7,37 @@ import io.gitlab.arturbosch.detekt.core.config.validation.validateConfig
 
 @Suppress("UNCHECKED_CAST")
 internal data class AllRulesConfig(
-    private val originalConfig: Config,
-    private val defaultConfig: Config,
-    private val deprecatedRules: Set<DeprecatedRule> = emptySet(),
+    private val wrapped: Config,
+    private val deprecatedRules: Set<DeprecatedRule>,
     override val parent: Config? = null,
 ) : Config, ValidatableConfiguration {
 
     override val parentPath: String?
-        get() = originalConfig.parentPath ?: defaultConfig.parentPath
+        get() = wrapped.parentPath
 
     override fun subConfig(key: String) =
-        AllRulesConfig(originalConfig.subConfig(key), defaultConfig.subConfig(key), deprecatedRules, this)
+        AllRulesConfig(wrapped.subConfig(key), deprecatedRules, this)
 
     override fun subConfigKeys(): Set<String> {
-        return originalConfig.subConfigKeys() + defaultConfig.subConfigKeys()
+        return wrapped.subConfigKeys()
     }
 
     override fun <T : Any> valueOrDefault(key: String, default: T): T {
         return when (key) {
-            Config.ACTIVE_KEY -> if (isDeprecated()) false as T else originalConfig.valueOrDefault(key, true) as T
-            else -> originalConfig.valueOrDefault(key, defaultConfig.valueOrDefault(key, default))
+            Config.ACTIVE_KEY -> if (isDeprecated()) false as T else wrapped.valueOrDefault(key, true) as T
+            else -> wrapped.valueOrDefault(key, default)
         }
     }
 
     override fun <T : Any> valueOrNull(key: String): T? {
         return when (key) {
-            Config.ACTIVE_KEY -> if (isDeprecated()) false as T else originalConfig.valueOrNull(key) ?: true as? T
-            else -> originalConfig.valueOrNull(key) ?: defaultConfig.valueOrNull(key)
+            Config.ACTIVE_KEY -> if (isDeprecated()) false as T else wrapped.valueOrNull(key) ?: true as? T
+            else -> wrapped.valueOrNull(key)
         }
     }
 
     override fun validate(baseline: Config, excludePatterns: Set<Regex>) =
-        validateConfig(originalConfig, baseline, excludePatterns)
+        validateConfig(wrapped, baseline, excludePatterns)
 
     private fun isDeprecated(): Boolean = deprecatedRules.any { parentPath == it.toPath() }
 
diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/Configurations.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/Configurations.kt
index 6173b82fc7ff..be9f0295983f 100644
--- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/Configurations.kt
+++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/Configurations.kt
@@ -4,7 +4,6 @@ import io.github.detekt.tooling.api.spec.ConfigSpec
 import io.github.detekt.tooling.api.spec.ProcessingSpec
 import io.github.detekt.utils.openSafeStream
 import io.gitlab.arturbosch.detekt.api.Config
-import io.gitlab.arturbosch.detekt.core.tooling.getDefaultConfiguration
 import java.net.URI
 import java.net.URL
 import java.nio.file.FileSystemNotFoundException
@@ -12,26 +11,16 @@ import java.nio.file.FileSystems
 import java.nio.file.Path
 
 internal fun ProcessingSpec.loadConfiguration(): Config = with(configSpec) {
-    var declaredConfig: Config? = when {
+    return when {
         configPaths.isNotEmpty() -> parsePathConfig(configPaths)
         resources.isNotEmpty() -> parseResourceConfig(resources)
-        else -> null
+        else -> Config.empty
     }
-
-    if (useDefaultConfig) {
-        declaredConfig = if (declaredConfig == null) {
-            getDefaultConfiguration()
-        } else {
-            CompositeConfig(declaredConfig, getDefaultConfiguration())
-        }
-    }
-
-    return declaredConfig ?: getDefaultConfiguration()
 }
 
 private fun parseResourceConfig(urls: Collection<URL>): Config =
     if (urls.size == 1) {
-        urls.first().openSafeStream().reader().use(YamlConfig::load)
+        urls.single().openSafeStream().reader().use(YamlConfig::load)
     } else {
         urls.asSequence()
             .map { it.openSafeStream().reader().use(YamlConfig::load) }
@@ -40,7 +29,7 @@ private fun parseResourceConfig(urls: Collection<URL>): Config =
 
 private fun parsePathConfig(paths: Collection<Path>): Config =
     if (paths.size == 1) {
-        YamlConfig.load(paths.first())
+        YamlConfig.load(paths.single())
     } else {
         paths.asSequence()
             .map { YamlConfig.load(it) }
diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/tooling/ProcessingSpecSettingsBridge.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/tooling/ProcessingSpecSettingsBridge.kt
index 002915a9006f..58ceca23596c 100644
--- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/tooling/ProcessingSpecSettingsBridge.kt
+++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/tooling/ProcessingSpecSettingsBridge.kt
@@ -1,10 +1,16 @@
 package io.gitlab.arturbosch.detekt.core.tooling
 
 import io.github.detekt.tooling.api.spec.ProcessingSpec
+import io.gitlab.arturbosch.detekt.api.Config
 import io.gitlab.arturbosch.detekt.core.ProcessingSettings
 import io.gitlab.arturbosch.detekt.core.baseline.DETEKT_BASELINE_CREATION_KEY
 import io.gitlab.arturbosch.detekt.core.baseline.DETEKT_BASELINE_PATH_KEY
+import io.gitlab.arturbosch.detekt.core.config.AllRulesConfig
+import io.gitlab.arturbosch.detekt.core.config.CompositeConfig
+import io.gitlab.arturbosch.detekt.core.config.DisabledAutoCorrectConfig
 import io.gitlab.arturbosch.detekt.core.config.loadConfiguration
+import io.gitlab.arturbosch.detekt.core.config.validation.DeprecatedRule
+import io.gitlab.arturbosch.detekt.core.config.validation.loadDeprecations
 import io.gitlab.arturbosch.detekt.core.reporting.DETEKT_OUTPUT_REPORT_BASE_PATH_KEY
 import io.gitlab.arturbosch.detekt.core.reporting.DETEKT_OUTPUT_REPORT_PATHS_KEY
 import io.gitlab.arturbosch.detekt.core.util.MONITOR_PROPERTY_KEY
@@ -13,7 +19,9 @@ import io.gitlab.arturbosch.detekt.core.util.PerformanceMonitor.Phase
 
 internal fun <R> ProcessingSpec.withSettings(execute: ProcessingSettings.() -> R): R {
     val monitor = PerformanceMonitor()
-    val configuration = monitor.measure(Phase.LoadConfig) { loadConfiguration() }
+    val configuration = monitor.measure(Phase.LoadConfig) {
+        workaroundConfiguration(loadConfiguration())
+    }
     val settings = monitor.measure(Phase.CreateSettings) {
         ProcessingSettings(this, configuration).apply {
             baselineSpec.path?.let { register(DETEKT_BASELINE_PATH_KEY, it) }
@@ -31,3 +39,22 @@ internal fun <R> ProcessingSpec.withSettings(execute: ProcessingSettings.() -> R
     }
     return result
 }
+
+internal fun ProcessingSpec.workaroundConfiguration(config: Config): Config {
+    var declaredConfig: Config = config
+
+    if (rulesSpec.activateAllRules) {
+        val deprecatedRules = loadDeprecations().filterIsInstance<DeprecatedRule>().toSet()
+        declaredConfig = AllRulesConfig(declaredConfig, deprecatedRules)
+    }
+
+    if (!rulesSpec.autoCorrect) {
+        declaredConfig = DisabledAutoCorrectConfig(declaredConfig)
+    }
+
+    if (configSpec.useDefaultConfig) {
+        declaredConfig = CompositeConfig(declaredConfig, getDefaultConfiguration())
+    }
+
+    return declaredConfig
+}


Test patch:
diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfigSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfigSpec.kt
index 81648e926d14..602f47278bdb 100644
--- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfigSpec.kt
+++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfigSpec.kt
@@ -10,53 +10,23 @@ import org.junit.jupiter.api.Test
 class AllRulesConfigSpec {
     private val emptyYamlConfig = yamlConfigFromContent("")
 
-    @Nested
-    inner class ValueVerification {
-
-        @Test
-        fun verifyValue() {
-            val subject = AllRulesConfig(
-                originalConfig = yamlConfigFromContent(
-                    """
-                    style:
-                      MaxLineLength:
-                        maxLineLength: 100
-                    """.trimIndent()
-                ),
-                defaultConfig = emptyYamlConfig,
-            )
-
-            val subConfig = subject.subConfig("style")
-                .subConfig("MaxLineLength")
-            assertThat(subConfig.valueOrDefault("maxLineLength", 0)).isEqualTo(100)
-            assertThat(subConfig.valueOrNull<Int>("maxLineLength")).isEqualTo(100)
-        }
-
-        @Test
-        fun verifyValueOverride() {
-            val subject = AllRulesConfig(
-                originalConfig = yamlConfigFromContent(
-                    """
+    @Test
+    fun verifyValue() {
+        val subject = AllRulesConfig(
+            wrapped = yamlConfigFromContent(
+                """
                     style:
                       MaxLineLength:
                         maxLineLength: 100
-                    """.trimIndent()
-                ),
-                defaultConfig = yamlConfigFromContent(
-                    """
-                    style:
-                      MaxLineLength:
-                        maxLineLength: 120
-                    """.trimIndent()
-                ),
-            )
-
-            val actual = subject.subConfig("style")
-                .subConfig("MaxLineLength")
-                .valueOrDefault("maxLineLength", 0)
+                """.trimIndent()
+            ),
+            deprecatedRules = emptySet(),
+        )
 
-            assertThat(actual).isEqualTo(100)
-        }
+        val subConfig = subject.subConfig("style")
+            .subConfig("MaxLineLength")
+        assertThat(subConfig.valueOrDefault("maxLineLength", 0)).isEqualTo(100)
+        assertThat(subConfig.valueOrNull<Int>("maxLineLength")).isEqualTo(100)
     }
 
     @Nested
@@ -73,8 +43,8 @@ class AllRulesConfigSpec {
         @Test
         fun `is derived from the original config`() {
             val subject = AllRulesConfig(
-                originalConfig = rulesetConfig,
-                defaultConfig = emptyYamlConfig,
+                wrapped = rulesetConfig,
+                deprecatedRules = emptySet(),
             )
             val actual = subject.parentPath
             assertThat(actual).isEqualTo(rulesetId)
@@ -83,11 +53,11 @@ class AllRulesConfigSpec {
         @Test
         fun `is derived from the default config if unavailable in original config`() {
             val subject = AllRulesConfig(
-                originalConfig = emptyYamlConfig,
-                defaultConfig = rulesetConfig,
+                wrapped = emptyYamlConfig,
+                deprecatedRules = emptySet(),
             )
             val actual = subject.parentPath
-            assertThat(actual).isEqualTo(rulesetId)
+            assertThat(actual).isEqualTo(null)
         }
     }
 
@@ -104,8 +74,8 @@ class AllRulesConfigSpec {
         @Test
         fun `is the parent`() {
             val subject = AllRulesConfig(
-                originalConfig = rulesetConfig,
-                defaultConfig = emptyYamlConfig,
+                wrapped = rulesetConfig,
+                deprecatedRules = emptySet(),
             )
             val actual = subject.subConfig("style").parent
             assertThat(actual).isEqualTo(subject)
@@ -114,8 +84,8 @@ class AllRulesConfigSpec {
         @Test
         fun `is the parent for all subConfig`() {
             val subject = AllRulesConfig(
-                originalConfig = rulesetConfig,
-                defaultConfig = emptyYamlConfig,
+                wrapped = rulesetConfig,
+                deprecatedRules = emptySet(),
             )
 
             assertThat(subject.subConfigKeys()).contains("style")
@@ -128,8 +98,7 @@ class AllRulesConfigSpec {
         @Test
         fun `rule is active if not deprecated`() {
             val subject = AllRulesConfig(
-                originalConfig = emptyYamlConfig,
-                defaultConfig = emptyYamlConfig,
+                wrapped = emptyYamlConfig,
                 deprecatedRules = emptySet()
             )
                 .subConfig("ruleset")
@@ -143,9 +112,8 @@ class AllRulesConfigSpec {
         @Test
         fun `rule is inactive if deprecated`() {
             val subject = AllRulesConfig(
-                originalConfig = emptyYamlConfig,
-                defaultConfig = emptyYamlConfig,
-                deprecatedRules = setOf(DeprecatedRule("ruleset", "ARule", ""))
+                wrapped = emptyYamlConfig,
+                deprecatedRules = setOf(DeprecatedRule("ruleset", "ARule", "")),
             )
                 .subConfig("ruleset")
                 .subConfig("ARule")
diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/ConfigurationsSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/ConfigurationsSpec.kt
index cf044a09bd31..2229a1e483f0 100644
--- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/ConfigurationsSpec.kt
+++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/ConfigurationsSpec.kt
@@ -75,34 +75,4 @@ class ConfigurationsSpec {
             assertThat(config.valueOrDefault("three", -1)).isEqualTo(3)
         }
     }
-
-    @Nested
-    inner class `build upon default config` {
-
-        private val config = ProcessingSpec {
-            config {
-                resources = listOf(resourceUrl("/configs/activate-all-rules-wont-override-here.yml"))
-                useDefaultConfig = true
-            }
-            rules { activateAllRules = true }
-        }.loadConfiguration()
-
-        @Test
-        fun `should override config when specified`() {
-            val ruleConfig = config.subConfig("style").subConfig("MaxLineLength")
-            val lineLength = ruleConfig.valueOrDefault("maxLineLength", -1)
-            val excludeComments = ruleConfig.valueOrDefault("excludeCommentStatements", false)
-
-            assertThat(lineLength).isEqualTo(100)
-            assertThat(excludeComments).isTrue()
-        }
-
-        @Test
-        fun `should be active=false by default`() {
-            val actual = config.subConfig("comments")
-                .subConfig("CommentOverPrivateFunction")
-                .valueOrDefault("active", true)
-            assertThat(actual).isFalse()
-        }
-    }
 }
diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/WorkaroundConfigurationKtSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/tooling/WorkaroundConfigurationKtSpec.kt
similarity index 89%
rename from detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/WorkaroundConfigurationKtSpec.kt
rename to detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/tooling/WorkaroundConfigurationKtSpec.kt
index 326737405e31..63cb008e310e 100644
--- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/WorkaroundConfigurationKtSpec.kt
+++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/tooling/WorkaroundConfigurationKtSpec.kt
@@ -1,8 +1,7 @@
-package io.gitlab.arturbosch.detekt.core
+package io.gitlab.arturbosch.detekt.core.tooling
 
 import io.github.detekt.test.utils.resourceUrl
 import io.github.detekt.tooling.api.spec.ProcessingSpec
-import io.gitlab.arturbosch.detekt.core.config.loadConfiguration
 import org.assertj.core.api.Assertions.assertThat
 import org.junit.jupiter.api.Nested
 import org.junit.jupiter.api.Test
@@ -13,11 +12,12 @@ class WorkaroundConfigurationKtSpec {
     inner class `with all rules activated by default` {
 
         private val config = ProcessingSpec {
-            config { resources = listOf(resourceUrl("/configs/empty.yml")) }
+            config {
+                resources = listOf(resourceUrl("/configs/empty.yml"))
+                useDefaultConfig = true
+            }
             rules { activateAllRules = true }
-        }.let { spec ->
-            spec.workaroundConfiguration(spec.loadConfiguration())
-        }
+        }.withSettings { spec.workaroundConfiguration(config) }
 
         @Test
         fun `should override active to true by default`() {
@@ -42,9 +42,7 @@ class WorkaroundConfigurationKtSpec {
         private val config = ProcessingSpec {
             config { resources = listOf(resourceUrl("/configs/activate-all-rules-will-override-here.yml")) }
             rules { activateAllRules = true }
-        }.let { spec ->
-            spec.workaroundConfiguration(spec.loadConfiguration())
-        }
+        }.withSettings { spec.workaroundConfiguration(config) }
 
         @Test
         fun `should override config when specified`() {
@@ -72,9 +70,7 @@ class WorkaroundConfigurationKtSpec {
             private val config = ProcessingSpec {
                 config { resources = listOf(resourceUrl("/configs/config-with-auto-correct.yml")) }
                 rules { autoCorrect = true }
-            }.let { spec ->
-                spec.workaroundConfiguration(spec.loadConfiguration())
-            }
+            }.withSettings { spec.workaroundConfiguration(config) }
 
             private val style = config.subConfig("style")
             private val comments = config.subConfig("comments")
@@ -98,9 +94,7 @@ class WorkaroundConfigurationKtSpec {
         inner class `when not specified all autoCorrect values are overridden to false` {
             private val config = ProcessingSpec {
                 config { resources = listOf(resourceUrl("/configs/config-with-auto-correct.yml")) }
-            }.let { spec ->
-                spec.workaroundConfiguration(spec.loadConfiguration())
-            }
+            }.withSettings { spec.workaroundConfiguration(config) }
             private val style = config.subConfig("style")
             private val comments = config.subConfig("comments")
 
@@ -124,9 +118,7 @@ class WorkaroundConfigurationKtSpec {
             private val config = ProcessingSpec {
                 config { resources = listOf(resourceUrl("/configs/config-with-auto-correct.yml")) }
                 rules { autoCorrect = false }
-            }.let { spec ->
-                spec.workaroundConfiguration(spec.loadConfiguration())
-            }
+            }.withSettings { spec.workaroundConfiguration(config) }
             private val style = config.subConfig("style")
             private val comments = config.subConfig("comments")
 
@@ -156,9 +148,7 @@ class WorkaroundConfigurationKtSpec {
                     autoCorrect = false
                     activateAllRules = true
                 }
-            }.let { spec ->
-                spec.workaroundConfiguration(spec.loadConfiguration())
-            }
+            }.withSettings { spec.workaroundConfiguration(config) }
 
             private val style = config.subConfig("style")
             private val comments = config.subConfig("comments")