Skip to content

Commit 0514ff1

Browse files
committed
Check for Backpressure: in javadoc without annotation
1 parent 609dd16 commit 0514ff1

File tree

2 files changed

+72
-58
lines changed

2 files changed

+72
-58
lines changed

src/main/java/io/reactivex/Maybe.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,6 @@ public static <T> Maybe<T> fromFuture(Future<? extends T> future) {
631631
* <p>
632632
* <em>Important note:</em> This Maybe is blocking on the thread it gets subscribed on; you cannot unsubscribe from it.
633633
* <dl>
634-
* <dt><b>Backpressure:</b></dt>
635-
* <dd>The operator honors backpressure from downstream.</dd>
636634
* <dt><b>Scheduler:</b></dt>
637635
* <dd>{@code fromFuture} does not operate by default on a particular {@link Scheduler}.</dd>
638636
* </dl>

src/test/java/io/reactivex/JavadocWording.java

Lines changed: 72 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public void maybeDocRefersToMaybeTypes() throws Exception {
179179
}
180180
aOrAn(e, m, "Maybe");
181181
missingClosingDD(e, m, "Maybe");
182+
backpressureMentionedWithoutAnnotation(e, m, "Maybe");
182183
}
183184
}
184185

@@ -261,6 +262,7 @@ public void flowableDocRefersToFlowableTypes() throws Exception {
261262
}
262263
aOrAn(e, m, "Flowable");
263264
missingClosingDD(e, m, "Flowable");
265+
backpressureMentionedWithoutAnnotation(e, m, "Flowable");
264266
}
265267
}
266268

@@ -345,6 +347,7 @@ public void observableDocRefersToObservableTypes() throws Exception {
345347
}
346348
aOrAn(e, m, "Observable");
347349
missingClosingDD(e, m, "Observable");
350+
backpressureMentionedWithoutAnnotation(e, m, "Observable");
348351
}
349352
}
350353

@@ -500,6 +503,7 @@ public void singleDocRefersToSingleTypes() throws Exception {
500503

501504
aOrAn(e, m, "Single");
502505
missingClosingDD(e, m, "Single");
506+
backpressureMentionedWithoutAnnotation(e, m, "Single");
503507
}
504508
}
505509

@@ -510,62 +514,6 @@ public void singleDocRefersToSingleTypes() throws Exception {
510514
}
511515
}
512516

513-
static void aOrAn(StringBuilder e, RxMethod m, String baseTypeName) {
514-
aOrAn(e, m, "an", "Single", baseTypeName);
515-
aOrAn(e, m, "an", "Maybe", baseTypeName);
516-
aOrAn(e, m, "a", "Observer", baseTypeName);
517-
aOrAn(e, m, "a", "Observable", baseTypeName);
518-
aOrAn(e, m, "an", "Publisher", baseTypeName);
519-
aOrAn(e, m, "an", "Subscriber", baseTypeName);
520-
aOrAn(e, m, "an", "Flowable", baseTypeName);
521-
}
522-
523-
static void aOrAn(StringBuilder e, RxMethod m, String wrongPre, String word, String baseTypeName) {
524-
int jdx = 0;
525-
for (;;) {
526-
int idx = m.javadoc.indexOf(wrongPre + " " + word, jdx);
527-
if (idx >= 0) {
528-
e.append("java.lang.RuntimeException: a/an typo ")
529-
.append(word)
530-
.append("\r\n at io.reactivex.")
531-
.append(baseTypeName)
532-
.append(" (")
533-
.append(baseTypeName)
534-
.append(".java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
535-
jdx = idx + 6;
536-
} else {
537-
break;
538-
}
539-
}
540-
541-
}
542-
543-
static void missingClosingDD(StringBuilder e, RxMethod m, String baseTypeName) {
544-
int jdx = 0;
545-
for (;;) {
546-
int idx1 = m.javadoc.indexOf("<dd>", jdx);
547-
int idx2 = m.javadoc.indexOf("</dd>", jdx);
548-
549-
if (idx1 < 0 && idx2 < 0) {
550-
break;
551-
}
552-
553-
int idx3 = m.javadoc.indexOf("<dd>", idx1 + 4);
554-
555-
if (idx1 > 0 && idx2 > 0 && (idx3 < 0 || (idx2 < idx3 && idx3 > 0))) {
556-
jdx = idx2 + 5;
557-
} else {
558-
e.append("java.lang.RuntimeException: unbalanced <dd></dd> ")
559-
.append("\r\n at io.reactivex.")
560-
.append(baseTypeName)
561-
.append(" (")
562-
.append(baseTypeName)
563-
.append(".java:").append(m.javadocLine + lineNumber(m.javadoc, idx1) - 1).append(")\r\n\r\n");
564-
break;
565-
}
566-
}
567-
}
568-
569517
@Test
570518
public void completableDocRefersToCompletableTypes() throws Exception {
571519
List<RxMethod> list = BaseTypeParser.parse(MaybeNo2Dot0Since.findSource("Completable"), "Completable");
@@ -710,6 +658,7 @@ public void completableDocRefersToCompletableTypes() throws Exception {
710658
}
711659
aOrAn(e, m, "Completable");
712660
missingClosingDD(e, m, "Completable");
661+
backpressureMentionedWithoutAnnotation(e, m, "Completable");
713662
}
714663
}
715664

