Skip to content

Commit c449469

Browse files
committed
QL: add query detecting fields that are only used within the charpred
1 parent 70f4efb commit c449469

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @name Field only used in CharPred
3+
* @description A field only being used in the charpred suggests that the field should be inlined into the charpred.
4+
* @kind problem
5+
* @problem.severity recommendation
6+
* @id ql/field-only-used-in-charpred
7+
* @tags correctness
8+
* @precision very-high
9+
*/
10+
11+
import ql
12+
13+
from Class c, FieldDecl f
14+
where
15+
c.getAField() = f and
16+
forex(FieldAccess access | access.getDeclaration() = f.getVarDecl() |
17+
access.getEnclosingPredicate() = c.getCharPred()
18+
) and
19+
not f.getVarDecl().overrides(_) and
20+
f.getLocation().getFile().getAbsolutePath().matches("%/javascript/%")
21+
select f, "Field is only used in CharPred"

0 commit comments

Comments
 (0)