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 {
65
65
}
66
66
}
67
67
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
-
78
68
/**
79
69
* A `Method` from source that is not abstract
80
70
*/
94
84
m .getNumberOfCommentLines ( ) = 0 and
95
85
//permit a javadoc above as well as sufficient reason to leave empty
96
86
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 ( )
99
93
select m , "Empty method found."
Original file line number Diff line number Diff line change 1
1
| 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 {
24
24
public class Derived extends TestInner {
25
25
26
26
@ Override
27
- public void f () { } // $ Alert
27
+ public void f () {
28
+ }
29
+
30
+ public native int nativeMethod ();
28
31
}
29
32
30
33
public interface TestInterface {
31
34
32
- default void method () { } // $ Alert
35
+ default void method () {
36
+ }
33
37
}
34
38
35
39
}
You can’t perform that action at this time.
0 commit comments