mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Java: Improve constant-loop-condition
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
class A {
|
||||
final boolean cond = otherCond();
|
||||
|
||||
boolean otherCond() { return 3 > 5; }
|
||||
|
||||
void f(int initx) {
|
||||
@@ -30,5 +32,9 @@ class A {
|
||||
while(initx > 0) { // OK: loop used as an if-statement
|
||||
break;
|
||||
}
|
||||
|
||||
while (cond) { // BAD: read of final field
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
| A.java:6:11:6:15 | !... | $@ might not terminate, as this loop condition is constant within the loop. | A.java:6:5:6:16 | stmt | Loop |
|
||||
| A.java:13:11:13:15 | ... > ... | $@ might not terminate, as this loop condition is constant within the loop. | A.java:12:5:12:19 | stmt | Loop |
|
||||
| A.java:27:20:27:32 | ... < ... | $@ might not terminate, as this loop condition is constant within the loop. | A.java:27:5:27:38 | stmt | Loop |
|
||||
| A.java:8:11:8:15 | !... | $@ might not terminate, as this loop condition is constant within the loop. | A.java:8:5:8:16 | stmt | Loop |
|
||||
| A.java:15:11:15:15 | ... > ... | $@ might not terminate, as this loop condition is constant within the loop. | A.java:14:5:14:19 | stmt | Loop |
|
||||
| A.java:29:20:29:32 | ... < ... | $@ might not terminate, as this loop condition is constant within the loop. | A.java:29:5:29:38 | stmt | Loop |
|
||||
| A.java:36:12:36:15 | cond | $@ might not terminate, as this loop condition is constant within the loop. | A.java:36:5:36:16 | stmt | Loop |
|
||||
|
||||
Reference in New Issue
Block a user