IDE code-improvement suggestion

Answered

I wrote:

    fun appNameToDBKey(name: String) = name.lowercase().filterNot { it.isWhitespace() }

but this is better (more succinctly and efficiently) written as

    fun appNameToDBKey(name: String) = name.lowercase().filterNot(Char::isWhitespace)

Could IntelliJ detect cases like this, where a trivial function does nothing but call another function, and suggest using the called function directly?

0
2 comments
Hi, this is usually solved by the intention "Convert lambda to reference" that wasn't working for quite some time (related to the bug KTIJ-32330 (https://youtrack.jetbrains.com/issue/KTIJ-32330)). However, it's already been fixed in the future versions of IntelliJ IDEA (2026.2 EAP).
0

Please sign in to leave a comment.