Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V8021. Using a unary operator...
menu mobile close menu
Additional information
toggle menu Contents

V8021. Using a unary operator several times is meaningless or reverses the result.

May 27 2026

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 
}