Inspectopedia 2026.3 Help

'if' expression with identical branches

Reports an if expression when its then and else branches execute the same code.

The quick-fix removes the if and keeps one copy of the branch. If evaluating the condition may have side effects, the quick-fix is marked as potentially changing semantics.

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.

IfExpressionWithIdenticalBranches
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 | Kotlin | Redundant constructs

Example:

fun answer(useDefault: Boolean): Int = if (useDefault) 42 else 42
fun answer(useDefault: Boolean): Int = 42

Inspection ID: IfExpressionWithIdenticalBranches

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 IfExpressionWithIdenticalBranches

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 2026.3, Qodana for JVM 2026.3,

Last modified: 20 November 2026