A local variable is returned with a postfix ++ or --, so the change is lost
What it finds
return count++; returns the old value and then increments a variable that goes out of scope with the return, so the increment has no effect. For a local variable or a by-value parameter this is never what was meant; return count + 1; or return ++count; says what is wanted.
From the rule's source, returned_postfix_increment.rs.
class Counter{ int total; int Next(int n) { return n++;tx0 reports: return n++ returns the old value and loses the change } int Field() { return total++; }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/csharp:returned-postfix-increment" = "off"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:returned-postfix-increment] reason="..."tx0 explain tx0/csharp:returned-postfix-increment shows the same in the terminal. Found a false positive? Report it.