Skip to content

Commit ced572d

Browse files
author
Zac Sweers
committedNov 20, 2018
Rework checkCheckReturnValueSupport test for optional check
1 parent 64fcd67 commit ced572d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed
 

‎src/test/java/io/reactivex/validators/BaseTypeAnnotations.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,18 @@ static void checkCheckReturnValueSupport(Class<?> clazz) {
4242
continue;
4343
}
4444
if (m.getDeclaringClass() == clazz) {
45-
boolean isSubscribeMethod = "subscribe".equals(m.getName()) && m.getParameterTypes().length == 0;
45+
boolean isSubscribeMethod = "subscribe".equals(m.getName());
46+
boolean isNoArgSubscribeMethod = isSubscribeMethod && m.getParameterTypes().length == 0;
4647
boolean isAnnotationPresent = m.isAnnotationPresent(CheckReturnValue.class);
48+
boolean isVoid = m.getReturnType().equals(Void.TYPE);
4749

4850
if (isSubscribeMethod) {
49-
if (isAnnotationPresent) {
50-
b.append("subscribe() method has @CheckReturnValue: ").append(m).append("\r\n");
51+
if (isNoArgSubscribeMethod) {
52+
if (isAnnotationPresent) {
53+
b.append("subscribe() method has @CheckReturnValue: ").append(m).append("\r\n");
54+
}
55+
} else if (!isVoid && !m.isAnnotationPresent(OptionalCheckReturnValue.class)) {
56+
b.append("subscribe() method missing @OptionalCheckReturnValue: ").append(m).append("\r\n");
5157
}
5258
continue;
5359
}
@@ -57,7 +63,7 @@ static void checkCheckReturnValueSupport(Class<?> clazz) {
5763
continue;
5864
}
5965

60-
if (m.getReturnType().equals(Void.TYPE)) {
66+
if (isVoid) {
6167
if (isAnnotationPresent) {
6268
b.append("Void method has @CheckReturnValue: ").append(m).append("\r\n");
6369
}

0 commit comments

Comments
 (0)