mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
Python: Don't flag return procedure_call() in __init__ as error
This commit fixes the results for
0d8a429b7e/files/mayaTools/cgm/lib/classes/AttrFactory.py (L90)
```
def __init__(...):
if error_case:
return guiFactory.warning(...)
```
that was wrongly reporting _Explicit return in __init__ method._ as an error.
This commit is contained in:
@@ -12,11 +12,12 @@
|
||||
|
||||
import python
|
||||
|
||||
from Return r
|
||||
from Return r, Expr rv
|
||||
where
|
||||
exists(Function init | init.isInitMethod() and r.getScope() = init and exists(r.getValue())) and
|
||||
not r.getValue() instanceof None and
|
||||
not exists(FunctionValue f | f.getACall() = r.getValue().getAFlowNode() | f.neverReturns()) and
|
||||
exists(Function init | init.isInitMethod() and r.getScope() = init) and
|
||||
r.getValue() = rv and
|
||||
not rv.pointsTo(Value::none_()) and
|
||||
not exists(FunctionValue f | f.getACall() = rv.getAFlowNode() | f.neverReturns()) and
|
||||
// to avoid double reporting, don't trigger if returning result from other __init__ function
|
||||
not exists(Attribute meth | meth = r.getValue().(Call).getFunc() | meth.getName() = "__init__")
|
||||
not exists(Attribute meth | meth = rv.(Call).getFunc() | meth.getName() = "__init__")
|
||||
select r, "Explicit return in __init__ method."
|
||||
|
||||
Reference in New Issue
Block a user