-
Notifications
You must be signed in to change notification settings - Fork 724
Expand file tree
/
Copy pathUndocumentedApiJava23.java
More file actions
61 lines (48 loc) · 1.93 KB
/
UndocumentedApiJava23.java
File metadata and controls
61 lines (48 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.example.api.mypackage;
/// Undocumented Api for Java 23 (and an example of bad documentation).
public class UndocumentedApiJava23 {
public class BadNested {} // Noncompliant {{Document this public class by adding an explicit description.}}
/// Documented.
public class GoodNested {} // Compliant
public String badField; // Noncompliant {{Document this public field by adding an explicit description.}}
/// Documented.
public String goodField; // Compliant
public void bad(int value) { // Noncompliant {{Document this public method by adding an explicit description.}}
}
/// Valid descriptions.
/// @param value Valid descriptions.
public void goodMethod1(int value) { // Compliant
}
/// Valid descriptions.
/// @param value Valid descriptions.
/// @return some text
/// @throws NumberFormatException sometimes
public String goodMethod2(int value) throws NumberFormatException { // Compliant
return "";
}
/// Valid descriptions.
/// @return some text
/// @throws NumberFormatException sometimes
public String missingParameted(int value) throws NumberFormatException { // Noncompliant {{Document the parameter(s): value}}
return "";
}
/// Valid descriptions.
/// @param value Valid descriptions.
/// @throws NumberFormatException sometimes
public String missingReturn(int value) throws NumberFormatException { // Noncompliant {{Document this method return value.}}
return "";
}
/// Valid descriptions.
/// @param value Valid descriptions.
/// @return some text
public String missingThrows(int value) throws NumberFormatException { // Noncompliant {{Document this method thrown exception(s): NumberFormatException}}
return "";
}
/// Documented, but not the type.
public class SomethingGenericBad<T> { // Noncompliant {{Document the type parameter(s): <T>}}
}
/// Documented.
/// @param <T> also documented
public class SomethingGenericGood<T> { // Compliant
}
}