Inspectopedia Help

Labeled switch rule can have code block

Reports rules of switch expressions or enhanced switch statements with an expression body. These can be converted to code blocks.


String message = switch (errorCode) { case 404 -> "Not found!"; ... };

After the quick-fix is applied:

String message = switch (errorCode) { case 404 -> { yield "Not found!"; } ... };

The inspection only reports if the language level of the project or module is 14 or higher.

New in 2019.1

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Java, 233.SNAPSHOT

Last modified: 13 July 2023