Skip to content

Commit

Permalink
simplify error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioaniche committed Sep 30, 2024
1 parent 7a3d075 commit 3c7295e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,10 @@ public void onDataflowVisitReturn(
*/
if (allFieldsAreNonNull) {
if (evaluatesToLiteral && evaluatesToFalse) {
String message =
String.format(
"The method ensures the %s of the fields, but doesn't return true",
(trueIfNonNull ? "non-nullability" : "nullability"));
raiseError(returnTree, state, message);
raiseError(
returnTree,
state,
"The method ensures the non-nullability of the fields, but returns incorrectly");
}
} else {
if (evaluatesToTrue || !evaluatesToLiteral) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public void semanticIssues_doesntEnsureNonNullabilityOfFields() {
" @EnsuresNonNullIf(value=\"nullableItem\", result=true)",
" public boolean hasNullableItem() {",
" if(nullableItem != null) {",
" // BUG: Diagnostic contains: The method ensures the non-nullability of the fields, but doesn't return true",
" // BUG: Diagnostic contains: The method ensures the non-nullability of the fields, but returns incorrectly",
" return false;",
" } else {",
" // BUG: Diagnostic contains: Method is annotated with @EnsuresNonNullIf but does not ensure fields [nullableItem]",
Expand Down Expand Up @@ -558,7 +558,7 @@ public void semanticIssues_doesntEnsureNonNullabilityOfFields_resultFalse() {
" @EnsuresNonNullIf(value=\"nullableItem\", result=false)",
" public boolean doesNotHaveNullableItem() {",
" if(nullableItem != null) {",
" // BUG: Diagnostic contains: The method ensures the nullability of the fields, but doesn't return true",
" // BUG: Diagnostic contains: The method ensures the non-nullability of the fields, but returns incorrectly",
" return false;",
" } else {",
" // BUG: Diagnostic contains: Method is annotated with @EnsuresNonNullIf but does not ensure fields [nullableItem]",
Expand Down Expand Up @@ -681,7 +681,7 @@ public void semanticIssues_methodDeclarationReversed() {
" @EnsuresNonNullIf(value=\"nullableItem\", result=true)",
" public boolean hasNullableItem() {",
" if(nullableItem != null) {",
" // BUG: Diagnostic contains: The method ensures the non-nullability of the fields, but doesn't return true",
" // BUG: Diagnostic contains: The method ensures the non-nullability of the fields, but returns incorrectly",
" return false;",
" } else {",
" // BUG: Diagnostic contains: Method is annotated with @EnsuresNonNullIf but does not ensure fields [nullableItem]",
Expand Down

0 comments on commit 3c7295e

Please sign in to comment.