Skip to content

Commit e510593

Browse files
committed
QL: Autoformat and fix test.
1 parent 6d313cf commit e510593

2 files changed

Lines changed: 103 additions & 95 deletions

File tree

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
| test.qll:4:2:7:6 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
2-
| test.qll:29:2:32:9 | Disjunction | This formula of 4 predicate calls can be replaced with a single call on a set literal, improving readability. |
3-
| test.qll:43:2:46:11 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
4-
| test.qll:62:4:65:11 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
5-
| test.qll:67:4:70:10 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
6-
| test.qll:72:4:75:10 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
7-
| test.qll:89:2:92:8 | Disjunction | This formula of 4 predicate calls can be replaced with a single call on a set literal, improving readability. |
8-
| test.qll:126:2:126:37 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
1+
| test.qll:4:3:7:7 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
2+
| test.qll:30:3:33:10 | Disjunction | This formula of 4 predicate calls can be replaced with a single call on a set literal, improving readability. |
3+
| test.qll:44:3:47:12 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
4+
| test.qll:62:7:65:14 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
5+
| test.qll:68:7:71:13 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
6+
| test.qll:74:7:77:13 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
7+
| test.qll:87:3:90:9 | Disjunction | This formula of 4 predicate calls can be replaced with a single call on a set literal, improving readability. |
8+
| test.qll:128:3:134:3 | Disjunction | This formula of 4 comparisons can be replaced with a single equality on a set literal, improving readability. |
Lines changed: 95 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,135 @@
11
import ql
22

33
predicate test1(int a) {
4-
a = 1 or // BAD
5-
a = 2 or
6-
a = 3 or
7-
a = 4
4+
a = 1 or // BAD
5+
a = 2 or
6+
a = 3 or
7+
a = 4
88
}
99

1010
predicate test2(int a) {
11-
a = [1, 2, 3, 4] // GOOD
11+
a = [1, 2, 3, 4] // GOOD
1212
}
1313

1414
predicate test3(int a) {
15-
a = 1 and // GOOD (for the purposes of this query)
16-
a = 2 and
17-
a = 3 and
18-
a = 4
15+
a = 1 and // GOOD (for the purposes of this query)
16+
a = 2 and
17+
a = 3 and
18+
a = 4
1919
}
2020

21-
bindingset[a] predicate test4(int a) {
22-
a < 1 or // GOOD (for the purposes of this query)
23-
a = 2 or
24-
a >= 3 or
25-
a > 4
21+
bindingset[a]
22+
predicate test4(int a) {
23+
a < 1 or // GOOD (for the purposes of this query)
24+
a = 2 or
25+
a >= 3 or
26+
a > 4
2627
}
2728

2829
predicate test5() {
29-
test1(1) or // BAD
30-
test1(2) or
31-
test1(3) or
32-
test1(4)
30+
test1(1) or // BAD
31+
test1(2) or
32+
test1(3) or
33+
test1(4)
3334
}
3435

3536
predicate test6() {
36-
test1(1) or // GOOD
37-
test2(2) or
38-
test3(3) or
39-
test4(4)
37+
test1(1) or // GOOD
38+
test2(2) or
39+
test3(3) or
40+
test4(4)
4041
}
4142

4243
int test7() {
43-
1 = result or // BAD
44-
2 = result or
45-
3 = result or
46-
4 = result
44+
1 = result or // BAD
45+
2 = result or
46+
3 = result or
47+
4 = result
4748
}
4849

4950
predicate test8() {
50-
test7() = 1 or // BAD [NOT DETECTED]
51-
test7() = 2 or
52-
test7() = 3 or
53-
test7() = 4
51+
test7() = 1 or // BAD [NOT DETECTED]
52+
test7() = 2 or
53+
test7() = 3 or
54+
test7() = 4
5455
}
5556

56-
class MyTest8Class extends int
57-
{
58-
string s;
59-
60-
MyTest8Class() {
61-
(
62-
this = 1 or // BAD
63-
this = 2 or
64-
this = 3 or
65-
this = 4
66-
) and (
67-
s = "1" or // BAD
68-
s = "2" or
69-
s = "3" or
70-
s = "4"
71-
) and exists(float f |
72-
f = 1.0 or // BAD
73-
f = 1.5 or
74-
f = 2.0 or
75-
f = 2.5
76-
)
77-
}
78-
79-
predicate is(int x) {
80-
x = this
81-
}
82-
83-
int get() {
84-
result = this
85-
}
57+
class MyTest8Class extends int {
58+
string s;
59+
60+
MyTest8Class() {
61+
(
62+
this = 1 or // BAD
63+
this = 2 or
64+
this = 3 or
65+
this = 4
66+
) and
67+
(
68+
s = "1" or // BAD
69+
s = "2" or
70+
s = "3" or
71+
s = "4"
72+
) and
73+
exists(float f |
74+
f = 1.0 or // BAD
75+
f = 1.5 or
76+
f = 2.0 or
77+
f = 2.5
78+
)
79+
}
80+
81+
predicate is(int x) { x = this }
82+
83+
int get() { result = this }
8684
}
8785

8886
predicate test9(MyTest8Class c) {
89-
c.is(1) or // BAD
90-
c.is(2) or
91-
c.is(3) or
92-
c.is(4)
87+
c.is(1) or // BAD
88+
c.is(2) or
89+
c.is(3) or
90+
c.is(4)
9391
}
9492

9593
predicate test10(MyTest8Class c) {
96-
c.get() = 1 or // BAD [NOT DETECTED]
97-
c.get() = 2 or
98-
c.get() = 3 or
99-
c.get() = 4
94+
c.get() = 1 or // BAD [NOT DETECTED]
95+
c.get() = 2 or
96+
c.get() = 3 or
97+
c.get() = 4
10098
}
10199

102-
bindingset[a, b, c, d] predicate test11(int a, int b, int c, int d) {
103-
a = 1 or // GOOD
104-
b = 2 or
105-
c = 3 or
106-
d = 4
100+
bindingset[a, b, c, d]
101+
predicate test11(int a, int b, int c, int d) {
102+
a = 1 or // GOOD
103+
b = 2 or
104+
c = 3 or
105+
d = 4
107106
}
108107

109-
bindingset[a, b] predicate test12(int a, int b) {
110-
a = 1 or // BAD [NOT DETECTED]
111-
a = 2 or
112-
a = 3 or
113-
a = 4 or
114-
b = 0
108+
bindingset[a, b]
109+
predicate test12(int a, int b) {
110+
a = 1 or // BAD [NOT DETECTED]
111+
a = 2 or
112+
a = 3 or
113+
a = 4 or
114+
b = 0
115115
}
116116

117117
predicate test13(int a, int b) {
118-
(a = 1 and b = 1) or // GOOD
119-
(a = 2 and b = 4) or
120-
(a = 3 and b = 9) or
121-
(a = 4 and b = 16)
118+
a = 1 and b = 1 // GOOD
119+
or
120+
a = 2 and b = 4
121+
or
122+
a = 3 and b = 9
123+
or
124+
a = 4 and b = 16
122125
}
123126

124-
from int a
125-
where
126-
a = 1 or ((a = 2 or a = 3) or a = 4) // BAD
127-
select a
127+
predicate test14(int a) {
128+
a = 1 // BAD
129+
or
130+
(
131+
(a = 2 or a = 3)
132+
or
133+
a = 4
134+
)
135+
}

0 commit comments

Comments
 (0)