A local variable is declared but never used

tx0/cpp:unused-local-variablestrictwarningmaintainability/dead-codedepth fastsmell

What it finds

int unused;: a variable the function never mentions again is noise, and often a sign that code meant to use it uses another variable.

The name must occur nowhere else in the function, also not in macros or in branches of conditional directives that are not read, and the declaration must not be marked as possibly unused or bound to a register.

From the rule's source, unused_local_variable.rs.

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/cpp:unused-local-variable" = "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/cpp:unused-local-variable] reason="..."

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