Skip to content

Commit 5c0ca03

Browse files
Added Javadoc checks to Checkstyle. Fix violating Javadoc. (#7210)
Add JavadocMethod and MissingJavadocMethod checks to Checkstyle. Checks ensure there are no missing Javadoc comments for public methods, and that each of the Javadoc comments describe all method parameters. Add suppressions.xml Checkstyle configuration file to exclude Jmh, Test, and Internal from MissingJavadocMethod check. Move Checkstyle configuration files and License headers into config directory. Fix Javadoc comments that violate the added checks.
1 parent ea8c183 commit 5c0ca03

File tree

17 files changed

+60
-15
lines changed

17 files changed

+60
-15
lines changed

build.gradle

+4-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jar {
129129
}
130130

131131
license {
132-
header rootProject.file("HEADER")
132+
header rootProject.file("config/license/HEADER")
133133
ext.year = Calendar.getInstance().get(Calendar.YEAR)
134134
skipExistingHeaders true
135135
ignoreFailures true
@@ -234,10 +234,11 @@ jacocoTestReport.dependsOn GCandMem
234234
build.dependsOn jacocoTestReport
235235

236236
checkstyle {
237-
configFile = file("checkstyle.xml")
237+
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
238238
toolVersion = checkstyleVersion
239239
configProperties = [
240-
"checkstyle.header.file": file("HEADER_JAVA")
240+
"checkstyle.suppressions.file": rootProject.file("config/checkstyle/suppressions.xml"),
241+
"checkstyle.header.file": rootProject.file("config/license/HEADER_JAVA")
241242
]
242243
}
243244

checkstyle.xml renamed to config/checkstyle/checkstyle.xml

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"https://checkstyle.org/dtds/configuration_1_3.dtd">
55

66
<module name="Checker">
7+
<module name="SuppressionFilter">
8+
<property name="file" value="${checkstyle.suppressions.file}"/>
9+
</module>
710

811
<!-- Headers -->
912
<module name="Header">
@@ -12,6 +15,9 @@
1215
</module>
1316

1417
<module name="TreeWalker">
18+
<module name="JavadocMethod"/>
19+
<module name="MissingJavadocMethod"/>
20+
1521
<module name="RegexpSinglelineJava">
1622
<property name="severity" value="warning"/>
1723
<property name="format" value="^(?!\s+\* $).*?\s+$"/>

config/checkstyle/suppressions.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
5+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
6+
7+
<suppressions>
8+
9+
<suppress checks="MissingJavadocMethod" files="[\\/]main[\\/]java[\\/]io[\\/]reactivex[\\/]rxjava3[\\/]internal[\\/]"/>
10+
<suppress checks="MissingJavadocMethod" files="[\\/]jmh[\\/]java[\\/]io[\\/]reactivex[\\/]rxjava3[\\/]"/>
11+
<suppress checks="MissingJavadocMethod" files="[\\/]test[\\/]java[\\/]io[\\/]reactivex[\\/]rxjava3[\\/]"/>
12+
13+
</suppressions>
File renamed without changes.
File renamed without changes.

src/main/java/io/reactivex/rxjava3/core/Completable.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -1908,11 +1908,12 @@ public final Completable doOnLifecycle(@NonNull Consumer<? super Disposable> onS
19081908
* <dt><b>Scheduler:</b></dt>
19091909
* <dd>{@code doOnLifecycle} does not operate by default on a particular {@link Scheduler}.</dd>
19101910
* </dl>
1911-
* @param onSubscribe the consumer called when a {@link CompletableObserver} subscribes.
1912-
* @param onError the consumer called when this emits an {@code onError} event
1913-
* @param onComplete the runnable called just before when the current {@code Completable} completes normally
1914-
* @param onAfterTerminate the runnable called after this {@code Completable} completes normally
1915-
* @param onDispose the {@link Runnable} called when the downstream disposes the subscription
1911+
* @param onSubscribe the {@link Consumer} called when a {@link CompletableObserver} subscribes.
1912+
* @param onError the {@code Consumer} called when this emits an {@code onError} event
1913+
* @param onComplete the {@link Action} called just before when the current {@code Completable} completes normally
1914+
* @param onTerminate the {@code Action} called just before this {@code Completable} terminates
1915+
* @param onAfterTerminate the {@code Action} called after this {@code Completable} completes normally
1916+
* @param onDispose the {@code Action} called when the downstream disposes the subscription
19161917
* @return the new {@code Completable} instance
19171918
* @throws NullPointerException if {@code onSubscribe}, {@code onError}, {@code onComplete}
19181919
* {@code onTerminate}, {@code onAfterTerminate} or {@code onDispose} is {@code null}

src/main/java/io/reactivex/rxjava3/core/Flowable.java

+4
Original file line numberDiff line numberDiff line change
@@ -9723,6 +9723,10 @@ public final Flowable<T> doOnComplete(@NonNull Action onComplete) {
97239723
* <dd>{@code doOnEach} does not operate by default on a particular {@link Scheduler}.</dd>
97249724
* </dl>
97259725
*
9726+
* @param onNext the {@link Consumer} to invoke when the current {@code Flowable} calls {@code onNext}
9727+
* @param onError the {@code Consumer} to invoke when the current {@code Flowable} calls {@code onError}
9728+
* @param onComplete the {@link Action} to invoke when the current {@code Flowable} calls {@code onComplete}
9729+
* @param onAfterTerminate the {@code Action} to invoke when the current {@code Flowable} calls {@code onAfterTerminate}
97269730
* @return the new {@code Flowable} instance
97279731
* @throws NullPointerException if {@code onNext}, {@code onError}, {@code onComplete} or {@code onAfterTerminate} is {@code null}
97289732
* @see <a href="http://reactivex.io/documentation/operators/do.html">ReactiveX operators documentation: Do</a>

src/main/java/io/reactivex/rxjava3/core/Notification.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public final class Notification<T> {
2626

2727
final Object value;
2828

29-
/** Not meant to be implemented externally. */
29+
/** Not meant to be implemented externally.
30+
* @param value the value to carry around in the notification, not {@code null}
31+
*/
3032
private Notification(@Nullable Object value) {
3133
this.value = value;
3234
}

src/main/java/io/reactivex/rxjava3/core/Observable.java

+4
Original file line numberDiff line numberDiff line change
@@ -8608,6 +8608,10 @@ public final Observable<T> doOnComplete(@NonNull Action onComplete) {
86088608
* <dd>{@code doOnEach} does not operate by default on a particular {@link Scheduler}.</dd>
86098609
* </dl>
86108610
*
8611+
* @param onNext the {@link Consumer} to invoke when the current {@code Observable} calls {@code onNext}
8612+
* @param onError the {@code Consumer} to invoke when the current {@code Observable} calls {@code onError}
8613+
* @param onComplete the {@link Action} to invoke when the current {@code Observable} calls {@code onComplete}
8614+
* @param onAfterTerminate the {@code Action} to invoke when the current {@code Observable} calls {@code onAfterTerminate}
86118615
* @return the new {@code Observable} instance
86128616
* @throws NullPointerException if {@code onNext}, {@code onError}, {@code onComplete} or {@code onAfterTerminate} is {@code null}
86138617
* @see <a href="http://reactivex.io/documentation/operators/do.html">ReactiveX operators documentation: Do</a>

src/main/java/io/reactivex/rxjava3/exceptions/CompositeException.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ private void appendStackTrace(StringBuilder b, Throwable ex, String prefix) {
229229
}
230230

231231
abstract static class PrintStreamOrWriter {
232-
/** Prints the specified string as a line on this StreamOrWriter. */
232+
/** Prints the specified string as a line on this StreamOrWriter.
233+
* @param o string to print
234+
*/
233235
abstract void println(Object o);
234236
}
235237

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableReplay.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ public static <T> ConnectableFlowable<T> create(Flowable<T> source,
118118
}
119119

120120
/**
121-
* Creates a OperatorReplay instance to replay values of the given source observable.
122-
* @param source the source observable
123-
* @param bufferFactory the factory to instantiate the appropriate buffer when the observable becomes active
124-
* @return the connectable observable
121+
* Creates a OperatorReplay instance to replay values of the given source {@code Flowable}.
122+
* @param <T> the value type
123+
* @param source the source {@code Flowable} to use
124+
* @param bufferFactory the factory to instantiate the appropriate buffer when the {@code Flowable} becomes active
125+
* @return the {@code ConnectableFlowable} instance
125126
*/
126127
static <T> ConnectableFlowable<T> create(Flowable<T> source,
127128
final Supplier<? extends ReplayBuffer<T>> bufferFactory) {
@@ -544,6 +545,7 @@ public void dispose() {
544545
}
545546
/**
546547
* Convenience method to auto-cast the index object.
548+
* @param <U> type to cast index object
547549
* @return the current index object
548550
*/
549551
@SuppressWarnings("unchecked")

src/main/java/io/reactivex/rxjava3/internal/operators/mixed/ScalarXMapZHelper.java

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ static <T> boolean tryAsCompletable(Object source,
7878
* Try subscribing to a {@link MaybeSource} mapped from
7979
* a scalar source (which implements {@link Supplier}).
8080
* @param <T> the upstream value type
81+
* @param <R> the downstream value type
8182
* @param source the source reactive type ({@code Flowable} or {@code Observable})
8283
* possibly implementing {@link Supplier}.
8384
* @param mapper the function that turns the scalar upstream value into a
@@ -117,6 +118,7 @@ static <T, R> boolean tryAsMaybe(Object source,
117118
* Try subscribing to a {@link SingleSource} mapped from
118119
* a scalar source (which implements {@link Supplier}).
119120
* @param <T> the upstream value type
121+
* @param <R> the downstream value type
120122
* @param source the source reactive type ({@code Flowable} or {@code Observable})
121123
* possibly implementing {@link Supplier}.
122124
* @param mapper the function that turns the scalar upstream value into a

src/main/java/io/reactivex/rxjava3/internal/operators/observable/ObservableReplay.java

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public static <T> ConnectableObservable<T> create(ObservableSource<T> source,
122122

123123
/**
124124
* Creates a OperatorReplay instance to replay values of the given source observable.
125+
* @param <T> the value type
125126
* @param source the source observable
126127
* @param bufferFactory the factory to instantiate the appropriate buffer when the observable becomes active
127128
* @return the connectable observable
@@ -453,6 +454,7 @@ public void dispose() {
453454
}
454455
/**
455456
* Convenience method to auto-cast the index object.
457+
* @param <U> type index to be casted to
456458
* @return the index Object or null
457459
*/
458460
@SuppressWarnings("unchecked")

src/main/java/io/reactivex/rxjava3/internal/util/QueueDrainHelper.java

+1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ static boolean isCancelled(BooleanSupplier cancelled) {
291291
/**
292292
* Drains the queue based on the outstanding requests in post-completed mode (only!).
293293
*
294+
* @param <T> the value type
294295
* @param n the current request amount
295296
* @param actual the target Subscriber to send events to
296297
* @param queue the queue to drain if in the post-complete state

src/main/java/io/reactivex/rxjava3/observers/BaseTestConsumer.java

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public abstract class BaseTestConsumer<T, U extends BaseTestConsumer<T, U>> {
5454
*/
5555
protected boolean timeout;
5656

57+
/**
58+
* Constructs a {@code BaseTestConsumer} with {@code CountDownLatch} set to 1.
59+
*/
5760
public BaseTestConsumer() {
5861
this.values = new VolatileSizeArrayList<>();
5962
this.errors = new VolatileSizeArrayList<>();

src/test/java/io/reactivex/rxjava3/exceptions/CompositeExceptionTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void compositeExceptionFromTwoDuplicateComposites() {
148148
cex.getCause().printStackTrace();
149149
}
150150

151-
/**
151+
/*
152152
* This hijacks the Throwable.printStackTrace() output and puts it in a string, where we can look for
153153
* "CIRCULAR REFERENCE" (a String added by Throwable.printEnclosedStackTrace)
154154
*/

src/test/java/io/reactivex/rxjava3/schedulers/SchedulerTestHelper.java

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ private SchedulerTestHelper() {
2828
/**
2929
* Verifies that the given Scheduler does not deliver handled errors to its executing Thread's
3030
* {@link java.lang.Thread.UncaughtExceptionHandler}.
31+
*
32+
* @param scheduler {@link Scheduler} to verify.
3133
*/
3234
static void handledErrorIsNotDeliveredToThreadHandler(Scheduler scheduler) throws InterruptedException {
3335
Thread.UncaughtExceptionHandler originalHandler = Thread.getDefaultUncaughtExceptionHandler();

0 commit comments

Comments
 (0)