From cbd74b1e565804f942a478a1bb7bb1a0841f2cc2 Mon Sep 17 00:00:00 2001 From: Vfrolov Date: Thu, 27 Oct 2022 12:09:14 +0300 Subject: [PATCH 1/2] Added trim() for testDirs value ### What's done: * added trim() for testDirs value Closes #1288 --- .../org/cqfn/diktat/common/config/rules/RulesConfigReader.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt b/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt index 78eee8f29d..2d64237765 100644 --- a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt +++ b/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt @@ -125,7 +125,7 @@ data class CommonConfiguration(private val configuration: Map?) * List of directory names which will be used to detect test sources */ val testAnchors: List by lazy { - val testDirs = (configuration ?: emptyMap()).getOrDefault("testDirs", "test").split(',') + val testDirs = (configuration ?: emptyMap()).getOrDefault("testDirs", "test").split(',').map { it.trim() } if (testDirs.any { !it.lowercase(Locale.getDefault()).endsWith("test") }) { log.error("test directory names should end with `test`") } From 96a28c0af780b62cbbbd932ce515bf8ec84fb329 Mon Sep 17 00:00:00 2001 From: Vfrolov Date: Fri, 28 Oct 2022 13:52:00 +0300 Subject: [PATCH 2/2] Added trim() for list of string test directories ### What's done: * Added trim() for list of string test directories Closes #1288 --- .../src/test/kotlin/org/cqfn/diktat/test/ConfigReaderTest.kt | 1 + diktat-common/src/test/resources/test-rules-config.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/diktat-common/src/test/kotlin/org/cqfn/diktat/test/ConfigReaderTest.kt b/diktat-common/src/test/kotlin/org/cqfn/diktat/test/ConfigReaderTest.kt index 8d3287aa42..4d0802e289 100644 --- a/diktat-common/src/test/kotlin/org/cqfn/diktat/test/ConfigReaderTest.kt +++ b/diktat-common/src/test/kotlin/org/cqfn/diktat/test/ConfigReaderTest.kt @@ -25,6 +25,7 @@ class ConfigReaderTest { .readResource("src/test/resources/test-rules-config.yml") requireNotNull(rulesConfigList) assert(rulesConfigList.getCommonConfiguration().kotlinVersion == kotlinVersion) + assert(rulesConfigList.getCommonConfiguration().testAnchors.contains("androidUnitTest")) assert(rulesConfigList.find { it.name == DIKTAT_COMMON } ?.configuration ?.get("kotlinVersion") diff --git a/diktat-common/src/test/resources/test-rules-config.yml b/diktat-common/src/test/resources/test-rules-config.yml index 0e20745031..7ae20b78b7 100644 --- a/diktat-common/src/test/resources/test-rules-config.yml +++ b/diktat-common/src/test/resources/test-rules-config.yml @@ -3,6 +3,7 @@ configuration: domainName: org.cqfn.diktat kotlinVersion: 1.4.21 + testDirs: "test, androidUnitTest" - name: CLASS_NAME_INCORRECT enabled: true - name: CONSTANT_UPPERCASE