23
23
@ AutoService (BugChecker .class )
24
24
@ BugPattern (
25
25
summary =
26
- "This public internal class doesn't end with the javadoc disclaimer: \" "
27
- + OtelInternalJavadoc .EXPECTED_INTERNAL_COMMENT
26
+ "This public internal class doesn't end with any of the applicable javadoc disclaimers: \" "
27
+ + OtelInternalJavadoc .EXPECTED_INTERNAL_COMMENT_V1
28
+ + "\" , or \" "
29
+ + OtelInternalJavadoc .EXPECTED_INTERNAL_COMMENT_V2
28
30
+ "\" " ,
29
31
severity = WARNING )
30
32
public class OtelInternalJavadoc extends BugChecker implements BugChecker .ClassTreeMatcher {
@@ -36,17 +38,24 @@ public class OtelInternalJavadoc extends BugChecker implements BugChecker.ClassT
36
38
private static final Pattern EXCLUDE_PACKAGE_PATTERN =
37
39
Pattern .compile ("^io\\ .opentelemetry\\ .javaagent\\ .instrumentation\\ .internal\\ ." );
38
40
39
- static final String EXPECTED_INTERNAL_COMMENT =
41
+ static final String EXPECTED_INTERNAL_COMMENT_V1 =
40
42
"This class is internal and is hence not for public use."
41
43
+ " Its APIs are unstable and can change at any time." ;
42
44
45
+ static final String EXPECTED_INTERNAL_COMMENT_V2 =
46
+ "This class is internal and experimental. Its APIs are unstable and can change at any time."
47
+ + " Its APIs (or a version of them) may be promoted to the public stable API in the"
48
+ + " future, but no guarantees are made." ;
49
+
43
50
@ Override
44
51
public Description matchClass (ClassTree tree , VisitorState state ) {
45
52
if (!isPublic (tree ) || !isInternal (state ) || tree .getSimpleName ().toString ().endsWith ("Test" )) {
46
53
return Description .NO_MATCH ;
47
54
}
48
55
String javadoc = getJavadoc (state );
49
- if (javadoc != null && javadoc .endsWith (EXPECTED_INTERNAL_COMMENT )) {
56
+ if (javadoc != null
57
+ && (javadoc .contains (EXPECTED_INTERNAL_COMMENT_V1 )
58
+ || javadoc .contains (EXPECTED_INTERNAL_COMMENT_V2 ))) {
50
59
return Description .NO_MATCH ;
51
60
}
52
61
return describeMatch (tree );
0 commit comments