mapOf or setOf lists the same literal key or element twice, so one of them is lost
What it finds
In mapOf("a" to 1, "a" to 2) the second pair replaces the first; in setOf(1, 1) the copy disappears. Either the key was meant to be another one or the line is a leftover.
From the rule's source, duplicate_collection_key.rs.
val codes = mapOf( "ok" to 200, "missing" to 404, "ok" to 201,tx0 reports: is listed twice)val flags = setOf(1, 2, 1)tx0 reports: the element 1 is listed twiceval fine = mapOf("a" to 1, "b" to 1) Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/kotlin:duplicate-key-in-literal-map" = "off"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:duplicate-key-in-literal-map] reason="..."tx0 explain tx0/kotlin:duplicate-key-in-literal-map shows the same in the terminal. Found a false positive? Report it.