-
What language is this for? Java
-
Which rule? S1479 - “switch statements should not have too many case clauses”
-
Why do you believe it’s a false-positive/false-negative? The switch statement is directly over an enum type (
OrderStatus
) with 31 cases. According to the rule documentation, switch statements over enums should be ignored. However, SonarQube flags this switch as having too many cases, which seems to be a false positive. -
Are you using
- SonarQube Cloud? No
- SonarQube Server / Community Build - which version? SonarQube Server v2025.1.0 (Build 102418)
- SonarQube for IDE - which IDE/version? No
- in connected mode with SonarQube Server / Community Build or SonarQube Cloud? Connected to SonarQube Server (Community Edition)
-
How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
public enum OrderStatus {
PENDING, PROCESSING, ... UNDER_REVIEW // 31 values
}
public class OrderProcessor {
public void processOrder(OrderStatus status) {
switch (status) {
case PENDING:
System.out.println("Order is pending.");
break;
case PROCESSING:
System.out.println("Order is being processed.");
break;
// ... All 31 cases without any empty case
case UNDER_REVIEW:
System.out.println("Order is under review.");
break;
}
}
}