V8021. Using a unary operator several times is meaningless or reverses the result.
The analyzer has detected that a unary operator (!, ^, -, or +) is used twice in a row in the same expression. Using the operator + multiple times is redundant. In the case of other operators, doing so cancels the effect of the first use.
The example:
func foo() {
....
for _, u := range users {
if !(!hideInactive) && !u.IsActive {
continue
}
....
}
}
The ! operator is applied twice to the hideInactive variable, which is equivalent to not using negation at all. Such an error may occur due to a typo when placing parentheses in the condition.
The fixed code:
if !(!hideInactive && !u.IsActive) {
continue
}