mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
Python: Modernise the py/explicit-return-in-init query.
Add explicit test case to show that we don't doulbe report this problem.
This commit is contained in:
@@ -13,11 +13,10 @@
|
||||
import python
|
||||
|
||||
from Return r
|
||||
where exists(Function init | init.isInitMethod() and
|
||||
r.getScope() = init and exists(r.getValue())) and
|
||||
not r.getValue() instanceof None and
|
||||
not exists(FunctionObject f | f.getACall() = r.getValue().getAFlowNode() |
|
||||
f.neverReturns()
|
||||
) and
|
||||
not exists(Attribute meth | meth = ((Call)r.getValue()).getFunc() | meth.getName() = "__init__")
|
||||
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
|
||||
// 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__")
|
||||
select r, "Explicit return in __init__ method."
|
||||
|
||||
Reference in New Issue
Block a user