-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathAV Rule 191.ql
More file actions
29 lines (25 loc) · 835 Bytes
/
AV Rule 191.ql
File metadata and controls
29 lines (25 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @name AV Rule 191
* @description The break statement shall not be used.
* @kind problem
* @id cpp/jsf/av-rule-191
* @problem.severity recommendation
* @tags maintainability
* external/jsf
*/
import cpp
/*
* TODO: "The break statement may be used to break out of a single loop provided
* the alternative would obscure or otherwise significantly complicate the
* control logic."
*/
// whether t is the last statement of s, possibly peeling off blocks
predicate isTerminatingStmt(Stmt s, Stmt t) {
s = t or isTerminatingStmt(s.(BlockStmt).getLastStmt(), t)
}
from BreakStmt s
where
s.fromSource() and
// exclude break statements that terminate switch cases
not exists(SwitchCase sc | isTerminatingStmt(sc.getLastStmt(), s))
select s, "AV Rule 191: The break statement shall not be used."