File tree Expand file tree Collapse file tree 3 files changed +12
-16
lines changed
test/query-tests/EmptyMethod Expand file tree Collapse file tree 3 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -65,16 +65,6 @@ class SurefireTest extends Class {
6565 }
6666}
6767
68- /**
69- * Frameworks that provide `PointCuts`
70- * which commonly intentionally annotate empty methods
71- */
72- class PointCutAnnotation extends Annotation {
73- PointCutAnnotation ( ) {
74- this .getType ( ) .hasQualifiedName ( "org.aspectj.lang.annotation" , "Pointcut" )
75- }
76- }
77-
7868/**
7969 * A `Method` from source that is not abstract
8070 */
9484 m .getNumberOfCommentLines ( ) = 0 and
9585 //permit a javadoc above as well as sufficient reason to leave empty
9686 not exists ( Javadoc jd | m .getDoc ( ) .getJavadoc ( ) = jd ) and
97- //methods annotated this way are usually intentionally empty
98- not exists ( PointCutAnnotation a | a = m .getAnAnnotation ( ) )
87+ //annotated methods are considered compliant
88+ not exists ( m .getAnAnnotation ( ) ) and
89+ //default methods are not abstract, but are considered compliant
90+ not m .isDefault ( ) and
91+ //native methods have no body
92+ not m .isNative ( )
9993select m , "Empty method found."
Original file line number Diff line number Diff line change 11| Test.java:13:15:13:16 | f2 | Empty method found. |
2- | Test.java:27:17:27:17 | f | Empty method found. |
3- | Test.java:32:18:32:23 | method | Empty method found. |
Original file line number Diff line number Diff line change @@ -24,12 +24,16 @@ public abstract class TestInner {
2424 public class Derived extends TestInner {
2525
2626 @ Override
27- public void f () { } // $ Alert
27+ public void f () {
28+ }
29+
30+ public native int nativeMethod ();
2831 }
2932
3033 public interface TestInterface {
3134
32- default void method () { } // $ Alert
35+ default void method () {
36+ }
3337 }
3438
3539}
You can’t perform that action at this time.
0 commit comments