Repository: detekt/detekt (kotlin)

Issue:
When setting `config -> excludes -> ''` to empty string misleading error is logged
## Expected Behavior
Setting `config -> excludes -> ''` should print some error like below
`Value "" set for config parameter "config > excludes" is not of required type List.`

## Observed Behavior
The below error is getting printed
`Value "" set for config parameter "config > excludes" is not of required type EmptyList.`
See `EmptyList`, it should be `List`

## Steps to Reproduce
In latest branch

## Context
Was updating the detekt to latest snapshot

## Your Environment
NA

Pull request description:
Fixes https://github.com/detekt/detekt/issues/7433

Patch:
diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/BaseConfig.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/BaseConfig.kt
index 072556b4ff02..d43dd2826e16 100644
--- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/BaseConfig.kt
+++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/BaseConfig.kt
@@ -41,15 +41,21 @@ fun Config.valueOrDefaultInternal(
     } catch (_: ClassCastException) {
         error(
             "Value \"$result\" set for config parameter \"${keySequence(key)}\" is not of" +
-                " required type ${default::class.simpleName}."
+                " required type ${default::class.simpleName?.let { getDefaultName(it) }}."
         )
     } catch (_: NumberFormatException) {
         error(
             "Value \"$result\" set for config parameter \"${keySequence(key)}\" is not of" +
-                " required type ${default::class.simpleName}."
+                " required type ${default::class.simpleName?.let { getDefaultName(it) }}."
         )
     }
 
+private fun getDefaultName(className: String): String = if (className == "EmptyList") {
+    "List"
+} else {
+    className
+}
+
 fun tryParseBasedOnDefault(result: String, defaultResult: Any): Any = when (defaultResult) {
     is Int -> result.toInt()
     is Boolean ->


Test patch:
diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/YamlConfigSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/YamlConfigSpec.kt
index 355c8024dc24..315e1fdcee8c 100644
--- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/YamlConfigSpec.kt
+++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/YamlConfigSpec.kt
@@ -153,6 +153,17 @@ class YamlConfigSpec {
                     "Value \"[1, 2]\" set for config parameter \"key\" contains non-string values."
             )
         }
+
+        @Test
+        fun `prints meaningful message when string is used instead of list of strings`() {
+            assertThatIllegalStateException().isThrownBy {
+                config.valueOrDefaultInternal(key = "key", result = "", default = emptyList<String>())
+            }.withMessage(
+                """
+                    Value "" set for config parameter "key" is not of required type List.
+                """.trimIndent()
+            )
+        }
     }
 
     @Nested