Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#21,540 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
java
Ambito
devtools

Direzione di ricerca

Inizia con Likely Bugs/Statements/ContinueInFalseLoop.ql e verifica come valuta le condizioni dei cicli do quando false è memorizzato in una variabile locale. Esamina i casi interessati PosCase1_Var1.java e PosCase1_Var5.java, quindi esegui i test del checker per confermare che entrambi i casi vengano segnalati, mantenendo coperto il comportamento esistente per il valore letterale false.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
CodeQL
Stelle
10.1k
Fork
2.1k
Merge medio
2g 16h
PR unite (30g)
143

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di github/codeql

Tutte le issue di github/codeql

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.