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

Ensure castToNonNull insertion/removal suggested fixes do not remove comments #815

Merged
merged 5 commits into from Aug 25, 2023

Conversation

msridhar
Copy link
Collaborator

We now preserve the original source code of the AST node for which we are adding or removing a cast, ensuring that comments within the node are preserved.

@coveralls
Copy link

coveralls commented Aug 25, 2023

Pull Request Test Coverage Report for Build #1185

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 93.421%

Files with Coverage Reduction New Missed Lines %
../nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java 2 96.72%
Totals Coverage Status
Change from base Build #1183: 0.03%
Covered Lines: 5751
Relevant Lines: 6156

💛 - Coveralls

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.

Modulo the question below (and I also can't think of an example which would have any issues), this LGTM!

" static class Foo { @Nullable Object getObj() { return null; } }",
" Object test1(Foo f) {",
" return f",
" // comment that should not be deleted",
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens in the nonNullF = nullVal; // some comment case? Just nonNullF = castToNonNull(nullVal); // some comment, I assume?

Is there any case you can imagine where the comment ends up inside the castToNonNull(...) call like here, but without a newline between the comment and )?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll add a couple more tests. We could also have castToNonNull(f./* comment */getObj())

@msridhar msridhar enabled auto-merge (squash) August 25, 2023 20:27
@msridhar msridhar merged commit c42b0f7 into master Aug 25, 2023
8 checks passed
@msridhar msridhar deleted the manu/casttononnull-fix-no-comment-delete 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