KT.UNNECESSARY_FILTER
Unnecessary 'filter()' call
Unnecessary filters add complexity to the code and accomplish nothing. They should be removed.
Noncompliant Code
Copy
val x = listOf(1, 2, 3)
.filter { it > 1 }
.count()
val x = listOf(1, 2, 3)
.filter { it > 1 }
.isEmpty()
Compliant Code
Copy
val x = listOf(1, 2, 3)
.count { it > 2 }
}
val x = listOf(1, 2, 3)
.none { it > 1 }