Skip to content

Commit

Permalink
Fix NestedScopeFunctions detekt errors
Browse files Browse the repository at this point in the history
  • Loading branch information
WildOrangutan committed May 2, 2022
1 parent d5368cb commit 499ef41
Showing 1 changed file with 4 additions and 6 deletions.
Expand Up @@ -121,17 +121,15 @@ class NestedScopeFunctions(config: Config = Config.empty) : Rule(config) {

private fun KtCallExpression.isScopeFunction(): Boolean {
val descriptors = resolveDescriptors()
val descriptor = descriptors.find { it.matchesScopeFunction() }
return descriptor != null
return !descriptors.any { it.matchesScopeFunction() }
}

private fun KtCallExpression.resolveDescriptors(): List<CallableDescriptor> =
getResolvedCall(bindingContext)?.resultingDescriptor
?.let { listOf(it) + it.overriddenDescriptors }
?: emptyList()
.orEmpty()

private fun CallableDescriptor.matchesScopeFunction(): Boolean {
return functions.find { it.match(this) } != null
}
private fun CallableDescriptor.matchesScopeFunction(): Boolean =
!functions.any { it.match(this) }
}
}

0 comments on commit 499ef41

Please sign in to comment.