A value is tested to differ from one constant or another, which every value does

tx0/go:always-true-inequalitydefaultwarningbug

What it finds

if s != "a" || s != "b": every value differs from at least one of two different constants, so the condition holds whatever s is. && was meant, to test that s is neither.

Reported are chains of || in which the same expression, without calls or receives, is compared with != to two different constants: integer literals or constant strings.

From the rule's source, always_true_inequality.rs.

Example from the rule's tests
package p func f(s string, n int) bool {	if s != "a" || s != "b" {tx0 reports: s always differs from one of the two constants		return true	}	if n != 1 || s == "c" || n != 2 {tx0 reports: n always differs from one of the two constants		return true	}	return s != "a" && s != "b" || n != 1 || n != 1}
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 in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/go:always-true-inequality" = "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/go:always-true-inequality] reason="..."

tx0 explain tx0/go:always-true-inequality shows the same in the terminal. Found a false positive? Report it.