Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions python/ql/src/Classes/CallsToInitDel/MethodCallOrder.qll
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,23 @@ predicate missingCallToSuperclassMethod(Class base, Function shouldCall, string
*/
predicate missingCallToSuperclassMethodRestricted(Class base, Function shouldCall, string name) {
missingCallToSuperclassMethod(base, shouldCall, name) and
not exists(Class superBase |
// Alert only on the highest base class that has the issue
superBase = getADirectSuperclass+(base) and
missingCallToSuperclassMethod(superBase, shouldCall, name)
) and
not superclassAlsoMissesCall(base, shouldCall, name) and
not exists(Function subShouldCall |
// Mention in the alert only the lowest method we're missing the call to
subShouldCall.getScope() = getADirectSubclass+(shouldCall.getScope()) and
missingCallToSuperclassMethod(base, subShouldCall, name)
)
}

/**
* Holds if a strict superclass of `base` is also missing a call to `shouldCall` named `name`,
* indicating that `base` is not the highest class in the hierarchy with this issue.
*/
Comment on lines +164 to +166
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new doc comment is a bit ambiguous: “missing a call to shouldCall named name” reads like shouldCall is being named here. Consider rephrasing to explicitly say this checks whether any strict superclass of base also satisfies missingCallToSuperclassMethod(..., shouldCall, name) (i.e., is also missing the call to the superclass method name).

Suggested change
* Holds if a strict superclass of `base` is also missing a call to `shouldCall` named `name`,
* indicating that `base` is not the highest class in the hierarchy with this issue.
*/
* Holds if some strict superclass of `base` also satisfies `missingCallToSuperclassMethod(..., shouldCall, name)`,
* that is, is also missing the call to the superclass method named `name`, so `base` is not the highest class
* in the hierarchy with this issue.

Copilot uses AI. Check for mistakes.
pragma[nomagic]
private predicate superclassAlsoMissesCall(Class base, Function shouldCall, string name) {
missingCallToSuperclassMethod(getADirectSuperclass+(base), shouldCall, name)
}

/**
* If `base` contains a `super()` call, gets a method in the inheritance hierarchy of `name` in the MRO of `base`
* that does not contain a `super()` call, but would call `shouldCall` if it did, which does not otherwise get called
Expand Down