Do not accept empty default methods

This commit is contained in:
Tamas Vajk
2025-03-12 10:37:37 +01:00
parent 77400778ea
commit 3d4fcefe70
4 changed files with 3 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ public class Test {
## Implementation Notes
The rule excludes reporting methods that are annotated or marked as `default`.
The rule excludes reporting methods that are annotated.
## References
- [java.util.Collections.add](https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/Collection.html#add(E))

View File

@@ -86,8 +86,6 @@ where
not exists(m.getDoc().getJavadoc()) and
//annotated methods are considered compliant
not exists(m.getAnAnnotation()) and
//default methods are not abstract, but are considered compliant
not m.isDefault() and
//native methods have no body
not m.isNative()
select m, "This empty method should be completed."

View File

@@ -1 +1,2 @@
| Test.java:13:15:13:16 | f2 | This empty method should be completed. |
| Test.java:35:18:35:23 | method | This empty method should be completed. |

View File

@@ -32,8 +32,7 @@ public class Test {
public interface TestInterface {
default void method() {
}
default void method() { } // $ Alert
}
}