-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathAV Rule 194.ql
More file actions
18 lines (17 loc) · 927 Bytes
/
AV Rule 194.ql
File metadata and controls
18 lines (17 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
* @name AV Rule 194
* @description All switch statements that do not intend to test for every enumeration value shall contain a final default clause.
* @kind problem
* @id cpp/jsf/av-rule-194
* @problem.severity error
*/
import cpp
from EnumSwitch es, EnumConstant ec
where // A switch without a default case ...
not es.hasDefaultCase() and
// ... that misses at least one value ...
ec = es.getAMissingCase() and
// ... and make sure we pick a single missed value; choose the first one
not exists (EnumConstant ec2, int i, int j |
ec2 = es.getAMissingCase() and ec2 = ec2.getDeclaringEnum().getEnumConstant(i) and ec = ec.getDeclaringEnum().getEnumConstant(j) and i < j)
select es, "AV Rule 195: all switch statements that do not intend to test for every enumeration value shall contain a final default clause. This statement is missing a case for " + ec.getName()