@@ -719,4 +668,71 @@ public void completableDocRefersToCompletableTypes() throws Exception {
719668
fail(e.toString());
720669
}
721670
}
671+
672+
static void aOrAn(StringBuilder e, RxMethod m, String baseTypeName) {
673+
aOrAn(e, m, "an", "Single", baseTypeName);
674+
aOrAn(e, m, "an", "Maybe", baseTypeName);
675+
aOrAn(e, m, "a", "Observer", baseTypeName);
676+
aOrAn(e, m, "a", "Observable", baseTypeName);
677+
aOrAn(e, m, "an", "Publisher", baseTypeName);
678+
aOrAn(e, m, "an", "Subscriber", baseTypeName);
679+
aOrAn(e, m, "an", "Flowable", baseTypeName);
680+
}
681+
682+
static void aOrAn(StringBuilder e, RxMethod m, String wrongPre, String word, String baseTypeName) {
683+
int jdx = 0;
684+
for (;;) {
685+
int idx = m.javadoc.indexOf(wrongPre + " " + word, jdx);
686+
if (idx >= 0) {
687+
e.append("java.lang.RuntimeException: a/an typo ")
688+
.append(word)
689+
.append("\r\n at io.reactivex.")
690+
.append(baseTypeName)
691+
.append(" (")
692+
.append(baseTypeName)
693+
.append(".java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
694+
jdx = idx + 6;
695+
} else {
696+
break;
697+
}
698+
}
699+
700+
}
701+
702+
static void missingClosingDD(StringBuilder e, RxMethod m, String baseTypeName) {
703+
int jdx = 0;
704+
for (;;) {
705+
int idx1 = m.javadoc.indexOf("<dd>", jdx);
706+
int idx2 = m.javadoc.indexOf("</dd>", jdx);
707+
708+
if (idx1 < 0 && idx2 < 0) {
709+
break;
710+
}
711+
712+
int idx3 = m.javadoc.indexOf("<dd>", idx1 + 4);
713+
714+
if (idx1 > 0 && idx2 > 0 && (idx3 < 0 || (idx2 < idx3 && idx3 > 0))) {
715+
jdx = idx2 + 5;
716+
} else {
717+
e.append("java.lang.RuntimeException: unbalanced <dd></dd> ")
718+
.append("\r\n at io.reactivex.")
719+
.append(baseTypeName)
720+
.append(" (")
721+
.append(baseTypeName)
722+
.append(".java:").append(m.javadocLine + lineNumber(m.javadoc, idx1) - 1).append(")\r\n\r\n");
723+
break;
724+
}
725+
}
726+
}
727+
728+
static void backpressureMentionedWithoutAnnotation(StringBuilder e, RxMethod m, String baseTypeName) {
729+
if (m.backpressureDocLine > 0 && m.backpressureKind == null) {
730+
e.append("java.lang.RuntimeException: backpressure documented but not annotated ")
731+
.append("\r\n at io.reactivex.")
732+
.append(baseTypeName)
733+
.append(" (")
734+
.append(baseTypeName)
735+
.append(".java:").append(m.backpressureDocLine).append(")\r\n\r\n");
736+
}
737+
}
722738
}

0 commit comments

Comments
 (0)