Skip to content

Commit 9ee1c49

Browse files
committed
C#: Replace localFlow with localFlowStep in recursive predicate
1 parent 55ea715 commit 9ee1c49

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

csharp/ql/src/Bad Practices/Implementation Hiding/ExposeRepresentation.ql

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff 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+
4348
predicate modificationAfter(Expr before, Expr after) {
4449
mayWriteToCollection(after) and
4550
localFlowStep+(exprNode(before), exprNode(after))

0 commit comments

Comments
 (0)