Remove case for being last in initialisation. This pattern can still be a problem if the subclass overrides initialisation.

This commit is contained in:
Joe Farebrother
2025-06-13 10:36:27 +01:00
parent 95153c172c
commit 22a6fa3ebf

View File

@@ -5,6 +5,7 @@
* @kind problem
* @tags reliability
* correctness
* quality
* @problem.severity warning
* @sub-severity low
* @precision high
@@ -33,10 +34,6 @@ predicate initSelfCallOverridden(
)
}
predicate lastUse(DataFlow::Node node) {
not exists(DataFlow::Node next | DataFlow::localFlow(node, next) and node != next)
}
predicate readsFromSelf(Function method) {
exists(DataFlow::ParameterNode self, DataFlow::Node sink |
self.getParameter() = method.getArg(0) and
@@ -55,7 +52,7 @@ where
initSelfCallOverridden(init, self, call, target, override) and
readsFromSelf(override) and
not isClassmethod(override) and
not lastUse(self) and
not isStaticmethod(override) and
not target.getName().matches("\\_%")
select call, "This call to $@ in an initialization method is overridden by $@.", target,
target.getQualifiedName(), override, override.getQualifiedName()