A var holds a mutable collection, so it can change in two ways
What it finds
var items = mutableListOf<Int>() can be reassigned and changed in place. One of the two is enough: a val with a mutable collection, or a var with a read-only one.
From the rule's source, mutable_collection_in_var.rs.
class Cart { var items = mutableListOf<String>()tx0 reports: items is a var holding a mutable collection val fixed = mutableListOf<String>() var replaced = listOf<String>()} 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:mutable-collection-in-var" = "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:mutable-collection-in-var] reason="..."tx0 explain tx0/kotlin:mutable-collection-in-var shows the same in the terminal. Found a false positive? Report it.