Unused return value of a function with lambda expression body
Reports calls with an unused return value when the called function returns a lambda from an expression body.
If there is =
between function header and body block, code from the function will not be evaluated which can lead to incorrect behavior.
Remove = token from function declaration can be used to amend the code automatically.
Example:
fun printHello() = { println("Hello") }
fun main() {
printHello() // This function doesn't print anything
}
After the quick-fix is applied:
fun printHello() { println("Hello") }
fun main() {
printHello()
}
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Kotlin, @snapshot@ |
Last modified: 13 July 2023