mirror of
https://github.com/github/codeql.git
synced 2026-01-01 00:27:24 +01:00
Will need subsequent PRs fixing up test failures (due to deprecated methods moving around), but other than that everything should be straight-forward.
29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
/**
|
|
* @name Missing call to __init__ during object initialization
|
|
* @description An omitted call to a super-class __init__ method may lead to objects of this class not being fully initialized.
|
|
* @kind problem
|
|
* @tags reliability
|
|
* correctness
|
|
* @problem.severity error
|
|
* @sub-severity low
|
|
* @precision high
|
|
* @id py/missing-call-to-init
|
|
*/
|
|
|
|
import python
|
|
import MethodCallOrder
|
|
|
|
from ClassObject self, FunctionObject initializer, FunctionObject missing
|
|
where
|
|
self.lookupAttribute("__init__") = initializer and
|
|
missing_call_to_superclass_method(self, initializer, missing, "__init__") and
|
|
// If a superclass is incorrect, don't flag this class as well.
|
|
not missing_call_to_superclass_method(self.getASuperType(), _, missing, "__init__") and
|
|
not missing.neverReturns() and
|
|
not self.failedInference() and
|
|
not missing.isBuiltin() and
|
|
not self.isAbstract()
|
|
select self,
|
|
"Class " + self.getName() + " may not be initialized properly as $@ is not called from its $@.",
|
|
missing, missing.descriptiveString(), initializer, "__init__ method"
|