A lambda uses the implicit it inside another lambda that has an implicit it too

tx0/kotlin:nested-implicit-itrecommendedwarningmaintainability/complexitydepth fastsmell

What it finds

In items.map { it.children.filter { it.visible } } the inner it hides the outer one, and a reader has to count braces to know which element is meant. Naming one of the parameters makes it plain. Reported when the outer lambda's it is also used.

From the rule's source, shadowed_it.rs.

Example from the rule's tests
fun visible(groups: List<Group>): List<List<Item>> {    val a = groups.map { it.items.filter { it.visible && it.size > 0 } }tx0 reports: this it hides the it of the enclosing lambda    val b = groups.map { group -> group.items.filter { it.visible } }    val c = groups.map { listOf(1).map { it + 1 } }    return a + b}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:nested-implicit-it" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/kotlin:nested-implicit-it] reason="..."

tx0 explain tx0/kotlin:nested-implicit-it shows the same in the terminal. Found a false positive? Report it.