mirror of
https://github.com/github/codeql.git
synced 2026-01-03 01:30:19 +01:00
Will need subsequent PRs fixing up test failures (due to deprecated methods moving around), but other than that everything should be straight-forward.
24 lines
666 B
Plaintext
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."
|