A lambda uses the implicit it inside another lambda that has an implicit it too
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.
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} 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:
[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.