FP in S128: "Switch cases should end with an unconditional "break" statement"

Hi,
I’m using version 6.7.5 of SonarQube.

Rule “Switch cases should end with an unconditional “break” statement” raises an error on following piece of code:

	switch (in) {
	case 0:
		return 0;
	case 1: // SonarQube violation here: 
            // "End this switch case with an unconditional break, return or throw statement."
		try {
			return doIt();
		} finally {
		}
	default:
		return 99;
	}

For me, in case 1, I always return or throw an exception, even though there’s a finally statement.
Do I miss something or is this a false positive?
Thanks a lot.

Regards,
Nicolas

Hello @nico, thanks for the feedback and the clean reproducer, it’s always appreciated.

I also think this is a wrong behavior of the rule, I created a ticket to improve it.

Best,
Quentin

1 Like