Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamugare committed Apr 26, 2019
1 parent 7d27261 commit 413476b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 7 additions & 5 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Expand Up @@ -639,12 +639,14 @@ private Description checkReturnExpression(
return Description.NO_MATCH;
}
if (mayBeNullExpr(state, retExpr)) {
String message = "returning @Nullable expression from method with @NonNull return type";
final ErrorMessage errorMessage =
new ErrorMessage(
MessageTypes.RETURN_NULLABLE,
"returning @Nullable expression from method with @NonNull return type");
handler.onPrepareErrorMessage(retExpr, state, errorMessage);

return errorBuilder.createErrorDescriptionForNullAssignment(
new ErrorMessage(MessageTypes.RETURN_NULLABLE, message),
retExpr,
state.getPath(),
buildDescription(tree));
errorMessage, retExpr, state.getPath(), buildDescription(tree));
}
return Description.NO_MATCH;
}
Expand Down
5 changes: 4 additions & 1 deletion nullaway/src/test/java/com/uber/nullaway/NullAwayTest.java
Expand Up @@ -1575,7 +1575,7 @@ public void OptionalEmptinessRxPositiveTest() {
" .map(optional -> optional.get().toString());",
" observable",
" .filter(optional -> optional.isPresent() || perhaps())",
" // BUG: Diagnostic contains: returning @Nullable expression from method with @NonNull",
" // BUG: Diagnostic contains: Optional optional can be empty",
" .map(optional -> optional.get())",
" .map(irr -> irr.toString());",
" }",
Expand All @@ -1602,6 +1602,9 @@ public void OptionalEmptinessRxNegativeTest() {
" private static boolean perhaps() { return Math.random() > 0.5; }",
" void foo(Observable<Optional<String>> observable) {",
" observable",
" .filter(optional -> optional.isPresent())",
" .map(optional -> optional.get().toString());",
" observable",
" .filter(optional -> optional.isPresent() && perhaps())",
" .map(optional -> optional.get().toString());",
" observable",
Expand Down

0 comments on commit 413476b

Please sign in to comment.