Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#21,540 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
java
领域
devtools

调研方向

从 Likely Bugs/Statements/ContinueInFalseLoop.ql 开始,检查它在 false 存储于局部变量中时如何评估 do-loop 条件。查看受影响的 PosCase1_Var1.java 和 PosCase1_Var5.java 用例,然后运行 checker 测试,以确认两个用例都会被标记,同时现有的字面量 false 行为仍然得到覆盖。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 16 小时
30 天内合并 PR
143

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/codeql 的其他 Issue

查看 github/codeql 的全部 Issue

相似的 Issue

更多 DevTools Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。