The analyzer detected a potential error in the use of the ?: ternary operator. The same action is performed for both possible outcomes of the condition. Most likely, there is a typo in the code or it is redundant.
Look at this example:
let result = flag ? x : x;
The result variable is always assigned the value of the x variable. Most likely, a developer intended to use another variable:
let result = flag ? x : y;
Non-identical but equivalent expressions are also taken into account. For example, for this code snippet:
let result = flag ? x * y : y * x;
The analyzer issues a warning, as the multiplication is commutative and the result will be equivalent.
This diagnostic rule is classified as:
You can look at examples of errors detected by the V7012 diagnostic. |
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: