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

NullableOnMethodReturnType seems incomplete #318

Open
Bananeweizen opened this issue Aug 1, 2024 · 3 comments
Open

NullableOnMethodReturnType seems incomplete #318

Bananeweizen opened this issue Aug 1, 2024 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Bananeweizen
Copy link
Contributor

I've just reviewed the new NullableOnMethodReturnType recipe after receiving the latest release locally. To me it seems incomplete:

  • It handles Nullable, but not the opposite annotation ("NonNull", "NotNull" or other variants)
  • it seems to handle only the rewrite.internal.Nullable annotation, no other Nullable (like checker framework, Eclipse JDT, ...) due to relying on the class reference, not the simple class name literal.

Please be aware I only read the code and didn't run any test. So I might be completely wrong with this analysis.

@Bananeweizen Bananeweizen added the bug Something isn't working label Aug 1, 2024
@timtebeek
Copy link
Contributor

Hi! I'ts been developed to scratch an internal itch, and to that end makes some assumptions indeed. We have an convention of annotating the package with NonNullApi in package-info.java, which is why there's no equivalent handling of NonNull. Similarly, we consistently use our internal Nullable annotation, which is why you don't see other annotations handled.

We could make the recipe more broadly applicable by giving it an @Option of which annotation to match, such that folks can override the default with a declarative recipe. Would that be an acceptable solution for both of the cases you've mentioned?

@timtebeek timtebeek added the question Further information is requested label Aug 1, 2024
@Bananeweizen
Copy link
Contributor Author

Such an option should be sufficient for both cases. Is there a general convention on whether such an option should be multi-valued (which would depend on the recipe author), or whether the recipe should be listed multiple times with single values by the user? Just wondering if that makes a difference for performance...

@timtebeek timtebeek removed the question Further information is requested label Aug 1, 2024
@timtebeek timtebeek moved this to Backlog in OpenRewrite Aug 1, 2024
@timtebeek timtebeek added enhancement New feature or request and removed bug Something isn't working labels Aug 1, 2024
@timtebeek
Copy link
Contributor

I like simplicity, so I'd lean towards just repeating the recipe with different arguments in a recipeList:, as you can see here. The runtime characteristics would be slightly different, but negligible when compared to other recipes that call out to Maven Central.

@timtebeek timtebeek added the good first issue Good for newcomers label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

2 participants