The name of the rule: “switch” statements should have at least 3 “case” clauses
The MISRA-C:2012 Rule 16.6, which is the base of this sonaqube rule is named as: Every switch statement shall have at least two switch-clauses.
Two, not “Three”.
Here is a compliant example from the MISRA document:
switch ( z )
z = 2;
default: /* Compliant */
z = 0;
This rule is tagged as
based-on-misra, which means we took MISRA into consideration when designing this rule, but our goal was not to make a rules that 100% matches the MISRA specification.
Nevertheless, we agree that in this case, setting the limit to 3 is not a good idea, and we had already created a ticket to change that. You can follow its progress here: https://jira.sonarsource.com/browse/CPP-2437
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.