Inspectopedia 2024.3 Help

Switch statement issues

'default' not last case in 'switch'   New in this release

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   New in this release

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   New in this release

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

'switch' statement is redundant and can be replaced   New in this release

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

Duplicate 'case' label   New in this release

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

Fallthrough in 'switch' statement   New in this release

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

Nested 'switch' statement   New in this release

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

Text label in 'switch' statement   New in this release

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

Unreachable 'case' branch of a 'switch' statement   New in this release

Reports an unreachable case branch of a switch statement.

Variable is declared and being used in different 'case' clauses   New in this release

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: 11 September 2024