Inspectopedia 2025.3 Help

Conditional expression

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:

Object result = (condition) ? foo() : bar();

After the quick-fix is applied:

Object result; if (condition) { comp = foo(); } else { comp = bar(); }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

ConditionalExpression
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Control flow issues

Configure the inspection:

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

String s = (foo == null) ? "" : foo.toString();

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).

Inspection ID: ConditionalExpression

Inspection options

Here you can find the description of settings available for the Conditional expression inspection, and the reference of their default values.

Ignore for simple assignments and returns

Option ID:

ignoreSimpleAssignmentsAndReturns

Default value:

Not selected
Ignore places where an if statement is not possible

Option ID:

ignoreExpressionContext

Default value:

Selected

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection ConditionalExpression

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.3, Qodana for JVM 2025.3,

Last modified: 03 December 2025