mirror of
https://github.com/github/codeql.git
synced 2026-02-08 03:01:10 +01:00
Autoformat and fix test.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
|
||||
@@ -1,127 +1,135 @@
|
||||
import ql
|
||||
|
||||
predicate test1(int a) {
|
||||
a = 1 or // BAD
|
||||
a = 2 or
|
||||
a = 3 or
|
||||
a = 4
|
||||
a = 1 or // BAD
|
||||
a = 2 or
|
||||
a = 3 or
|
||||
a = 4
|
||||
}
|
||||
|
||||
predicate test2(int a) {
|
||||
a = [1, 2, 3, 4] // GOOD
|
||||
a = [1, 2, 3, 4] // GOOD
|
||||
}
|
||||
|
||||
predicate test3(int a) {
|
||||
a = 1 and // GOOD (for the purposes of this query)
|
||||
a = 2 and
|
||||
a = 3 and
|
||||
a = 4
|
||||
a = 1 and // GOOD (for the purposes of this query)
|
||||
a = 2 and
|
||||
a = 3 and
|
||||
a = 4
|
||||
}
|
||||
|
||||
bindingset[a] predicate test4(int a) {
|
||||
a < 1 or // GOOD (for the purposes of this query)
|
||||
a = 2 or
|
||||
a >= 3 or
|
||||
a > 4
|
||||
bindingset[a]
|
||||
predicate test4(int a) {
|
||||
a < 1 or // GOOD (for the purposes of this query)
|
||||
a = 2 or
|
||||
a >= 3 or
|
||||
a > 4
|
||||
}
|
||||
|
||||
predicate test5() {
|
||||
test1(1) or // BAD
|
||||
test1(2) or
|
||||
test1(3) or
|
||||
test1(4)
|
||||
test1(1) or // BAD
|
||||
test1(2) or
|
||||
test1(3) or
|
||||
test1(4)
|
||||
}
|
||||
|
||||
predicate test6() {
|
||||
test1(1) or // GOOD
|
||||
test2(2) or
|
||||
test3(3) or
|
||||
test4(4)
|
||||
test1(1) or // GOOD
|
||||
test2(2) or
|
||||
test3(3) or
|
||||
test4(4)
|
||||
}
|
||||
|
||||
int test7() {
|
||||
1 = result or // BAD
|
||||
2 = result or
|
||||
3 = result or
|
||||
4 = result
|
||||
1 = result or // BAD
|
||||
2 = result or
|
||||
3 = result or
|
||||
4 = result
|
||||
}
|
||||
|
||||
predicate test8() {
|
||||
test7() = 1 or // BAD [NOT DETECTED]
|
||||
test7() = 2 or
|
||||
test7() = 3 or
|
||||
test7() = 4
|
||||
test7() = 1 or // BAD [NOT DETECTED]
|
||||
test7() = 2 or
|
||||
test7() = 3 or
|
||||
test7() = 4
|
||||
}
|
||||
|
||||
class MyTest8Class extends int
|
||||
{
|
||||
string s;
|
||||
class MyTest8Class extends int {
|
||||
string s;
|
||||
|
||||
MyTest8Class() {
|
||||
(
|
||||
this = 1 or // BAD
|
||||
this = 2 or
|
||||
this = 3 or
|
||||
this = 4
|
||||
) and (
|
||||
s = "1" or // BAD
|
||||
s = "2" or
|
||||
s = "3" or
|
||||
s = "4"
|
||||
) and exists(float f |
|
||||
f = 1.0 or // BAD
|
||||
f = 1.5 or
|
||||
f = 2.0 or
|
||||
f = 2.5
|
||||
)
|
||||
}
|
||||
MyTest8Class() {
|
||||
(
|
||||
this = 1 or // BAD
|
||||
this = 2 or
|
||||
this = 3 or
|
||||
this = 4
|
||||
) and
|
||||
(
|
||||
s = "1" or // BAD
|
||||
s = "2" or
|
||||
s = "3" or
|
||||
s = "4"
|
||||
) and
|
||||
exists(float f |
|
||||
f = 1.0 or // BAD
|
||||
f = 1.5 or
|
||||
f = 2.0 or
|
||||
f = 2.5
|
||||
)
|
||||
}
|
||||
|
||||
predicate is(int x) {
|
||||
x = this
|
||||
}
|
||||
predicate is(int x) { x = this }
|
||||
|
||||
int get() {
|
||||
result = this
|
||||
}
|
||||
int get() { result = this }
|
||||
}
|
||||
|
||||
predicate test9(MyTest8Class c) {
|
||||
c.is(1) or // BAD
|
||||
c.is(2) or
|
||||
c.is(3) or
|
||||
c.is(4)
|
||||
c.is(1) or // BAD
|
||||
c.is(2) or
|
||||
c.is(3) or
|
||||
c.is(4)
|
||||
}
|
||||
|
||||
predicate test10(MyTest8Class c) {
|
||||
c.get() = 1 or // BAD [NOT DETECTED]
|
||||
c.get() = 2 or
|
||||
c.get() = 3 or
|
||||
c.get() = 4
|
||||
c.get() = 1 or // BAD [NOT DETECTED]
|
||||
c.get() = 2 or
|
||||
c.get() = 3 or
|
||||
c.get() = 4
|
||||
}
|
||||
|
||||
bindingset[a, b, c, d] predicate test11(int a, int b, int c, int d) {
|
||||
a = 1 or // GOOD
|
||||
b = 2 or
|
||||
c = 3 or
|
||||
d = 4
|
||||
bindingset[a, b, c, d]
|
||||
predicate test11(int a, int b, int c, int d) {
|
||||
a = 1 or // GOOD
|
||||
b = 2 or
|
||||
c = 3 or
|
||||
d = 4
|
||||
}
|
||||
|
||||
bindingset[a, b] predicate test12(int a, int b) {
|
||||
a = 1 or // BAD [NOT DETECTED]
|
||||
a = 2 or
|
||||
a = 3 or
|
||||
a = 4 or
|
||||
b = 0
|
||||
bindingset[a, b]
|
||||
predicate test12(int a, int b) {
|
||||
a = 1 or // BAD [NOT DETECTED]
|
||||
a = 2 or
|
||||
a = 3 or
|
||||
a = 4 or
|
||||
b = 0
|
||||
}
|
||||
|
||||
predicate test13(int a, int b) {
|
||||
(a = 1 and b = 1) or // GOOD
|
||||
(a = 2 and b = 4) or
|
||||
(a = 3 and b = 9) or
|
||||
(a = 4 and b = 16)
|
||||
a = 1 and b = 1 // GOOD
|
||||
or
|
||||
a = 2 and b = 4
|
||||
or
|
||||
a = 3 and b = 9
|
||||
or
|
||||
a = 4 and b = 16
|
||||
}
|
||||
|
||||
from int a
|
||||
where
|
||||
a = 1 or ((a = 2 or a = 3) or a = 4) // BAD
|
||||
select a
|
||||
predicate test14(int a) {
|
||||
a = 1 // BAD
|
||||
or
|
||||
(
|
||||
(a = 2 or a = 3)
|
||||
or
|
||||
a = 4
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user