| 1 |
/* |
| 2 |
* Copyright (c) 2016-present, RxJava Contributors. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See |
| 11 |
* the License for the specific language governing permissions and limitations under the License. |
| 12 |
*/ |
| 13 |
|
| 14 |
package io.reactivex.rxjava3.internal.util; |
| 15 |
|
| 16 |
import java.io.File; |
| 17 |
import java.nio.file.Files; |
| 18 |
import java.util.List; |
| 19 |
|
| 20 |
import io.reactivex.rxjava3.core.*; |
| 21 |
import io.reactivex.rxjava3.parallel.ParallelFlowable; |
| 22 |
import io.reactivex.rxjava3.testsupport.TestHelper; |
| 23 |
|
| 24 |
/** |
| 25 |
* Scan the JavaDocs of the base classes and list those which do not have the {@code @throws} tag. |
| 26 |
* The lack is not an error by itself but worth looking at. |
| 27 |
*/ |
| 28 |
public final class JavadocNoThrows { |
| 29 |
|
| 30 |
private JavadocNoThrows() { |
| 31 |
throw new IllegalArgumentException("No instances!"); |
| 32 |
} |
| 33 |
|
| 34 |
public static void main(String[] args) throws Exception { |
| 35 |
for (Class<?> clazz : CLASSES) { |
| 36 |
String clazzName = clazz.getSimpleName(); |
| 37 |
String packageName = clazz.getPackage().getName(); |
| 38 |
File f = TestHelper.findSource(clazzName, packageName); |
| 39 |
|
| 40 |
List<String> lines = Files.readAllLines(f.toPath()); |
| 41 |
|
| 42 |
for (int i = 1; i < lines.size(); i++) { |
| 43 |
String line = lines.get(i).trim(); |
| 44 |
|
| 45 |
if (line.startsWith("/**")) { |
| 46 |
boolean found = false; |
| 47 |
for (int j = i + 1; j < lines.size(); j++) { |
| 48 |
|
| 49 |
String line2 = lines.get(j).trim(); |
| 50 |
if (line2.startsWith("public")) { |
| 51 |
if (line2.endsWith("() {")) { |
| 52 |
found = true; |
| 53 |
} |
| 54 |
break; |
| 55 |
} |
| 56 |
if (line2.startsWith("* @throws")) { |
| 57 |
found = true; |
| 58 |
break; |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
if (!found) { |
| 63 |
System.out.printf(" at %s.%s.method(%s.java:%s)%n%n", packageName, clazzName, clazzName, i + 1); |
| 64 |
} |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
static final Class<?>[] CLASSES = { |
| 71 |
Flowable.class, Observable.class, Maybe.class, Single.class, Completable.class, ParallelFlowable.class |
| 72 |
}; |
| 73 |
} |