From 5ea54c76cd6cf247d48581e3d7a03eb0649207a3 Mon Sep 17 00:00:00 2001 From: aktsay Date: Thu, 31 Dec 2020 13:20:25 +0300 Subject: [PATCH] feature/more-prefixes-boolean-methods(#417) ### What's done: * Fixed bugs --- .../diktat/ruleset/rules/IdentifierNaming.kt | 16 +++++++--------- .../ruleset/chapter1/IdentifierNamingWarnTest.kt | 7 +++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt index e661476607..eb45669995 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt @@ -82,15 +82,6 @@ import org.jetbrains.kotlin.psi.psiUtil.parents */ @Suppress("ForbiddenComment") class IdentifierNaming(private val configRules: List) : Rule("identifier-naming") { - private var isFixMode: Boolean = false - private lateinit var emitWarn: EmitType - - val configuration by lazy { - BooleanFunctionsConfiguration( - this.configRules.getRuleConfig(FUNCTION_BOOLEAN_PREFIX)?.configuration ?: emptyMap() - ) - } - private val allMethodPrefixes by lazy { if (configuration.allowedBooleanPrefixes.isNullOrEmpty()) { booleanMethodPrefixes @@ -98,6 +89,13 @@ class IdentifierNaming(private val configRules: List) : Rule("ident booleanMethodPrefixes + configuration.allowedBooleanPrefixes.filter { it.isNotEmpty() } } } + private var isFixMode: Boolean = false + private lateinit var emitWarn: EmitType + val configuration by lazy { + BooleanFunctionsConfiguration( + this.configRules.getRuleConfig(FUNCTION_BOOLEAN_PREFIX)?.configuration ?: emptyMap() + ) + } override fun visit( node: ASTNode, diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingWarnTest.kt index 1bf4b2a746..73e98946ac 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingWarnTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingWarnTest.kt @@ -26,10 +26,9 @@ import org.junit.jupiter.api.Test class IdentifierNamingWarnTest : LintTestBase(::IdentifierNaming) { private val ruleId: String = "$DIKTAT_RULE_SET_ID:identifier-naming" - private val rulesConfigBooleanFunctions: List = listOf( - RulesConfig(FUNCTION_BOOLEAN_PREFIX.name, true, - mapOf("allowedPrefixes" to "equals, equivalent, foo")) + RulesConfig(FUNCTION_BOOLEAN_PREFIX.name, true, + mapOf("allowedPrefixes" to "equals, equivalent, foo")) ) // ======== checks for generics ======== @Test @@ -419,7 +418,7 @@ class IdentifierNamingWarnTest : LintTestBase(::IdentifierNaming) { fun fooBar(): Boolean { } fun equivalentToAnother(): Boolean { } """.trimIndent(), - rulesConfigList = rulesConfigBooleanFunctions + rulesConfigList = rulesConfigBooleanFunctions ) }