From 1dc5b157aac91a903ef4782adf8c1dd9ccaefcce Mon Sep 17 00:00:00 2001 From: Gouri Panda Date: Sat, 16 Jul 2022 00:04:54 +0530 Subject: [PATCH] ReturnCount.excludedFunctions should be a List --- detekt-core/src/main/resources/default-detekt-config.yml | 3 ++- .../io/gitlab/arturbosch/detekt/rules/style/ReturnCount.kt | 4 ++-- .../gitlab/arturbosch/detekt/rules/style/ReturnCountSpec.kt | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/detekt-core/src/main/resources/default-detekt-config.yml b/detekt-core/src/main/resources/default-detekt-config.yml index 462058ca590..b83d5201eb6 100644 --- a/detekt-core/src/main/resources/default-detekt-config.yml +++ b/detekt-core/src/main/resources/default-detekt-config.yml @@ -626,7 +626,8 @@ style: ReturnCount: active: true max: 2 - excludedFunctions: 'equals' + excludedFunctions: + - 'equals' excludeLabeled: false excludeReturnFromLambda: true excludeGuardClauses: false diff --git a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCount.kt b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCount.kt index 1d6d69e53eb..d0ffdba332c 100644 --- a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCount.kt +++ b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCount.kt @@ -59,8 +59,8 @@ class ReturnCount(config: Config = Config.empty) : Rule(config) { @Configuration("define the maximum number of return statements allowed per function") private val max: Int by config(2) - @Configuration("define a free-form comma separated list of function names to be ignored by this check") - private val excludedFunctions: SplitPattern by config("equals") { SplitPattern(it) } + @Configuration("define a list of function names to be ignored by this check") + private val excludedFunctions: SplitPattern by config(listOf("equals")) { SplitPattern(it.joinToString(",")) } @Configuration("if labeled return statements should be ignored") private val excludeLabeled: Boolean by config(false) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCountSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCountSpec.kt index 9abd3b37a9b..1ce28adf704 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCountSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCountSpec.kt @@ -347,7 +347,7 @@ class ReturnCountSpec { TestConfig( mapOf( MAX to "2", - EXCLUDED_FUNCTIONS to "test1,test2" + EXCLUDED_FUNCTIONS to listOf("test1", "test2") ) ) ).compileAndLint(code)