@@ -317,65 +317,7 @@ public void flowableDocRefersToFlowableTypes() throws Exception {
317
317
}
318
318
}
319
319
320
- if (m .signature .matches ("(?s).*?\\ sSingle\\ <.*?\\ >\\ s+\\ w+\\ (.*" )) {
321
- for (String at : AT_RETURN_WORDS ) {
322
- int idx = m .javadoc .indexOf (at + "{@code Flowable" );
323
- if (idx >= 0 ) {
324
- e .append ("Returns Single but docs return Flowable\r \n at io.reactivex.rxjava3.core." )
325
- .append ("Flowable.method(Flowable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
326
- }
327
- idx = m .javadoc .indexOf (at + "{@code Maybe" );
328
- if (idx >= 0 ) {
329
- e .append ("Returns Single but docs return Maybe\r \n at io.reactivex.rxjava3.core." )
330
- .append ("Flowable.method(Flowable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
331
- }
332
- idx = m .javadoc .indexOf (at + "{@code Publisher" );
333
- if (idx >= 0 ) {
334
- e .append ("Returns Single but docs return Publisher\r \n at io.reactivex.rxjava3.core." )
335
- .append ("Flowable.method(Flowable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
336
- }
337
- }
338
- }
339
-
340
- if (m .signature .matches ("(?s).*?\\ sMaybe\\ <.*\\ >\\ s+\\ w+\\ (.*" )) {
341
- for (String at : AT_RETURN_WORDS ) {
342
- int idx = m .javadoc .indexOf (at + "{@code Flowable" );
343
- if (idx >= 0 ) {
344
- e .append ("Returns Maybe but docs return Flowable\r \n at io.reactivex.rxjava3.core." )
345
- .append ("Flowable.method(Flowable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
346
- }
347
- idx = m .javadoc .indexOf (at + "{@code Single" );
348
- if (idx >= 0 ) {
349
- e .append ("Returns Maybe but docs return Single\r \n at io.reactivex.rxjava3.core." )
350
- .append ("Flowable.method(Flowable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
351
- }
352
- idx = m .javadoc .indexOf (at + "{@code Publisher" );
353
- if (idx >= 0 ) {
354
- e .append ("Returns Maybe but docs return Publisher\r \n at io.reactivex.rxjava3.core." )
355
- .append ("Flowable.method(Flowable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
356
- }
357
- }
358
- }
359
-
360
- if (m .signature .matches ("(?s).*?\\ sCompletable\\ s+\\ w+\\ (.*" )) {
361
- for (String at : AT_RETURN_WORDS ) {
362
- int idx = m .javadoc .indexOf (at + "{@code Flowable" );
363
- if (idx >= 0 ) {
364
- e .append ("Returns Completable but docs return Flowable\r \n at io.reactivex.rxjava3.core." )
365
- .append ("Flowable.method(Flowable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
366
- }
367
- idx = m .javadoc .indexOf (at + "{@code Single" );
368
- if (idx >= 0 ) {
369
- e .append ("Returns Completable but docs return Single\r \n at io.reactivex.rxjava3.core." )
370
- .append ("Flowable.method(Flowable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
371
- }
372
- idx = m .javadoc .indexOf (at + "{@code Maybe" );
373
- if (idx >= 0 ) {
374
- e .append ("Returns Completable but docs return Maybe\r \n at io.reactivex.rxjava3.core." )
375
- .append ("Flowable.method(Flowable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
376
- }
377
- }
378
- }
320
+ checkAtReturnAndSignatureMatch ("Flowable" , m , e , "Flowable" , "Observable" , "Maybe" , "Single" , "Completable" );
379
321
380
322
aOrAn (e , m , "Flowable" );
381
323
missingClosingDD (e , m , "Flowable" );
@@ -478,55 +420,7 @@ public void observableDocRefersToObservableTypes() throws Exception {
478
420
break ;
479
421
}
480
422
}
481
- if (m .signature .matches ("(?s).*?\\ sSingle\\ <.*?\\ >\\ s+\\ w+\\ (.*" )) {
482
- for (String at : AT_RETURN_WORDS ) {
483
- int idx = m .javadoc .indexOf (at + "{@code Observable" );
484
- if (idx >= 0 ) {
485
- e .append ("Returns Single but docs return Observable\r \n at io.reactivex.rxjava3.core." )
486
- .append ("Observable.method(Observable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
487
- }
488
- idx = m .javadoc .indexOf (at + "{@code Maybe" );
489
- if (idx >= 0 ) {
490
- e .append ("Returns Single but docs return Maybe\r \n at io.reactivex.rxjava3.core." )
491
- .append ("Observable.method(Observable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
492
- }
493
- }
494
- }
495
-
496
- if (m .signature .matches ("(?s).*?\\ sMaybe\\ <.*?\\ >\\ s+\\ w+\\ (.*" )) {
497
- for (String at : AT_RETURN_WORDS ) {
498
- int idx = m .javadoc .indexOf (at + "{@code Observable" );
499
- if (idx >= 0 ) {
500
- e .append ("Returns Maybe but docs return Observable\r \n at io.reactivex.rxjava3.core." )
501
- .append ("Observable.method(Observable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
502
- }
503
- idx = m .javadoc .indexOf (at + "{@code Single" );
504
- if (idx >= 0 ) {
505
- e .append ("Returns Maybe but docs return Single\r \n at io.reactivex.rxjava3.core." )
506
- .append ("Observable.method(Observable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
507
- }
508
- }
509
- }
510
-
511
- if (m .signature .matches ("(?s).*?\\ sCompletable\\ s+\\ w+\\ (.*" )) {
512
- for (String at : AT_RETURN_WORDS ) {
513
- int idx = m .javadoc .indexOf (at + "{@code Observable" );
514
- if (idx >= 0 ) {
515
- e .append ("Returns Completable but docs return Observable\r \n at io.reactivex.rxjava3.core." )
516
- .append ("Observable.method(Observable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
517
- }
518
- idx = m .javadoc .indexOf (at + "{@code Single" );
519
- if (idx >= 0 ) {
520
- e .append ("Returns Completable but docs return Single\r \n at io.reactivex.rxjava3.core." )
521
- .append ("Observable.method(Observable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
522
- }
523
- idx = m .javadoc .indexOf (at + "{@code Maybe" );
524
- if (idx >= 0 ) {
525
- e .append ("Returns Completable but docs return Maybe\r \n at io.reactivex.rxjava3.core." )
526
- .append ("Observable.method(Observable.java:" ).append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 ).append (")\r \n \r \n " );
527
- }
528
- }
529
- }
423
+ checkAtReturnAndSignatureMatch ("Observable" , m , e , "Flowable" , "Observable" , "Maybe" , "Single" , "Completable" );
530
424
531
425
aOrAn (e , m , "Observable" );
532
426
missingClosingDD (e , m , "Observable" );
@@ -890,6 +784,9 @@ public void completableDocRefersToCompletableTypes() throws Exception {
890
784
break ;
891
785
}
892
786
}
787
+
788
+ checkAtReturnAndSignatureMatch ("Completable" , m , e , "Flowable" , "Observable" , "Maybe" , "Single" , "Completable" );
789
+
893
790
aOrAn (e , m , "Completable" );
894
791
missingClosingDD (e , m , "Completable" );
895
792
backpressureMentionedWithoutAnnotation (e , m , "Completable" );
@@ -903,6 +800,38 @@ public void completableDocRefersToCompletableTypes() throws Exception {
903
800
}
904
801
}
905
802
803
+ static void checkAtReturnAndSignatureMatch (String className , RxMethod m , StringBuilder e , String ... types ) {
804
+ for (String t : types ) {
805
+ String regex ;
806
+ if (t .contains ("Completable" )) {
807
+ regex = "(?s).*?\\ s" + t + "\\ s+\\ w+\\ (.*" ;
808
+ } else {
809
+ regex = "(?s).*?\\ s" + t + "\\ <.*?\\ >\\ s+\\ w+\\ (.*" ;
810
+ }
811
+ if (m .signature .matches (regex )) {
812
+ for (String at : AT_RETURN_WORDS ) {
813
+ for (String u : types ) {
814
+ if (!t .equals (u )) {
815
+ int idx = m .javadoc .indexOf (at + "{@code " + u );
816
+ if (idx >= 0 ) {
817
+ e .append ("Returns " ).append (t )
818
+ .append (" but docs return " )
819
+ .append (u )
820
+ .append ("\r \n at io.reactivex.rxjava3.core." )
821
+ .append (className )
822
+ .append (".method(" )
823
+ .append (className )
824
+ .append (".java:" )
825
+ .append (m .javadocLine + lineNumber (m .javadoc , idx ) - 1 )
826
+ .append (")\r \n \r \n " );
827
+ }
828
+ }
829
+ }
830
+ }
831
+ }
832
+ }
833
+ }
834
+
906
835
static void aOrAn (StringBuilder e , RxMethod m , String baseTypeName ) {
907
836
aOrAn (e , m , " an" , "Single" , baseTypeName );
908
837
aOrAn (e , m , " an" , "Maybe" , baseTypeName );
0 commit comments