Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add javadoc boilerplate internal comment v2 for experimental classes #6886

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

@BugPattern(
summary =
"This public internal class doesn't end with the javadoc disclaimer: \""
+ OtelInternalJavadoc.EXPECTED_INTERNAL_COMMENT
"This public internal class doesn't end with any of the applicable javadoc disclaimers: \""
+ OtelInternalJavadoc.EXPECTED_INTERNAL_COMMENT_V1
+ OtelInternalJavadoc.EXPECTED_INTERNAL_COMMENT_V2
+ "\"",
ravi-nagendran marked this conversation as resolved.
Show resolved Hide resolved
severity = WARNING)
public class OtelInternalJavadoc extends BugChecker implements BugChecker.ClassTreeMatcher {
Expand All @@ -31,17 +32,24 @@ public class OtelInternalJavadoc extends BugChecker implements BugChecker.ClassT

private static final Pattern INTERNAL_PACKAGE_PATTERN = Pattern.compile("\\binternal\\b");

static final String EXPECTED_INTERNAL_COMMENT =
static final String EXPECTED_INTERNAL_COMMENT_V1 =
"This class is internal and is hence not for public use."
+ " Its APIs are unstable and can change at any time.";

static final String EXPECTED_INTERNAL_COMMENT_V2 =
"This class is internal and experimental. Its APIs are unstable and can change at any time."
+ " Its APIs (or a version of them) may be promoted to the public stable API in the"
+ " future, but no guarantees are made.";

@Override
public Description matchClass(ClassTree tree, VisitorState state) {
if (!isPublic(tree) || !isInternal(state) || tree.getSimpleName().toString().endsWith("Test")) {
return Description.NO_MATCH;
}
String javadoc = getJavadoc(state);
if (javadoc != null && javadoc.contains(EXPECTED_INTERNAL_COMMENT)) {
if (javadoc != null
&& (javadoc.contains(EXPECTED_INTERNAL_COMMENT_V1)
|| javadoc.contains(EXPECTED_INTERNAL_COMMENT_V2))) {
return Description.NO_MATCH;
}
return describeMatch(tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

package io.opentelemetry.gradle.customchecks.internal;

// BUG: Diagnostic contains: doesn't end with the javadoc disclaimer
// BUG: Diagnostic contains: doesn't end with any of the applicable javadoc disclaimers
public class InternalJavadocPositiveCases {

// BUG: Diagnostic contains: doesn't end with the javadoc disclaimer
// BUG: Diagnostic contains: doesn't end with any of the applicable javadoc disclaimers
public static class One {}

/** Doesn't have the disclaimer. */
// BUG: Diagnostic contains: doesn't end with the javadoc disclaimer
// BUG: Diagnostic contains: doesn't end with any of the applicable javadoc disclaimers
public static class Two {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/**
* A collection of configuration options which define the behavior of a {@link Logger}.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
* <p>This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*
* @see SdkLoggerProviderUtil#setLoggerConfigurator(SdkLoggerProviderBuilder, ScopeConfigurator)
* @see SdkLoggerProviderUtil#addLoggerConfiguratorCondition(SdkLoggerProviderBuilder, Predicate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
* <p>Delegates all calls to the configured {@link LoggerProvider}, and its {@link LoggerBuilder}s,
* {@link Logger}s.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
* <p>This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*/
public final class SdkEventLoggerProvider implements EventLoggerProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/**
* A collection of configuration options which define the behavior of a {@link Meter}.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
* <p>This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*
* @see SdkMeterProviderUtil#setMeterConfigurator(SdkMeterProviderBuilder, ScopeConfigurator)
* @see SdkMeterProviderUtil#addMeterConfiguratorCondition(SdkMeterProviderBuilder, Predicate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
* A collection of methods that allow use of experimental features prior to availability in public
* APIs.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
* <p>This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*/
public final class SdkMeterProviderUtil {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
* A collection of methods that allow use of experimental features prior to availability in public
* APIs.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
* <p>This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*/
public final class SdkTracerProviderUtil {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/**
* A collection of configuration options which define the behavior of a {@link Tracer}.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
* <p>This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*
* @see SdkTracerProviderUtil#setTracerConfigurator(SdkTracerProviderBuilder, ScopeConfigurator)
* @see SdkTracerProviderUtil#addTracerConfiguratorCondition(SdkTracerProviderBuilder, Predicate,
Expand Down
Loading