Files
codeql/cpp/ql/test/examples/lgtm-query-examples/equality_test_on_boolean.ql
2018-08-02 17:53:23 +01:00

16 lines
429 B
Plaintext

/**
* @name Equality test on Boolean
* @description Testing equality with `true` is redundant
* and can make the code harder to read.
* @kind problem
* @problem.severity warning
*/
import cpp
from EqualityOperation eq, Expr trueExpr
where
trueExpr = eq.getAnOperand() and
trueExpr.getType() instanceof BoolType and
trueExpr.getValue().toInt() = 1
select eq, "Expression tested for equality with 'true'"