Java: Simplify mock call location check using getEnclosingCallable

This commit is contained in:
Napalys Klicius
2025-08-26 09:44:00 +00:00
parent 1abb8ad54a
commit 8017fae297

View File

@@ -65,7 +65,7 @@ class MockitoMockingMethodCall extends MethodCall {
from JUnit4TestMethod testMethod, ClassOrInterface mockedClassOrInterface
where
exists(MockitoMockCall mockCall |
mockCall.getParent+() = testMethod.getBody().getAStmt() and
mockCall.getEnclosingCallable() = testMethod and
mockedClassOrInterface = mockCall.getMockedType() and
// Only flag classes with multiple public methods (2 or more)
strictcount(Method m | m = mockedClassOrInterface.getAMethod() and m.isPublic()) > 1 and