[false-negative]S1219 can not detect non-case labels which are wrapped in braces

Affects Sonarqube Version:
Sonarqube version:
sonar-scanner version:

S1219: “switch” statements should not contain non-case labels

Unable to detect non-case labels which are wrapped in braces.
This rule is implemented in java-checks-!\org\sonar\java\checks\SwitchWithLabelsCheck.java,
This rule uses for (StatementTree statementTree : cgt.body()) to traverse all StatementTree under the switch, and then uses if (statementTree.is(LABELED_STATEMENT)) to determine whether it is a non-case label.
When non-case labels are wrapped in braces, they may no longer belong to cgt.body().

Code Sample demonstrating the issue:

switch (state) {
	// Seeking the first character of a new word
	case NEW:
		newSwitch:	// unable to detect this label
		switch (c) {
			// Empty word
			case ',':

Expected outcome:

Running Sonarqube through:
command line

Hello @wongwuchiu,

I agree that it makes sense to detect this case, so I created a ticket. Thank you for your report.