Eclipse's NonNullByDefault annotation should also check fields

Hi,

I recently used Eclipse’s NonNullByDefault annotation at a package level, and I noticed it’s not checking for fields. The return type and parameters work just fine; they are null by default. But fields are not being checked even though the annotation is supposed to support FIELD in its DefaultLocation. I think this annotation should also check for fields, given its value can be configured to include them or not, right?

I did some digging in the code as I’m interested in contributing to SonarLint, and I found that only the Spring annotation @org.springframework.lang.NonNullFields is checking for fields, so I opened a small Pull Request with a fix, I hope it could be helpful to address this issue :slightly_smiling_face:

I’m looking forward to any feedback on this.

Cheers!

2 Likes

Hello @JoseLion

I confirm that NonNullByDefault from Eclipse is only partially supported, and it makes sense to add the support for DefaultLocation.FIELD.

Ticket created: SONARJAVA-3710.

We will have a look at your PR shortly.

Best,
Quentin

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.