NullAway
NullAway copied to clipboard
Not inferring from a first filter in case of two consecutive filters
Found this false positive in the code while using.
class Aclass {
class Name {
@Nullable String firstName;
@Nullable String lastName;
@Nullable String middleName;
}
@Contract("null -> true")
public boolean isBlank(@Nullable String string) {
return string == null || string.trim().length() == 0;
}
private Observable<Integer> filterThenMap(Observable<Name> observable) {
return observable
.filter(name -> !isBlank(name.firstName) && name.middleName!=null)
.filter(name -> name.lastName!=null)
.map(name -> name.firstName.length());
}
}
This gives warning: [NullAway] dereferenced expression name.firstName is @Nullable at
.map(name -> name.firstName.length());
Yeah I think our Rx support is a bit brittle and needs one-off support for cases like this. We can think about how to make it more robust.