Skip to content

Commit 3d4fcef

Browse files
committed
Do not accept empty default methods
1 parent 7740077 commit 3d4fcef

File tree

4 files changed

+3
-5
lines changed

4 files changed

+3
-5
lines changed

java/ql/src/Language Abuse/EmptyMethod.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class Test {
2828

2929
## Implementation Notes
3030

31-
The rule excludes reporting methods that are annotated or marked as `default`.
31+
The rule excludes reporting methods that are annotated.
3232

3333
## References
3434
- [java.util.Collections.add](https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/Collection.html#add(E))

java/ql/src/Language Abuse/EmptyMethod.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ where
8686
not exists(m.getDoc().getJavadoc()) and
8787
//annotated methods are considered compliant
8888
not exists(m.getAnAnnotation()) and
89-
//default methods are not abstract, but are considered compliant
90-
not m.isDefault() and
9189
//native methods have no body
9290
not m.isNative()
9391
select m, "This empty method should be completed."
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
| Test.java:13:15:13:16 | f2 | This empty method should be completed. |
2+
| Test.java:35:18:35:23 | method | This empty method should be completed. |

java/ql/test/query-tests/EmptyMethod/Test.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public void f() {
3232

3333
public interface TestInterface {
3434

35-
default void method() {
36-
}
35+
default void method() { } // $ Alert
3736
}
3837

3938
}

0 commit comments

Comments
 (0)