Two reflect.Values are compared with ==, which compares their internals rather than the values they hold
What it finds
reflect.ValueOf(a) == reflect.ValueOf(b): a reflect.Value is a struct with a type, a pointer and flags, and == compares those, so two values holding equal data are usually unequal. Value.Equal, Interface() compared with ==, or reflect.DeepEqual compare what the values hold.
An operand of == or != must be a call of reflect.ValueOf or reflect.Indirect, resolved through the imports of the file, and the other operand must not be nil.
From the rule's source, reflect_value_equality.rs.
package p import "reflect" func f(a, b any, v reflect.Value) bool { if reflect.ValueOf(a) == reflect.ValueOf(b) {tx0 reports: == on reflect.Values compares their internals, not the values they hold return true } if v != reflect.ValueOf(b) {tx0 reports: != on reflect.Values compares their internals, not the values they hold return true } return reflect.ValueOf(a).Equal(reflect.ValueOf(b)) || reflect.TypeOf(a) == reflect.TypeOf(b)} 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/go:reflect-value-equality" = "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:reflect-value-equality] reason="..."tx0 explain tx0/go:reflect-value-equality shows the same in the terminal. Found a false positive? Report it.