``++switch++`` statements are useful when there are many different cases depending on the value of the same expression. For just one or two cases however, the code will be more readable with ``++if++`` statements.


Moreover, ``++if++`` statements are obviously more suitable when the condition of the ``++switch++`` is boolean.


Here are the rules to count the cases:

* ``++default++`` is counted as a case.
* If there is no ``++default++`` clause, the ``++case++`` count is incremented by one (to account for the ``++else++`` branch of an equivalent ``++if++``).
* All the cases falling through to ``++default++`` are not counted (they would all be the ``++else++`` branch of the equivalent ``++if++``).

include::../noncompliant.adoc[]

include::../compliant.adoc[]

== See

* MISRA C:2012, 16.6 - Every switch statement shall have at least two switch-clauses

ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]
