When Select Case statements
have large sets of multi-line Case
clauses, the code becomes hard to read and maintain.
For example, the Cognitive Complexity is going to be particularly high.
In such scenarios, it’s better to refactor the Select Case
to only have single-line case clauses.
When all the Case
clauses of a Select Case
statement are single-line, the readability of the code is not affected.
Exceptions
This rule ignores:
-
Select Case
statements over Enum
arguments
- fall-through cases
-
Return
and Throw
statements in Case
clauses