true or false is an operand of && or ||, so the condition is fixed or the literal does nothing

tx0/csharp:bool-literal-operandrecommendedwarningreliability/logicdepth fastbug

What it finds

x && true is x, and x || false is x; x && false is always false and x || true always true, so the other operand stops mattering. Such literals are often left over from debugging, where a branch was switched off by hand and then forgotten.

From the rule's source, bool_literal_operand.rs.

Example from the rule's tests
class Toggles{    bool A(bool x) => x && true;tx0 reports: the literal in x && true does nothing     bool B(bool x) => false || x;tx0 reports: the literal in false || x does nothing     bool C(bool x) => x && false;tx0 reports: the literal in x && false fixes the result     bool D(bool x, bool y) => x && y;}
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:bool-literal-operand" = "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:bool-literal-operand] reason="..."

tx0 explain tx0/csharp:bool-literal-operand shows the same in the terminal. Found a false positive? Report it.