Back to Intellij Community

ReplaceNegatedIsEmptyWithIsNotEmpty

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ReplaceNegatedIsEmptyWithIsNotEmpty.html

2025.3-rc-2557 B
Original Source

Reports negation isEmpty() and isNotEmpty() for collections and String, or isBlank() and isNotBlank() for String.

Using corresponding functions makes your code simpler.

The quick-fix replaces the negation call with the corresponding call from the Standard Library.

Example:

fun main() {
      val list = listOf(1,2,3)
      if (!list.isEmpty()) {
          // do smth
      }
  }

After the quick-fix is applied:

fun main() {
      val list = listOf(1,2,3)
      if (list.isNotEmpty()) {
          // do smth
      }
  }