Files
codeql/python/ql/src/Expressions/EqualsNone.ql
2025-06-19 14:08:51 +01:00

20 lines
524 B
Plaintext

/**
* @name Testing equality to None
* @description Testing whether an object is 'None' using the == operator is inefficient and potentially incorrect.
* @kind problem
* @tags quality
* reliability
* correctness
* performance
* @problem.severity recommendation
* @sub-severity high
* @precision very-high
* @id py/test-equals-none
*/
import python
from Compare c
where c.getOp(0) instanceof Eq and c.getAComparator() instanceof None
select c, "Testing for None should use the 'is' operator."