Files
codeql/python/ql/src/Statements/UnusedExceptionObject.ql
2025-10-30 13:58:59 +00:00

23 lines
598 B
Plaintext

/**
* @name Unused exception object
* @description An exception object is created, but is not used.
* @kind problem
* @tags quality
* reliability
* error-handling
* @problem.severity error
* @sub-severity low
* @precision very-high
* @id py/unused-exception-object
*/
import python
private import LegacyPointsTo
from Call call, ClassValue ex
where
call.getFunc().(ExprWithPointsTo).pointsTo(ex) and
ex.getASuperType() = ClassValue::exception() and
exists(ExprStmt s | s.getValue() = call)
select call, "Instantiating an exception, but not raising it, has no effect."