Files
codeql/python/ql/src/Expressions/CompareConstants.ql
Taus Brock-Nannestad f07a7bf8cf Python: Autoformat everything using qlformat.
Will need subsequent PRs fixing up test failures (due to deprecated
methods moving around), but other than that everything should be
straight-forward.
2020-07-07 15:43:52 +02:00

24 lines
666 B
Plaintext

/**
* @name Comparison of constants
* @description Comparison of constants is always constant, but is harder to read than a simple constant.
* @kind problem
* @tags maintainability
* useless-code
* external/cwe/cwe-570
* external/cwe/cwe-571
* @problem.severity warning
* @sub-severity low
* @precision very-high
* @id py/comparison-of-constants
*/
import python
from Compare comparison, Expr left, Expr right
where
comparison.compares(left, _, right) and
left.isConstant() and
right.isConstant() and
not exists(Assert a | a.getTest() = comparison)
select comparison, "Comparison of constants; use 'True' or 'False' instead."