diktat icon indicating copy to clipboard operation
diktat copied to clipboard

RulesConfigReader does not remove whitespaces for testDirs

Open HaukeRa opened this issue 3 years ago • 2 comments

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

HaukeRa avatar May 03 '22 14:05 HaukeRa

Could you please provide an example of such yml config?

orchestr7 avatar May 03 '22 14:05 orchestr7

Sure:

- name: DIKTAT_COMMON
  configuration:
    domainName: com.example
    testDirs: "test, androidUnitTest"
    # expected values:  disabledChapters: "Naming, Comments, General, Variables, Functions, Classes"
    # or: "1, 2, 3, 4, 5, 6"
    disabledChapters: ""
    kotlinVersion: 1.6
    srcDirectories: "main, commonMain, iosMain, jvmMain, androidMain"

the androidUnitTest directory does not get its whitespace removed and is handled as ⎵androidUnitTest, effectively causing many problems in the corresponding inspections.

Of course the list could be defined without the space, but as it is often used for readability and also the srcDirectories entries get potential whitespaces removed, both lists should behave the same.

HaukeRa avatar May 03 '22 19:05 HaukeRa