Inspectopedia
 
2024.3

Conditional expression

Info
Last modified: 03 December 2024

Reports usages of the ternary condition operator and suggests converting them to if/else statements.

Some code standards prohibit the use of the condition operator.

Example:

After the quick-fix is applied:

Configure the inspection:

Use the Ignore for simple assignments and returns option to ignore simple assignments and returns and allow the following constructs:

Use the Ignore places where an if statement is not possible option to ignore conditional expressions in contexts in which automatic replacement with an if statement is not possible (for example, when the conditional expression is used as an argument to a super() constructor call).