Skip to content

Commit ad11fec

Browse files
committed
QL: add test for redundant-aggregate
1 parent b07ea32 commit ad11fec

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
bindingset[i]
2+
predicate foo(int i) {
3+
exists(int j | j = i | j = 2) // redundant
4+
or
5+
exists(Even j | j = i) // redundant
6+
or
7+
exists(int j |
8+
j = i // NOT redundant, inlining into a `forall` is not semantics preserving
9+
|
10+
forall(int k | k = j | k = 2)
11+
)
12+
}
13+
14+
class Even extends int {
15+
bindingset[this]
16+
Even() { this % 2 = 0 }
17+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| Foo.qll:3:3:3:31 | Exists | The $@ variable in this aggregate is assigned and used exactly once, and the aggregate is therefore redundant. | Foo.qll:3:10:3:14 | j | j |
2+
| Foo.qll:5:3:5:24 | Exists | The assignment to $@ in the exists(..) can replaced with an instanceof expression. | Foo.qll:5:10:5:15 | j | j |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
queries/style/RedundantAggregate.ql

0 commit comments

Comments
 (0)