Skip to content

Commit

Permalink
feature/more-prefixes-boolean-methods(#417)
Browse files Browse the repository at this point in the history
### What's done:
 * Fixed bugs
  • Loading branch information
aktsay6 committed Dec 31, 2020
1 parent 09ffef9 commit 5ea54c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,20 @@ import org.jetbrains.kotlin.psi.psiUtil.parents
*/
@Suppress("ForbiddenComment")
class IdentifierNaming(private val configRules: List<RulesConfig>) : 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
} else {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RulesConfig> = 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
Expand Down Expand Up @@ -419,7 +418,7 @@ class IdentifierNamingWarnTest : LintTestBase(::IdentifierNaming) {
fun fooBar(): Boolean { }
fun equivalentToAnother(): Boolean { }
""".trimIndent(),
rulesConfigList = rulesConfigBooleanFunctions
rulesConfigList = rulesConfigBooleanFunctions
)
}

Expand Down

0 comments on commit 5ea54c7

Please sign in to comment.