map is followed by filterNotNull, which mapNotNull does in one pass
What it finds
items.map { parse(it) }.filterNotNull() builds an intermediate list with the nulls in it; items.mapNotNull { parse(it) } builds only the result.
From the rule's source, map_then_filter_not_null.rs.
fun parse(items: List<String>) = items.map { it.toIntOrNull() }.filterNotNull()tx0 reports: map { ... }.filterNotNull() is `mapNotNull fun parsed(items: List<String>) = items.mapNotNull { it.toIntOrNull() } Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:map-then-filter-not-null" = "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:map-then-filter-not-null] reason="..."tx0 explain tx0/kotlin:map-then-filter-not-null shows the same in the terminal. Found a false positive? Report it.