Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert previously known string property to list based on default value #5347

Merged
merged 2 commits into from Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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`() {
arturbosch marked this conversation as resolved.
Show resolved Hide resolved
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()
}