Inspectopedia Help

Conditional break inside loop

Reports conditional breaks at the beginning or at the end of a loop and suggests adding a loop condition instead to shorten the code.

Example:

while (true) { if (i == 23) break; i++; }

After the quick fix is applied:

while (i != 23) { i++; }

Inspection options

Option

Type

Default

Don't suggest to replace with 'do while'

Checkbox

false

Allow merging with existing loop condition

Checkbox

false

Suggest conversion when 'if' is a single statement in loop

Checkbox

false

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023