toUpperCase, toLowerCase, capitalize or decapitalize converts case by the default locale
What it finds
These functions use the default locale, so "title".toUpperCase() gives "TİTLE" on a device set to Turkish, which breaks comparisons, keys and protocol text. The standard library deprecates them in favor of uppercase(), lowercase() and replaceFirstChar, which use the invariant locale, or take a locale for text meant for people.
From the rule's source, deprecated_case_conversion.rs.
fun keys(name: String): String { val a = name.toUpperCase()tx0 reports: toUpperCase() depends on the default locale val b = name.capitalize()tx0 reports: capitalize() depends on the default locale val c = name.uppercase() val d = name.toLowerCase(java.util.Locale.ROOT) return a + b + c + d} 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:locale-dependent-case-conversion" = "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:locale-dependent-case-conversion] reason="..."tx0 explain tx0/kotlin:locale-dependent-case-conversion shows the same in the terminal. Found a false positive? Report it.