Query module UselessComparisonTest

name
Useless comparison test
description
A comparison operation that always evaluates to true or always evaluates to false may indicate faulty logic and may result in dead code.
kind
problem
problem.severity
warning
precision
very-high
id
java/constant-comparison
tags
correctness logic external/cwe/cwe-570 external/cwe/cwe-571

Imports

Guards
RangeAnalysis

Provides classes and predicates for range analysis.

SSA

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

SignAnalysis

Provides sign analysis to determine whether expression are always positive or negative.

Predicates

concurrentModificationTest
constCond

Holds if cond always evaluates to isTrue.

constCondSimple

Holds if cond always evaluates to isTrue.

guardedTest

Holds if test and guard are equality tests of the same integral variable v with constants c1 and c2.

increaseOfVar

Gets an expression that equals v plus a positive value.

overFlowCand

Gets a seemingly positive expression that might be negative due to overflow.

overFlowTest
uselessEqTest

Holds if guard implies that test always has the value testIsTrue.