Inspectopedia Help

Switch statement issues

'default' not last case in 'switch'  

Reports a switch statement where the default case comes before another case instead of being the very last case, which may cause confusion.

'switch' statement has missing branches  

Reports a switch statement on a variable of the type enum or union when the statement doesn't cover some value options from the type.

'switch' statement has no 'default' branch  

Reports a switch statement without a default clause when some possible values are not enumerated.

'switch' statement is redundant and can be replaced  

Reports a switch statement with an empty body, or with only one case branch, or with a default branch only.

Duplicate 'case' label  

Reports a duplicated case label on a switch statement, which normally indicates an error.

Fallthrough in 'switch' statement  

Reports a switch statement where control can proceed from a branch to the next one.

Nested 'switch' statement  

Reports a switch statement that is nested in another switch statement.

Text label in 'switch' statement  

Reports a labeled statement inside a switch statement, which often results from a typo.

Unreachable 'case' branch of a 'switch' statement  

Reports an unreachable case branch of a switch statement.

Variable is declared and being used in different 'case' clauses  

Reports a variable that is declared in one case clause of a switch statement but is used in another case clause of the same statement.

Last modified: 29 April 2024