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
}
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: