mirror of
https://github.com/github/codeql.git
synced 2025-12-26 13:46:31 +01:00
Without backticks, the text UNDERSCORE UNDERSCORE eq UNDERSCORE UNDERSCORE would be considered to make things bold in our markdown output, making the query info look strange. Example https://codeql.github.com/codeql-query-help/python/py-slots-in-old-style-class/
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"
|