From 43324e9b617db7e122424b7bbf1e9d08f241385a Mon Sep 17 00:00:00 2001 From: Andrey Kuleshov Date: Wed, 14 Sep 2022 17:02:58 +0300 Subject: [PATCH] WRONG_OVERLOADING_FUNCTION_ARGUMENTS: adding exceptions to the rule ### What's done: - rule will be triggered if and only if it has same modifiers --- .../rules/chapter5/OverloadingArgumentsFunction.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/OverloadingArgumentsFunction.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/OverloadingArgumentsFunction.kt index 263d22c52a..1cc6fcae17 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/OverloadingArgumentsFunction.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/OverloadingArgumentsFunction.kt @@ -52,10 +52,13 @@ class OverloadingArgumentsFunction(configRules: List) : DiktatRule( /** * We can raise errors only on those methods that have same modifiers (inline/public/etc.) */ - private fun KtFunction.hasSameModifiers(other: KtFunction): Boolean = this.modifierList?.node?.getChildren(KtTokens.MODIFIER_KEYWORDS) - ?.sortedBy { it.text } == - other.modifierList?.node?.getChildren(KtTokens.MODIFIER_KEYWORDS) - ?.sortedBy { it.text } + private fun KtFunction.hasSameModifiers(other: KtFunction) = + this.modifierList?.node?.getChildren(KtTokens.MODIFIER_KEYWORDS) + ?.map { it.text } + ?.sortedBy { it } == + other.modifierList?.node?.getChildren(KtTokens.MODIFIER_KEYWORDS) + ?.map { it.text } + ?.sortedBy { it } /** * we need to compare following things for two functions: