mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Python: Restrict ShouldBeContextManager.ql results
By limiting the results to the class that actually defines the `__del__` method, we eliminate a bunch of FPs where a _subclass_ of such a class would also get flagged.
This commit is contained in:
@@ -19,7 +19,7 @@ private import semmle.python.dataflow.new.internal.DataFlowDispatch
|
||||
from Class c
|
||||
where
|
||||
not DuckTyping::isContextManager(c) and
|
||||
DuckTyping::hasMethod(c, "__del__")
|
||||
exists(c.getMethod("__del__"))
|
||||
select c,
|
||||
"Class " + c.getName() +
|
||||
" implements __del__ (presumably to release some resource). Consider making it a context manager."
|
||||
|
||||
Reference in New Issue
Block a user