From bb214e1021d9e140f9f6e9e44d9b4406d5ce33ab Mon Sep 17 00:00:00 2001 From: kentr0w Date: Tue, 26 Jan 2021 15:03:36 +0300 Subject: [PATCH 01/14] Kotlin version ### What's done: Added parameter --- diktat-analysis.yml | 1 + .../cqfn/diktat/common/config/rules/RulesConfigReader.kt | 7 +++++++ diktat-rules/src/main/resources/diktat-analysis-huawei.yml | 1 + diktat-rules/src/main/resources/diktat-analysis.yml | 1 + 4 files changed, 10 insertions(+) diff --git a/diktat-analysis.yml b/diktat-analysis.yml index bb2e9fa348..39585e981a 100644 --- a/diktat-analysis.yml +++ b/diktat-analysis.yml @@ -5,6 +5,7 @@ # put your package name here - it will be autofixed and checked domainName: org.cqfn.diktat # testDirs: test + kotlinVerstion: "" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true 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 c2d2b51be4..3b85960147 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 @@ -116,6 +116,13 @@ data class CommonConfiguration(private val configuration: Map?) configuration?.get("domainName") } + /** + * Get version of kotlin from configuration + */ + val kotlinVersion: String? by lazy { + configuration?.get("kotlinVersion") + } + /** * False if configuration has been read from config file, true if defaults are used */ diff --git a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml index ad2a5e1dcf..32b6db2e77 100644 --- a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml +++ b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml @@ -5,6 +5,7 @@ # put your package name here - it will be autofixed and checked domainName: com.huawei # testDirs: test + kotlinVerstion: "" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true diff --git a/diktat-rules/src/main/resources/diktat-analysis.yml b/diktat-rules/src/main/resources/diktat-analysis.yml index 9af524733e..2fed2611ab 100644 --- a/diktat-rules/src/main/resources/diktat-analysis.yml +++ b/diktat-rules/src/main/resources/diktat-analysis.yml @@ -4,6 +4,7 @@ # put your package name here - it will be autofixed and checked domainName: your.name.here testDirs: test + kotlinVerstion: "" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true From 874295805f1a99a2b6f389495be7b16006a5867e Mon Sep 17 00:00:00 2001 From: kentr0w Date: Tue, 26 Jan 2021 16:32:33 +0300 Subject: [PATCH 02/14] Kotlin version ### What's done: Added default value --- .../org/cqfn/diktat/common/config/rules/RulesConfigReader.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 3b85960147..7505fdfb38 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 @@ -119,8 +119,8 @@ data class CommonConfiguration(private val configuration: Map?) /** * Get version of kotlin from configuration */ - val kotlinVersion: String? by lazy { - configuration?.get("kotlinVersion") + val kotlinVersion: String by lazy { + configuration?.get("kotlinVersion") ?: KotlinVersion.CURRENT.toString() } /** From b08776a7203aaf5829c49e65b0d2ca1c92cdda3c Mon Sep 17 00:00:00 2001 From: kentr0w Date: Tue, 26 Jan 2021 16:33:58 +0300 Subject: [PATCH 03/14] Kotlin version ### What's done: Fixed after review --- diktat-analysis.yml | 4 ++-- diktat-rules/src/main/resources/diktat-analysis-huawei.yml | 4 ++-- diktat-rules/src/main/resources/diktat-analysis.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/diktat-analysis.yml b/diktat-analysis.yml index 39585e981a..2dbd94a271 100644 --- a/diktat-analysis.yml +++ b/diktat-analysis.yml @@ -4,8 +4,8 @@ configuration: # put your package name here - it will be autofixed and checked domainName: org.cqfn.diktat - # testDirs: test - kotlinVerstion: "" + testDirs: test + kotlinVersion: "" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true diff --git a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml index 32b6db2e77..dc7748521e 100644 --- a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml +++ b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml @@ -4,8 +4,8 @@ configuration: # put your package name here - it will be autofixed and checked domainName: com.huawei - # testDirs: test - kotlinVerstion: "" + testDirs: test + kotlinVersion: "" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true diff --git a/diktat-rules/src/main/resources/diktat-analysis.yml b/diktat-rules/src/main/resources/diktat-analysis.yml index 2fed2611ab..4ea1150d8e 100644 --- a/diktat-rules/src/main/resources/diktat-analysis.yml +++ b/diktat-rules/src/main/resources/diktat-analysis.yml @@ -4,7 +4,7 @@ # put your package name here - it will be autofixed and checked domainName: your.name.here testDirs: test - kotlinVerstion: "" + kotlinVersion: "" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true From 33e291ad6739ada96497f544541e72903e1b12f6 Mon Sep 17 00:00:00 2001 From: kentr0w Date: Tue, 26 Jan 2021 16:58:20 +0300 Subject: [PATCH 04/14] Kotlin version ### What's done: Fixed after review --- diktat-analysis.yml | 2 +- .../common/config/rules/RulesConfigReader.kt | 16 ++++++++++++++-- .../main/resources/diktat-analysis-huawei.yml | 2 +- .../src/main/resources/diktat-analysis.yml | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/diktat-analysis.yml b/diktat-analysis.yml index 2dbd94a271..c7ca84c8f3 100644 --- a/diktat-analysis.yml +++ b/diktat-analysis.yml @@ -5,7 +5,7 @@ # put your package name here - it will be autofixed and checked domainName: org.cqfn.diktat testDirs: test - kotlinVersion: "" + kotlinVersion: "1.4.10" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true 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 7505fdfb38..b4bee41552 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 @@ -119,8 +119,8 @@ data class CommonConfiguration(private val configuration: Map?) /** * Get version of kotlin from configuration */ - val kotlinVersion: String by lazy { - configuration?.get("kotlinVersion") ?: KotlinVersion.CURRENT.toString() + val kotlinVersion: KotlinVersion by lazy { + configuration?.get("kotlinVersion")?.kotlinVersion() ?: KotlinVersion.CURRENT } /** @@ -155,3 +155,15 @@ fun List.isRuleEnabled(rule: Rule): Boolean { val ruleMatched = getRuleConfig(rule) return ruleMatched?.enabled ?: true } + +/** + * Parse string into KotlinVersion + */ +fun String.kotlinVersion(): KotlinVersion { + require(this.contains("^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)\$".toRegex())) + val versions = this.split(".").map { it.toInt() } + return if (versions.size == 2) + KotlinVersion(versions[0], versions[1]) + else + KotlinVersion(versions[0], versions[1], versions[2]) +} diff --git a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml index dc7748521e..ed021a80b5 100644 --- a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml +++ b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml @@ -5,7 +5,7 @@ # put your package name here - it will be autofixed and checked domainName: com.huawei testDirs: test - kotlinVersion: "" + kotlinVersion: "1.4.10" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true diff --git a/diktat-rules/src/main/resources/diktat-analysis.yml b/diktat-rules/src/main/resources/diktat-analysis.yml index 4ea1150d8e..db4c741588 100644 --- a/diktat-rules/src/main/resources/diktat-analysis.yml +++ b/diktat-rules/src/main/resources/diktat-analysis.yml @@ -4,7 +4,7 @@ # put your package name here - it will be autofixed and checked domainName: your.name.here testDirs: test - kotlinVersion: "" + kotlinVersion: "1.4.10" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true From ce02a418c15b5779deab7a14907a3b60091a8e9b Mon Sep 17 00:00:00 2001 From: kentr0w Date: Tue, 26 Jan 2021 17:02:00 +0300 Subject: [PATCH 05/14] Kotlin version ### What's done: Fixed after review --- .../org/cqfn/diktat/common/config/rules/RulesConfigReader.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 b4bee41552..a0118d4783 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 @@ -119,8 +119,8 @@ data class CommonConfiguration(private val configuration: Map?) /** * Get version of kotlin from configuration */ - val kotlinVersion: KotlinVersion by lazy { - configuration?.get("kotlinVersion")?.kotlinVersion() ?: KotlinVersion.CURRENT + val kotlinVersion: KotlinVersion? by lazy { + configuration?.get("kotlinVersion")?.kotlinVersion() } /** From 7be2fa6694166614ecb9cf3bfa6e37fa4a29c6b6 Mon Sep 17 00:00:00 2001 From: kentr0w Date: Tue, 26 Jan 2021 17:53:05 +0300 Subject: [PATCH 06/14] Kotlin version ### What's done: Fixed after review --- .../diktat/common/config/rules/RulesConfigReader.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 a0118d4783..af2992bea7 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 @@ -16,6 +16,7 @@ import java.io.File import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromString +import org.cqfn.diktat.common.config.rules.RulesConfigReader.Companion.log const val DIKTAT_COMMON = "DIKTAT_COMMON" @@ -119,8 +120,11 @@ data class CommonConfiguration(private val configuration: Map?) /** * Get version of kotlin from configuration */ - val kotlinVersion: KotlinVersion? by lazy { - configuration?.get("kotlinVersion")?.kotlinVersion() + val kotlinVersion: KotlinVersion by lazy { + configuration?.get("kotlinVersion")?.kotlinVersion() ?: run { + log.error("Kotlin version not specified. Will be use current version") + KotlinVersion.CURRENT + } } /** @@ -160,7 +164,9 @@ fun List.isRuleEnabled(rule: Rule): Boolean { * Parse string into KotlinVersion */ fun String.kotlinVersion(): KotlinVersion { - require(this.contains("^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)\$".toRegex())) + require(this.contains("^(\\d+\\.)(\\d+)\\.?(\\d+)?$".toRegex())) { + "Kotlin version format is incorrect" + } val versions = this.split(".").map { it.toInt() } return if (versions.size == 2) KotlinVersion(versions[0], versions[1]) From 0f51cb99111a18c58a885c62e24cdacd89bc9d92 Mon Sep 17 00:00:00 2001 From: kentr0w Date: Wed, 27 Jan 2021 14:57:34 +0300 Subject: [PATCH 07/14] Kotlin version ### What's done: Fixed after review --- .../common/config/rules/RulesConfigReader.kt | 9 ++-- .../chapter6/classes/InlineClassesRule.kt | 5 +- .../ruleset/chapter6/InlineClassesWarnTest.kt | 54 +++++++++++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-) 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 af2992bea7..02f20d2614 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 @@ -5,6 +5,7 @@ package org.cqfn.diktat.common.config.rules import org.cqfn.diktat.common.config.reader.JsonResourceConfigReader +import org.cqfn.diktat.common.config.rules.RulesConfigReader.Companion.log import com.charleskorn.kaml.Yaml import com.charleskorn.kaml.YamlConfiguration @@ -16,7 +17,6 @@ import java.io.File import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromString -import org.cqfn.diktat.common.config.rules.RulesConfigReader.Companion.log const val DIKTAT_COMMON = "DIKTAT_COMMON" @@ -162,14 +162,17 @@ fun List.isRuleEnabled(rule: Rule): Boolean { /** * Parse string into KotlinVersion + * + * @return KotlinVersion from configuration */ fun String.kotlinVersion(): KotlinVersion { require(this.contains("^(\\d+\\.)(\\d+)\\.?(\\d+)?$".toRegex())) { "Kotlin version format is incorrect" } val versions = this.split(".").map { it.toInt() } - return if (versions.size == 2) + return if (versions.size == 2) { KotlinVersion(versions[0], versions[1]) - else + } else { KotlinVersion(versions[0], versions[1], versions[2]) + } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt index e600621a5d..881efe8f4a 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt @@ -18,6 +18,7 @@ import com.pinterest.ktlint.core.ast.ElementType.PUBLIC_KEYWORD import com.pinterest.ktlint.core.ast.ElementType.SUPER_TYPE_LIST import com.pinterest.ktlint.core.ast.ElementType.VAR_KEYWORD import com.pinterest.ktlint.core.ast.children +import org.cqfn.diktat.common.config.rules.getCommonConfiguration import org.jetbrains.kotlin.com.intellij.lang.ASTNode import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.psiUtil.visibilityModifierType @@ -37,7 +38,8 @@ class InlineClassesRule(private val configRule: List) : Rule("inlin emitWarn = emit isFixMode = autoCorrect - if (node.elementType == CLASS) { + val configuration by configRule.getCommonConfiguration() + if (node.elementType == CLASS && configuration.kotlinVersion.isAtLeast(ktVersion.major, ktVersion.minor, ktVersion.patch)) { handleClasses(node.psi as KtClass) } } @@ -72,6 +74,7 @@ class InlineClassesRule(private val configRule: List) : Rule("inlin ?: false companion object { + val ktVersion = KotlinVersion(1,4,10) val goodModifiers = listOf(PUBLIC_KEYWORD, PRIVATE_KEYWORD, FINAL_KEYWORD, PROTECTED_KEYWORD, INTERNAL_KEYWORD) } } diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt index 2a3cf65760..21611ee4eb 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt @@ -7,12 +7,33 @@ import org.cqfn.diktat.util.LintTestBase import com.pinterest.ktlint.core.LintError import generated.WarningNames +import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON +import org.cqfn.diktat.common.config.rules.RulesConfig +import org.cqfn.diktat.ruleset.constants.Warnings import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { private val ruleId = "$DIKTAT_RULE_SET_ID:inline-classes" + private val rulesConfigListEarlierVersion: List = listOf( + RulesConfig( + DIKTAT_COMMON, true, + mapOf("kotlinVersion" to "1.4.9")) + ) + + private val rulesConfigListSameVersion: List = listOf( + RulesConfig( + DIKTAT_COMMON, true, + mapOf("kotlinVersion" to "1.4.10")) + ) + + private val rulesConfigListLateVersion: List = listOf( + RulesConfig( + DIKTAT_COMMON, true, + mapOf("kotlinVersion" to "1.4.11")) + ) + @Test @Tag(WarningNames.INLINE_CLASS_CAN_BE_USED) fun `should not trigger on inline class`() { @@ -160,4 +181,37 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class LocalCommandExecutor", true) ) } + + @Test + @Tag(WarningNames.INLINE_CLASS_CAN_BE_USED) + fun `check kotlin version`() { + lintMethod( + """ + |class Some { + | val config = Config() + |} + """.trimMargin(), + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", true), + rulesConfigList = rulesConfigListLateVersion + ) + + lintMethod( + """ + |class Some { + | val config = Config() + |} + """.trimMargin(), + rulesConfigList = rulesConfigListEarlierVersion + ) + + lintMethod( + """ + |class Some { + | val config = Config() + |} + """.trimMargin(), + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", true), + rulesConfigList = rulesConfigListSameVersion + ) + } } From 2ad371f72b29c7282deba075eeed0485fba295ff Mon Sep 17 00:00:00 2001 From: kentr0w Date: Wed, 27 Jan 2021 15:09:07 +0300 Subject: [PATCH 08/14] Kotlin version ### What's done: Fixed according our code-style --- .../ruleset/rules/chapter6/classes/InlineClassesRule.kt | 4 ++-- .../cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt index 881efe8f4a..99f1ac0b36 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt @@ -1,6 +1,7 @@ package org.cqfn.diktat.ruleset.rules.chapter6.classes import org.cqfn.diktat.common.config.rules.RulesConfig +import org.cqfn.diktat.common.config.rules.getCommonConfiguration import org.cqfn.diktat.ruleset.constants.EmitType import org.cqfn.diktat.ruleset.constants.Warnings.INLINE_CLASS_CAN_BE_USED import org.cqfn.diktat.ruleset.utils.getFirstChildWithType @@ -18,7 +19,6 @@ import com.pinterest.ktlint.core.ast.ElementType.PUBLIC_KEYWORD import com.pinterest.ktlint.core.ast.ElementType.SUPER_TYPE_LIST import com.pinterest.ktlint.core.ast.ElementType.VAR_KEYWORD import com.pinterest.ktlint.core.ast.children -import org.cqfn.diktat.common.config.rules.getCommonConfiguration import org.jetbrains.kotlin.com.intellij.lang.ASTNode import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.psiUtil.visibilityModifierType @@ -74,7 +74,7 @@ class InlineClassesRule(private val configRule: List) : Rule("inlin ?: false companion object { - val ktVersion = KotlinVersion(1,4,10) + val ktVersion = KotlinVersion(1, 4, 10) val goodModifiers = listOf(PUBLIC_KEYWORD, PRIVATE_KEYWORD, FINAL_KEYWORD, PROTECTED_KEYWORD, INTERNAL_KEYWORD) } } diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt index 21611ee4eb..02ec076f0c 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt @@ -1,5 +1,7 @@ package org.cqfn.diktat.ruleset.chapter6 +import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON +import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.ruleset.constants.Warnings.INLINE_CLASS_CAN_BE_USED import org.cqfn.diktat.ruleset.rules.DIKTAT_RULE_SET_ID import org.cqfn.diktat.ruleset.rules.chapter6.classes.InlineClassesRule @@ -7,9 +9,6 @@ import org.cqfn.diktat.util.LintTestBase import com.pinterest.ktlint.core.LintError import generated.WarningNames -import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON -import org.cqfn.diktat.common.config.rules.RulesConfig -import org.cqfn.diktat.ruleset.constants.Warnings import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test @@ -21,13 +20,11 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { DIKTAT_COMMON, true, mapOf("kotlinVersion" to "1.4.9")) ) - private val rulesConfigListSameVersion: List = listOf( RulesConfig( DIKTAT_COMMON, true, mapOf("kotlinVersion" to "1.4.10")) ) - private val rulesConfigListLateVersion: List = listOf( RulesConfig( DIKTAT_COMMON, true, From 7a98e9081e44b192d62f4e9a1c8b249d4b123a10 Mon Sep 17 00:00:00 2001 From: kentr0w Date: Wed, 27 Jan 2021 15:13:30 +0300 Subject: [PATCH 09/14] Kotlin version ### What's done: Fixed according our code-style --- .../org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt index 02ec076f0c..e9c8a930d2 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt @@ -14,7 +14,6 @@ import org.junit.jupiter.api.Test class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { private val ruleId = "$DIKTAT_RULE_SET_ID:inline-classes" - private val rulesConfigListEarlierVersion: List = listOf( RulesConfig( DIKTAT_COMMON, true, From 8f79d21199b2c67ce06b001b6508fb1ff3bd281c Mon Sep 17 00:00:00 2001 From: kentr0w Date: Thu, 28 Jan 2021 11:11:28 +0300 Subject: [PATCH 10/14] Kotlin version ### What's done: Fixed after review, added more tests --- .../cqfn/diktat/ruleset/constants/Warnings.kt | 2 +- .../chapter6/classes/InlineClassesRule.kt | 9 ++++---- .../ruleset/chapter6/InlineClassesWarnTest.kt | 22 +++++++++---------- .../diktat/ruleset/smoke/DiktatSmokeTest.kt | 8 +++++++ .../smoke/src/main/kotlin/Example5Expected.kt | 2 +- .../smoke/src/main/kotlin/Example5Test.kt | 2 +- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt index 309fb41bf5..25e95848fb 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt @@ -152,7 +152,7 @@ enum class Warnings( AVOID_USING_UTILITY_CLASS(false, "6.4.1", "avoid using utility classes/objects, use extensions functions"), OBJECT_IS_PREFERRED(true, "6.4.2", "it is better to use object for stateless classes"), INVERSE_FUNCTION_PREFERRED(true, "5.1.4", "it is better to use inverse function"), - INLINE_CLASS_CAN_BE_USED(true, "6.1.12", "inline class can be used"), + INLINE_CLASS_CAN_BE_USED(false, "6.1.12", "inline class can be used"), ; /** diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt index 99f1ac0b36..dd254abdb1 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt @@ -39,7 +39,7 @@ class InlineClassesRule(private val configRule: List) : Rule("inlin isFixMode = autoCorrect val configuration by configRule.getCommonConfiguration() - if (node.elementType == CLASS && configuration.kotlinVersion.isAtLeast(ktVersion.major, ktVersion.minor, ktVersion.patch)) { + if (node.elementType == CLASS && configuration.kotlinVersion >= ktVersion) { handleClasses(node.psi as KtClass) } } @@ -49,9 +49,8 @@ class InlineClassesRule(private val configRule: List) : Rule("inlin if (hasValidProperties(classPsi) && !isExtendingClass(classPsi.node) && classPsi.node.getFirstChildWithType(MODIFIER_LIST)?.getChildren(null)?.all { it.elementType in goodModifiers } != false) { - INLINE_CLASS_CAN_BE_USED.warnAndFix(configRule, emitWarn, isFixMode, "class ${classPsi.name}", classPsi.node.startOffset, classPsi.node) { - // Fixme: since it's an experimental feature we shouldn't do fixer - } + // Fixme: since it's an experimental feature we shouldn't do fixer + INLINE_CLASS_CAN_BE_USED.warn(configRule, emitWarn, isFixMode, "class ${classPsi.name}", classPsi.node.startOffset, classPsi.node) } } @@ -74,7 +73,7 @@ class InlineClassesRule(private val configRule: List) : Rule("inlin ?: false companion object { - val ktVersion = KotlinVersion(1, 4, 10) + val ktVersion = KotlinVersion(1, 3) val goodModifiers = listOf(PUBLIC_KEYWORD, PRIVATE_KEYWORD, FINAL_KEYWORD, PROTECTED_KEYWORD, INTERNAL_KEYWORD) } } diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt index e9c8a930d2..8f31bb3bad 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/InlineClassesWarnTest.kt @@ -17,17 +17,17 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { private val rulesConfigListEarlierVersion: List = listOf( RulesConfig( DIKTAT_COMMON, true, - mapOf("kotlinVersion" to "1.4.9")) + mapOf("kotlinVersion" to "1.2.9")) ) private val rulesConfigListSameVersion: List = listOf( RulesConfig( DIKTAT_COMMON, true, - mapOf("kotlinVersion" to "1.4.10")) + mapOf("kotlinVersion" to "1.3")) ) private val rulesConfigListLateVersion: List = listOf( RulesConfig( DIKTAT_COMMON, true, - mapOf("kotlinVersion" to "1.4.11")) + mapOf("kotlinVersion" to "1.3.1")) ) @Test @@ -49,7 +49,7 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { | val config = Config() |} """.trimMargin(), - LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", true) + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", false) ) } @@ -62,7 +62,7 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { | val config = Config() |} """.trimMargin(), - LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", true) + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", false) ) } @@ -87,7 +87,7 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { | |} """.trimMargin(), - LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", true) + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", false) ) } @@ -136,7 +136,7 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { | val some = 3 |} """.trimMargin(), - LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", true) + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", false) ) } @@ -161,7 +161,7 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { | |} """.trimMargin(), - LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class LocalCommandExecutor", true) + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class LocalCommandExecutor", false) ) } @@ -174,7 +174,7 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { | |} """.trimMargin(), - LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class LocalCommandExecutor", true) + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class LocalCommandExecutor", false) ) } @@ -187,7 +187,7 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { | val config = Config() |} """.trimMargin(), - LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", true), + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", false), rulesConfigList = rulesConfigListLateVersion ) @@ -206,7 +206,7 @@ class InlineClassesWarnTest : LintTestBase(::InlineClassesRule) { | val config = Config() |} """.trimMargin(), - LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", true), + LintError(1, 1, ruleId, "${INLINE_CLASS_CAN_BE_USED.warnText()} class Some", false), rulesConfigList = rulesConfigListSameVersion ) } diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt index 814acea291..7516e14e2b 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt @@ -119,6 +119,10 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", | | http://www.apache.org/licenses/LICENSE-2.0 """.trimMargin() + ), + DIKTAT_COMMON to mapOf( + "domainName" to "org.cqfn.diktat", + "kotlinVersion" to "1.3.7" ) ) ) @@ -127,6 +131,10 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", Assertions.assertFalse( unfixedLintErrors.contains(LintError(line = 1, col = 1, ruleId = "diktat-ruleset:comments", detail = "${Warnings.COMMENTED_OUT_CODE.warnText()} /*")) ) + + Assertions.assertTrue( + unfixedLintErrors.contains(LintError(1, 1, "diktat-ruleset:inline-classes", "${Warnings.INLINE_CLASS_CAN_BE_USED.warnText()} class Some")) + ) } @Test diff --git a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Expected.kt b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Expected.kt index e1f8ad1003..73d8187164 100644 --- a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Expected.kt +++ b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Expected.kt @@ -10,6 +10,6 @@ package org.cqfn.diktat class Some { - + val config = Config() } diff --git a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Test.kt b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Test.kt index 7396489e1a..d54fe0ad3f 100644 --- a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Test.kt +++ b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/Example5Test.kt @@ -1,5 +1,5 @@ package org.cqfn.diktat class Some { - + val config = Config() } From 65e34e509afba239173217947ee53435e11059dd Mon Sep 17 00:00:00 2001 From: kentr0w Date: Thu, 28 Jan 2021 19:20:32 +0300 Subject: [PATCH 11/14] Kotlin version ### What's done: Fixed after review --- diktat-analysis.yml | 2 +- .../common/config/rules/RulesConfigReader.kt | 2 +- .../src/main/resources/diktat-analysis-huawei.yml | 2 +- .../src/main/resources/diktat-analysis.yml | 2 +- .../diktat/ruleset/utils/RulesConfigYamlTest.kt | 14 +++++++++++++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/diktat-analysis.yml b/diktat-analysis.yml index f61ecf96f5..033aa0b5b8 100644 --- a/diktat-analysis.yml +++ b/diktat-analysis.yml @@ -7,7 +7,7 @@ # testDirs: test disabledChapters: "" testDirs: test - kotlinVersion: "1.4.10" + kotlinVersion: "1.4.21" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true 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 2bca488a8d..ad5306a013 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 @@ -129,7 +129,7 @@ data class CommonConfiguration(private val configuration: Map?) */ val kotlinVersion: KotlinVersion by lazy { configuration?.get("kotlinVersion")?.kotlinVersion() ?: run { - log.error("Kotlin version not specified. Will be use current version") + log.error("Kotlin version not specified. Will be use ${KotlinVersion.CURRENT} version") KotlinVersion.CURRENT } } diff --git a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml index 1f77b40a60..223a92cfd7 100644 --- a/diktat-rules/src/main/resources/diktat-analysis-huawei.yml +++ b/diktat-rules/src/main/resources/diktat-analysis-huawei.yml @@ -7,7 +7,7 @@ # testDirs: test disabledChapters: "" testDirs: test - kotlinVersion: "1.4.10" + kotlinVersion: "1.4.21" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true diff --git a/diktat-rules/src/main/resources/diktat-analysis.yml b/diktat-rules/src/main/resources/diktat-analysis.yml index 2b884f913e..32bf0e43dc 100644 --- a/diktat-rules/src/main/resources/diktat-analysis.yml +++ b/diktat-rules/src/main/resources/diktat-analysis.yml @@ -5,7 +5,7 @@ domainName: your.name.here testDirs: test disabledChapters: "" - kotlinVersion: "1.4.10" + kotlinVersion: "1.4.21" # Checks that the Class/Enum/Interface name does not match Pascal case - name: CLASS_NAME_INCORRECT enabled: true diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt index da18bc44ea..e112268bed 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt @@ -1,8 +1,10 @@ package org.cqfn.diktat.ruleset.utils +import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.RulesConfigReader import org.cqfn.diktat.common.config.rules.getRuleConfig +import org.cqfn.diktat.common.config.rules.kotlinVersion import org.cqfn.diktat.ruleset.constants.Warnings import com.charleskorn.kaml.Yaml @@ -26,7 +28,7 @@ inline class RulesConfigYamlTest(private val pathMap: Map = compareRulesAndConfig("diktat-analysis.yml") compareRulesAndConfig("diktat-analysis-huawei.yml") val thirdConfig = "${System.getProperty("user.dir")}${File.separator}..${File.separator}diktat-analysis.yml${File.separator}" - compareRulesAndConfig(thirdConfig, "parent/diktat-analysis.yml") + compareRulesAndConfig(thirdConfig, ".../diktat-analysis.yml") } @Test @@ -36,6 +38,16 @@ inline class RulesConfigYamlTest(private val pathMap: Map = checkComments("../diktat-analysis.yml") } + @Test + fun `check kotlin version`() { + val currentKotlinVersion = KotlinVersion.CURRENT + pathMap.keys.forEach { path -> + val config = readAllRulesFromConfig(path) + val ktVersion = config.find { it.name == DIKTAT_COMMON }?.configuration?.get("kotlinVersion")?.kotlinVersion() + Assertions.assertEquals(ktVersion, currentKotlinVersion) + } + } + private fun checkComments(configName: String) { val lines = File(configName) .readLines() From f33ba071eb6ae1a3d3b17bce1ec2819663bc3d66 Mon Sep 17 00:00:00 2001 From: kentr0w Date: Sat, 30 Jan 2021 17:52:47 +0300 Subject: [PATCH 12/14] Kotlin version ### What's done: Fixed bugs accordign our code-style --- .../org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt index e112268bed..7dba198ce5 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt @@ -43,7 +43,10 @@ inline class RulesConfigYamlTest(private val pathMap: Map = val currentKotlinVersion = KotlinVersion.CURRENT pathMap.keys.forEach { path -> val config = readAllRulesFromConfig(path) - val ktVersion = config.find { it.name == DIKTAT_COMMON }?.configuration?.get("kotlinVersion")?.kotlinVersion() + val ktVersion = config.find { it.name == DIKTAT_COMMON } + ?.configuration + ?.get("kotlinVersion") + ?.kotlinVersion() Assertions.assertEquals(ktVersion, currentKotlinVersion) } } From 443ff0165a2a1f56627fa362e9dd2c7f2d6d28da Mon Sep 17 00:00:00 2001 From: kentr0w Date: Mon, 1 Feb 2021 12:41:25 +0300 Subject: [PATCH 13/14] Kotlin version ### What's done: Fixed after review --- .../common/config/rules/RulesConfigReader.kt | 2 +- .../org/cqfn/diktat/test/ConfigReaderTest.kt | 18 +++++++++++++++++- .../src/test/resources/test-rules-config.yml | 1 + .../ruleset/utils/RulesConfigYamlTest.kt | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) 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 ad5306a013..1c34c2a34d 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 @@ -129,7 +129,7 @@ data class CommonConfiguration(private val configuration: Map?) */ val kotlinVersion: KotlinVersion by lazy { configuration?.get("kotlinVersion")?.kotlinVersion() ?: run { - log.error("Kotlin version not specified. Will be use ${KotlinVersion.CURRENT} version") + log.error("Kotlin version not specified in the configuration file. Will be using ${KotlinVersion.CURRENT} version") KotlinVersion.CURRENT } } 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 c27dd630a8..60a352b06c 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 @@ -2,6 +2,9 @@ package org.cqfn.diktat.test import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.RulesConfigReader +import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON +import org.cqfn.diktat.common.config.rules.getCommonConfiguration +import org.cqfn.diktat.common.config.rules.kotlinVersion import org.junit.jupiter.api.Test class ConfigReaderTest { @@ -13,6 +16,19 @@ class ConfigReaderTest { assert(rulesConfigList.any { it.name == "CLASS_NAME_INCORRECT" && it.enabled }) assert(rulesConfigList.find { it.name == "CLASS_NAME_INCORRECT" }?.configuration == emptyMap()) assert(rulesConfigList.find { it.name == "DIKTAT_COMMON" } - ?.configuration == mapOf("domainName" to "org.cqfn.diktat")) + ?.configuration?.get("domainName") == "org.cqfn.diktat") + } + + @Test + fun `testing kotlin version`() { + val rulesConfigList: List? = RulesConfigReader(javaClass.classLoader) + .readResource("src/test/resources/test-rules-config.yml") + val currentKotlinVersion = KotlinVersion.CURRENT + requireNotNull(rulesConfigList) + assert(rulesConfigList.getCommonConfiguration().value.kotlinVersion == currentKotlinVersion) + assert(rulesConfigList.find { it.name == DIKTAT_COMMON } + ?.configuration + ?.get("kotlinVersion") + ?.kotlinVersion() == currentKotlinVersion) } } diff --git a/diktat-common/src/test/resources/test-rules-config.yml b/diktat-common/src/test/resources/test-rules-config.yml index 9219ba23ac..be6c9f20ee 100644 --- a/diktat-common/src/test/resources/test-rules-config.yml +++ b/diktat-common/src/test/resources/test-rules-config.yml @@ -2,6 +2,7 @@ enabled: true configuration: domainName: org.cqfn.diktat + kotlinVersion: 1.4.21 - name: CLASS_NAME_INCORRECT enabled: true - name: CONSTANT_UPPERCASE diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt index 7dba198ce5..97739f4a31 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt @@ -28,7 +28,7 @@ inline class RulesConfigYamlTest(private val pathMap: Map = compareRulesAndConfig("diktat-analysis.yml") compareRulesAndConfig("diktat-analysis-huawei.yml") val thirdConfig = "${System.getProperty("user.dir")}${File.separator}..${File.separator}diktat-analysis.yml${File.separator}" - compareRulesAndConfig(thirdConfig, ".../diktat-analysis.yml") + compareRulesAndConfig(thirdConfig, "../diktat-analysis.yml") } @Test From e73c41989893c798d73f7c48a635b16607cb8450 Mon Sep 17 00:00:00 2001 From: kentr0w Date: Mon, 1 Feb 2021 12:53:03 +0300 Subject: [PATCH 14/14] Kotlin version ### What's done: Fixed according our code-style --- .../src/test/kotlin/org/cqfn/diktat/test/ConfigReaderTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 60a352b06c..b1b624a80e 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 @@ -1,8 +1,8 @@ package org.cqfn.diktat.test +import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.RulesConfigReader -import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON import org.cqfn.diktat.common.config.rules.getCommonConfiguration import org.cqfn.diktat.common.config.rules.kotlinVersion import org.junit.jupiter.api.Test