A local variable or lambda parameter has the name of a parameter or local variable of the enclosing function

tx0/kotlin:local-shadows-outer-namestrictwarningstyle/namingdepth fastsmell

What it finds

val value = value.trim() inside a function with a parameter value hides the parameter for the rest of the block. Reading the code later, it is easy to take one for the other. The Kotlin compiler warns about it as well.

From the rule's source, name_shadowing.rs.

Example from the rule's tests
fun clean(value: String, items: List<String>): String {    val value = value.trim()tx0 reports: value hides a variable of the same name declared before it    val count = items.size    items.forEach { count -> log(count) }tx0 reports: count hides a variable    items.forEach { item -> log(item) }    return value} fun other(value: String) {    val copy = value}
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:local-shadows-outer-name" = "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:local-shadows-outer-name] reason="..."

tx0 explain tx0/kotlin:local-shadows-outer-name shows the same in the terminal. Found a false positive? Report it.