A local variable is declared and never used afterwards

tx0/csharp:unused-localrecommendedwarningmaintainability/dead-codedepth fastsmell

What it finds

A local variable that nothing reads or writes after its declaration is dead: either its use was forgotten, or the declaration is left over from an edit. Its initializer may still be needed for its effect, in which case the call can stand alone or be assigned to _. using declarations, which matter for their disposal, are left alone.

From the rule's source, unused_local.rs.

Example from the rule's tests
class Totals{    int Sum(int[] values)    {        int count = values.Length;tx0 reports: count is never used        int total = 0;        foreach (var v in values)        {            total += v;        }        return total;    }}
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 recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:unused-local" = "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/csharp:unused-local] reason="..."

tx0 explain tx0/csharp:unused-local shows the same in the terminal. Found a false positive? Report it.