Repository: analysis-dev/diktat (kotlin)

Issue:
RulesConfigReader does not remove whitespaces for testDirs
## Describe the bug
When reading the rules configuration from YAML, whitespaces around entries of `testDirs` are not removed.
https://github.com/analysis-dev/diktat/blob/759c26500de9c86c58af875f750017f14e3d2208/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt#L111-L112

## Expected behavior
Whitespaces are removed, as it is done for `sourceDirectories`:https://github.com/analysis-dev/diktat/blob/759c26500de9c86c58af875f750017f14e3d2208/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt#L148-L149

## Environment information
* diktat version: 1.1.0
* build tool (gradle): 7.4.2
* how is diktat run (CLI, plugin, etc.): spotless
* kotlin version: 1.6.20
* operating system: windows/ubuntu

Pull request description:
What's done:
added trim() for list of string test directories 
Closes #1288

Patch:
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 d4db28b013..cea43d2cc2 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<String, String>?)
      * List of directory names which will be used to detect test sources
      */
     val testAnchors: List<String> 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`")
         }


Test patch:
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