Skip to content

Commit

Permalink
ignore overridden methods for empty block check
Browse files Browse the repository at this point in the history
  • Loading branch information
Luro02 committed Apr 8, 2024
1 parent 7252d45 commit 4c1663d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import spoon.reflect.code.CtCatch;
import spoon.reflect.code.CtComment;
import spoon.reflect.code.CtSwitch;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.visitor.CtScanner;

@ExecutableCheck(reportedProblems = {ProblemType.EMPTY_BLOCK, ProblemType.EMPTY_CATCH})
Expand All @@ -31,6 +32,12 @@ public <T> void visitCtBlock(CtBlock<T> ctBlock) {
return;
}

if (ctBlock.getParent() instanceof CtMethod<?> ctMethod
&& ctMethod.getBody().equals(ctBlock)
&& SpoonUtil.isInOverriddenMethod(ctBlock)) {
return;
}

if (ctBlock.getParent() instanceof CtCatch ctCatch && ctCatch.getBody().equals(ctBlock)) {
addLocalProblem(
ctCatch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface A {

class B implements A {
@Override
public void call() {} /*# not ok #*/
public void call() {} /*# ok #*/
}

class C implements A {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Test.java:6
Test.java:9-10
Test.java:10

Test.java:19
Test.java:47
Test.java:50-51
Test.java:51-52
Expand Down

0 comments on commit 4c1663d

Please sign in to comment.