The same string literal is written several times in a file

tx0/kotlin:repeated-string-literalstrictwarningmaintainability/duplicationdepth fastmaintainability

What it finds

A string written in several places, such as a key, a message or a path, must be changed in all of them at once; a constant names it and keeps it in one place. Strings in annotations and imports are left alone, as are short ones.

From the rule's source, duplicated_string.rs.

Example from the rule's tests
fun keys(map: Map<String, Int>): Int {    val a = map["user.settings.theme"] ?: 0tx0 reports: is written 3 times    val b = map["user.settings.theme"] ?: 1    val c = map["user.settings.theme"] ?: 2    val d = map["short"] ?: map["short"] ?: map["short"] ?: 3    return a + b + c + d}
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 strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:repeated-string-literal" = "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:repeated-string-literal] reason="..."

tx0 explain tx0/kotlin:repeated-string-literal shows the same in the terminal. Found a false positive? Report it.