Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

False Negative: ContinueInFalseLoop.ql misses `do ... while(false)` loops once `false` is stored in a local.

Open
#21,540 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
java
Domain
devtools

Research direction

Start with Likely Bugs/Statements/ContinueInFalseLoop.ql and inspect how it evaluates do-loop conditions when false is stored in a local. Review the affected PosCase1_Var1.java and PosCase1_Var5.java cases, then run the checker tests to confirm both cases are flagged while the existing literal-false behavior remains covered.

Written by the indexing model from the issue text.

Description

False Negative: ContinueInFalseLoop.ql misses do ... while(false) loops once false is stored in a local.

Version
codeql 2.24.3

Checker

  • Checker id: Likely Bugs/Statements/ContinueInFalseLoop.ql
  • Checker description: This checker detects a 'continue' statement inside a 'do' loop whose condition is always false, meaning the continue will never actually re-run the loop body.

Description of the false negative

Both samples are still do loops whose condition is false and therefore cannot loop back after continue. The only difference is that the literal false is first assigned to a local variable.

That should still be a direct hit for Likely Bugs/Statements/ContinueInFalseLoop.ql.

Affected test cases

PosCase1_Var1.java

never is a constant false value, so the continue still cannot re-enter the loop body.

// A do loop with a literal false condition contains a continue statement targeting that same loop should be flagged as a positive case.
package scensct.var.pos;

public class PosCase1_Var1 {
    public static void main(String[] args) {
        final boolean never = false;
        do {
            // continue inside do with false condition
            continue;
        } while (never);
    }
}
PosCase1_Var5.java

flag is initialized from Boolean.FALSE and never changed. This is still the same impossible loop-back case.

// A do loop with a literal false condition contains a continue statement targeting that same loop should be flagged as a positive case.
package scensct.var.pos;

public class PosCase1_Var5 {
    public static void main(String[] args) {
        boolean flag = Boolean.FALSE;
        do {
            // continue inside do with false condition
            continue;
        } while (flag);
    }
}

Cause analysis

The miss is surprisingly basic. The query appears to require a literal false at the loop condition and loses the result as soon as that same value is stored in a local.

For developers, these are the same bug. Whether the condition is written as while (false) or while (never) should not matter.

References

None known.

Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 16h
Merged PRs (30d)
143

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/codeql

All issues in github/codeql

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.