-
Notifications
You must be signed in to change notification settings - Fork 40
Closed
Description
Describe the bug
False positive findings when lambda operation at the same level:
@Suppress("PARAMETER_NAME_IN_OUTER_LAMBDA")
overrideFunctions.forEach {
functionNameMap.compute(it.getIdentifierName()!!.text) { _, oldValue -> (oldValue ?: 0) + 1 }
} private fun isCheckNeeded(whiteSpace: PsiWhiteSpace) =
whiteSpace.parent
.node
.elementType
.let { it == VALUE_PARAMETER_LIST || it == VALUE_ARGUMENT_LIST } &&
whiteSpace.siblings(forward = false, withItself = false).none { it is PsiWhiteSpace && it.textContains('\n') } &&
@Suppress("PARAMETER_NAME_IN_OUTER_LAMBDA")
// no need to trigger when there are no more parameters in the list
whiteSpace.siblings(forward = true, withItself = false).any {
it.node.elementType.run { this == VALUE_ARGUMENT || this == VALUE_PARAMETER }
} @Suppress("PARAMETER_NAME_IN_OUTER_LAMBDA")
private fun checkBlankLineAfterKdoc(node: ASTNode) {
commentType.forEach {
val kdoc = node.getFirstChildWithType(it)
kdoc?.treeNext?.let { nodeAfterKdoc ->
if (nodeAfterKdoc.elementType == WHITE_SPACE && nodeAfterKdoc.numNewLines() > 1) {
WRONG_NEWLINES_AROUND_KDOC.warnAndFix(configRules, emitWarn, isFixMode, "redundant blank line after ${kdoc.text}", nodeAfterKdoc.startOffset, nodeAfterKdoc) {
nodeAfterKdoc.leaveOnlyOneNewLine()
}
}
}
}
} private fun KSAnnotation.getArgumentValue(argumentName: String): String = arguments
.singleOrNull { it.name?.asString() == argumentName }
.let {
requireNotNull(it) {
"Not found $argumentName in $this"
}
}
.value
?.let { it as? String }
.let {
requireNotNull(it) {
"Not found a value for $argumentName in $this"
}
}Expected behavior
Do not trigger when inner lambda has no it in the code
Observed behavior
Remove suppressing in diktat
Steps to Reproduce
Environment information
- diktat version: 2.0.0
- build tool (maven/gradle): gradle
- how is diktat run (CLI, plugin, etc.): plugin
- kotlin version: 1.9.21
- operating system: Windows
- link to a project (if your project is public): diktat
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working