The analyzer has detected suspicious formatting of the assignment operator and one of the unary operators: !, -, or +. It is most likely a mistake to use these operators—developers probably meant to use one of the following instead: !=, -=, or +=.
The analyzer flags the use of the assignment operator together with logical negation in the condition as suspicious:
let a = .... ;
let b = .... ;
....
if (a =! b) { // <=
....
}
Most likely, the code should include a check that the a variable is not equal to b. If so, the correct code should look like this:
if (a != b) {
....
}
If the goal is to perform an assignment rather than a comparison, it is preferable to fix the formatting to enhance the code's readability:
if (a = !b)
....
A similar error can involve the + and - unary operators. For them, normal statements are considered suspicious, not conditions. Suspicious code may look like this:
let size = ....;
let delta ....;
....
size =- delta; // <=
The code may be correct, but it likely contains a typo, and the developers probably intended to use the -= operator:
size -= delta;
This diagnostic rule is classified as:
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: