Inspectopedia
 
2024.3

Assignment used as condition

Warning
Last modified: 03 December 2024

Reports assignments that are used as a condition of an if, while, for, or do statement, or a conditional expression.

Although occasionally intended, this usage is confusing and may indicate a typo, for example, = instead of ==.

The quick-fix replaces = with ==.

Example:

After the quick-fix is applied: