Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid suggesting castToNonNull fixes in certain cases #799

Merged
merged 11 commits into from
Aug 25, 2023

Conversation

msridhar
Copy link
Collaborator

@msridhar msridhar commented Aug 4, 2023

We avoid suggesting a castToNonNull fix if either (1) the expression is the null literal (i.e., don't suggest castToNonNull(null)), or (2) the expression is a @Nullable parameter (see code comments for justification). In these cases, we suggest a @SuppressWarnings annotation instead.

Here we also add some tests to improve coverage of the ErrorBuilder class.

@coveralls
Copy link

coveralls commented Aug 4, 2023

Pull Request Test Coverage Report for Build #1182

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 6 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.3%) to 93.405%

Files with Coverage Reduction New Missed Lines %
../nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPath.java 1 96.32%
../nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java 5 96.72%
Totals Coverage Status
Change from base Build #1176: 0.3%
Covered Lines: 5750
Relevant Lines: 6156

💛 - Coveralls

@msridhar msridhar marked this pull request as draft August 4, 2023 23:59
@msridhar msridhar removed the request for review from lazaroclapp August 19, 2023 02:54
@msridhar msridhar marked this pull request as ready for review August 21, 2023 01:05
@msridhar
Copy link
Collaborator Author

Tested this more and didn't see any weird crashes or unexpected behaviors, so I think it's ready for review.

Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, minor comments below.

" return castToNonNull(o);",
" }",
"}")
.doTest();
}

@Test
public void suppressInsteadOfCastToNonNull() throws IOException {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment noting which cases these are and referencing the ErrorBuilder docs? Just because when not seen as part of the PR it might be hard to remember why we want this behavior.

Also, can we add a case where null is assigned to a non-null field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b84a4f7

@msridhar
Copy link
Collaborator Author

@lazaroclapp addressed your comments and also added a few more tests for ErrorBuilder code that was uncovered

Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! Appreciate the added coverage of existing code.

What I believe to be the most minor nit humanly possible below:

nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java Outdated Show resolved Hide resolved
Co-authored-by: Lázaro Clapp <lazaro@uber.com>
@msridhar msridhar enabled auto-merge (squash) August 25, 2023 17:49
@msridhar msridhar merged commit 154b758 into master Aug 25, 2023
8 checks passed
@msridhar msridhar deleted the manu/tweak-cast-suppressions branch September 4, 2023 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants