Skip to content

Commit 8017fae

Browse files
committed
Java: Simplify mock call location check using getEnclosingCallable
1 parent 1abb8ad commit 8017fae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

java/ql/src/Likely Bugs/Frameworks/JUnit/ExcessivePublicMethodMocking.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class MockitoMockingMethodCall extends MethodCall {
6565
from JUnit4TestMethod testMethod, ClassOrInterface mockedClassOrInterface
6666
where
6767
exists(MockitoMockCall mockCall |
68-
mockCall.getParent+() = testMethod.getBody().getAStmt() and
68+
mockCall.getEnclosingCallable() = testMethod and
6969
mockedClassOrInterface = mockCall.getMockedType() and
7070
// Only flag classes with multiple public methods (2 or more)
7171
strictcount(Method m | m = mockedClassOrInterface.getAMethod() and m.isPublic()) > 1 and

0 commit comments

Comments
 (0)