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) {
2929 not c .( Modifiable ) .isStatic ( )
3030}
3131
32- predicate mayWriteToCollection ( Expr modified ) {
33- modified instanceof CollectionModificationAccess
32+ predicate nodeMayWriteToCollection ( Node modified ) {
33+ modified . asExpr ( ) instanceof CollectionModificationAccess
3434 or
35- exists ( Expr mid | mayWriteToCollection ( mid ) | localExprFlow ( modified , mid ) )
35+ exists ( Node mid | nodeMayWriteToCollection ( mid ) | localFlowStep ( modified , mid ) )
3636 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 ( ) )
4041 )
4142}
4243
44+ predicate mayWriteToCollection ( Expr modified ) {
45+ nodeMayWriteToCollection ( any ( ExprNode n | n .getExpr ( ) = modified ) )
46+ }
47+
4348predicate modificationAfter ( Expr before , Expr after ) {
4449 mayWriteToCollection ( after ) and
4550 localFlowStep + ( exprNode ( before ) , exprNode ( after ) )
You can’t perform that action at this time.
0 commit comments