Files
codeql/python/ql/src/Expressions/CompareConstants.ql
Joe Farebrother 869e33e38c Tag 'linter-like' quality queries that use pointto
Excluded for now: unnecassary-delete; since the pattern is often intentional to break reference cycles, which the query doesn't account for; so uncertain about its claim of high precision
2025-06-19 14:07:15 +01:00

25 lines
683 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 quality
* 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."