File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
csharp/ql/src/Bad Practices/Implementation Hiding Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -29,17 +29,22 @@ predicate returnsCollection(Callable c, Field f) {
29
29
not c .( Modifiable ) .isStatic ( )
30
30
}
31
31
32
- predicate mayWriteToCollection ( Expr modified ) {
33
- modified instanceof CollectionModificationAccess
32
+ predicate nodeMayWriteToCollection ( Node modified ) {
33
+ modified . asExpr ( ) instanceof CollectionModificationAccess
34
34
or
35
- exists ( Expr mid | mayWriteToCollection ( mid ) | localExprFlow ( modified , mid ) )
35
+ exists ( Node mid | nodeMayWriteToCollection ( mid ) | localFlowStep ( modified , mid ) )
36
36
or
37
- exists ( MethodCall mid , Callable c | mayWriteToCollection ( mid ) |
38
- mid .getTarget ( ) = c and
39
- c .canReturn ( modified )
37
+ exists ( Node mid , MethodCall mc , Callable c | nodeMayWriteToCollection ( mid ) |
38
+ mc = mid .asExpr ( ) and
39
+ mc .getTarget ( ) = c and
40
+ c .canReturn ( modified .asExpr ( ) )
40
41
)
41
42
}
42
43
44
+ predicate mayWriteToCollection ( Expr modified ) {
45
+ nodeMayWriteToCollection ( any ( ExprNode n | n .getExpr ( ) = modified ) )
46
+ }
47
+
43
48
predicate modificationAfter ( Expr before , Expr after ) {
44
49
mayWriteToCollection ( after ) and
45
50
localFlowStep + ( exprNode ( before ) , exprNode ( after ) )
You can’t perform that action at this time.
0 commit comments