Query module ConstantLoopCondition

name
Constant loop condition
description
A loop condition that remains constant throughout the iteration indicates faulty logic and is likely to cause infinite looping.
kind
problem
problem.severity
warning
precision
very-high
id
java/constant-loop-condition
tags
correctness external/cwe/cwe-835

Imports

Guards
SSA

Provides classes and predicates for SSA representation (Static Single Assignment form).

java

Provides all default Java QL imports.

Predicates

loopExit

Holds if exit is a return or break statement that can exit the loop.

loopExitGuard

Holds if cond is a condition in the loop that guards all return and break statements that can exit the loop.

loopWhileTrue
mainLoopCondition

Holds if loop.getCondition() = cond and the loop can possibly execute more than once. That is, loops that are always terminated with a return or break are excluded as they are simply disguised if-statements.