cpp:NonEmptyCaseWithoutBreak false positive for [[std::fallthrough]]

  • SonarQube Developer Edition Version 7.9.1 (build 27448)

Static code analysis reports a blocker code smell for rule cpp:NonEmptyCaseWithoutBreak although [[std::fallthrough]]; was used.

Hello @fbeier,

The attribute for fall-through is [[fallthrough]], not [[std::fallthrough]]. Could you update your code accordingly and tell us if it works?

Thank you!

Thanks a lot! That was indeed our mistake. Using the correct [[fallthrough]] fixes the issue, and Sonarqube no longer reports “NonEmptyCaseWithoutBreak”. (Felix and I a working together on this.)

Our SQ may not be fully up to date, but the explanation of the rule didn’t mention that using [[fallthrough]] is a valid and conforming solution. Could you please have a look and get the rule’s description updated?

Best regards,
Knut

I just updated the description, it will be available in the next release.
Thank you!

1 Like