Skip to content

Commit

Permalink
Convert previously known string property to list based on default val…
Browse files Browse the repository at this point in the history
…ue - #5323
  • Loading branch information
arturbosch committed Sep 24, 2022
1 parent d04d85e commit fbfa6d6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Expand Up @@ -57,7 +57,7 @@ open class SplitPattern(
}

/**
* Splits given String into a sequence of strings splited by the provided delimiters ("," by default).
* Splits given String into a sequence of strings split by the provided delimiters ("," by default).
*
* It also trims the strings and removes the empty ones
*/
Expand Down
Expand Up @@ -13,6 +13,7 @@ import org.assertj.core.api.Assertions.assertThatThrownBy
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow
import java.nio.file.Files
import java.nio.file.Path

Expand Down Expand Up @@ -299,4 +300,19 @@ class RunnerSpec {
executeDetekt("--input", inputPath.toString(), "--max-issues", "2")
}
}

@Test
fun `regression - rule property, changed from comma separated string to list, throws on wrapped configs`() {
assertDoesNotThrow {
executeDetekt(
"--all-rules", // wrapped config
"--input",
inputPath.toString(),
"--config-resource",
"configs/return-count-with-string-property.yml",
"--max-issues",
"-1"
)
}
}
}
@@ -0,0 +1,4 @@
style:
ReturnCount:
active: true
excludedFunctions: 'test'
Expand Up @@ -2,6 +2,7 @@ package io.gitlab.arturbosch.detekt.core.config

import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.Config.Companion.CONFIG_SEPARATOR
import io.gitlab.arturbosch.detekt.api.commaSeparatedPattern

private val ALLOWED_BOOL_VALUES = setOf("true", "false")

Expand Down Expand Up @@ -48,5 +49,6 @@ fun tryParseBasedOnDefault(result: String, defaultResult: Any): Any = when (defa
}
is Double -> result.toDouble()
is String -> result
is List<*> -> result.commaSeparatedPattern().toList()
else -> throw ClassCastException()
}

0 comments on commit fbfa6d6

Please sign in to comment.