-
-
Couldn't load subscription status.
- Fork 101
Introduce @ParametersAreNonnullByDefault #541
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
Conversation
|
Add a way so sonarcloud flags notnull/nullable from Jetbrains? |
Good idea. I just checked but didnt find any rule. Unfortunately, we can not add custom rules with Sonarcloud (need -qube for that). So we would need a self-written test in the code using reflection. Not a big deal, but welp... |
|
Does the @ParametersAreNonnullByDefault work with public and private methods? |
|
It works with all methods in the whole package with the annotation. The way this PR sets it up, all code in the applications and database gradle modules has not-null as default for all method parameters now. |
Rly nice change, just as curiosity is the possible to add for example @nullable to private methods or it is now impossible to have null parameters in private methods? |
|
Yes. It is just about the implicit default, which is now Note that its still necessary to always annotate return types - no default for that. As a side note, these annotations actually dont add checks in the code. You can still pass |
7d598ad to
beb8f9b
Compare
|
Kudos, SonarCloud Quality Gate passed! |
|
Merging this, seems to be fine - if not, we can act afterwards. Want to accelerate development for this, need to get out a release for all the major improvements. Also, its weekened and I want to code a bit 😄 |
|
I tried to use the |
|
Its expected. The annotations only add IDE warnings and nothing else. They do not actually manipulate the code at all, nor add real security in the code. An alternative for that would be Lombok. |








Overview
Closes #539.
This cleans up the usage of
@NotNull/@Nonnull/@Nullableand improves the situation by adding@ParametersAreNonnullByDefaultto all packages.The changes are:
@ParametersAreNonnullByDefaultto all existingpackage-info.java(in application and database)@NotNullfrom all method parameters (its the default now)@NotNullon return types and similar by@Nonnullto consistently usejavax.annotations@Nullablefrom Jetbrains by@Nullablefromjavax.annotations@Nonnull/@Nullableon some return typesFun fact, with these changes, Sonar even found a missing
@NullableinTopHelperCommand.Review
This is a huge PR, but with very minor and simple changes. It will also confuse a lot of merge conflicts (but simple conflicts). Ideally we merge this PR as soon as possible, as it will get conflicts with each merge while it is open.
For reviewing this, it is only really important to make sure that I neither removed a
@Nullable, nor replaced one with@Nonnullor similar.It is not important to actually really read the code. Skimming over the changes should be sufficient.
It is possible that some formatting went weird due to the heavy annotation removal + spotless. If you found any odd looking spot, tell in review and I will correct it.