Ambiguous non-local 'break' or 'continue'
Reports break
or continue
usages inside of lambdas of loop-like functions.
break
and continue
keywords always apply to the real loops (for
, while
, do-while
). break
and continue
never apply to any function; for example, break
and continue
don't apply to forEach
, filter
, map
.
Using break
or continue
inside a loop-like function (for example, forEach
) may be confusing. The inspection suggests adding a label to clarify to which statement break
or continue
applies to.
Since Kotlin doesn't have a concept of loop-like functions, the inspection uses the heuristic. It assumes that functions that don't have one of callsInPlace(EXACTLY_ONCE)
or callsInPlace(AT_LEAST_ONCE)
contracts are loop-like functions.
Example:
The quick-fix adds clarifying labels:
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.
AmbiguousNonLocalJump- 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.
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Kotlin, 242.22892-IJ |