Skip to content

Commit a5fd2e9

Browse files
Improve query documentation
Co-authored-by: mc <[email protected]>
1 parent 1f76793 commit a5fd2e9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
## Overview
22

3-
An empty method may indicate that an implementation was intended to be provided but was accidentally omitted. When using the method, it will not be clear that it does not provide an implementation and with dynamic dispatch, resolving to a blank method may result in unexpected program behaviour.
3+
An empty method may indicate that an implementation was intended to be provided but was accidentally omitted. When using the method, it will not be clear that it does not provide an implementation and with dynamic dispatch, resolving to a blank method may result in unexpected program behavior.
44

55
## Recommendation
66

7-
If a method is intended to be left empty, do one of the following to indicate that it is intentionally empty: 1) mark it abstract in an abstract class, 2) place it in an interface (then it can be implicitly abstract), 3) place a comment in that method that lets others know that the implementation was intentionally omitted, or 4) throw an `UnsupportedOperationException` in the method (like is done in `java.util.Collection.add`).
7+
If a method is intended to be left empty, do one of the following to indicate that it is intentionally empty:
8+
1. Mark it abstract in an abstract class
9+
2. Place it in an interface (then it can be implicitly abstract)
10+
3. Place a comment in that method that lets others know that the implementation was intentionally omitted
11+
4. Add `UnsupportedOperationException` to the method (as in `java.util.Collection.add`).
812

913
## Example
1014

@@ -31,6 +35,6 @@ public class Test {
3135
The rule excludes reporting methods that are annotated.
3236

3337
## References
34-
- Java SE Documentation: [java.util.Collection.add](https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/Collection.html#add(E))
35-
- Wikipedia: [Template method pattern](https://en.wikipedia.org/wiki/Template_method_pattern)
36-
- Common Weakness Enumeration: [CWE-1071](https://cwe.mitre.org/data/definitions/1071.html)
38+
- Java SE Documentation: [java.util.Collection.add](https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/Collection.html#add(E)).
39+
- Wikipedia: [Template method pattern](https://en.wikipedia.org/wiki/Template_method_pattern).
40+
- Common Weakness Enumeration: [CWE-1071](https://cwe.mitre.org/data/definitions/1071.html).

0 commit comments

Comments
 (0)