-
Notifications
You must be signed in to change notification settings - Fork 39
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
Disallow static import of {Mono,Flux}
and partially allow empty
#992
Conversation
Looks good. No mutations were possible for these changes. |
empty
{Mono,Flux}
and partially allow empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 💪
error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
Changes look good but are we sure we want we want to disallow all static imports for Most of the present use cases seem to fall into this pattern public Mono<BankAccountDto> findBankAccountByPicnicId(@PathVariable String picnicId) {
return bankAccountService
.findByEmployeePicnicId(picnicId)
.flatMap(this::mapBankAccount)
.switchIfEmpty(error(itemNotFound("Bank Data of Employee", picnicId)));
} Which doesn't look that bad to me (but consistency might justify disallowing it). |
Good point, when I was looking to usages in our codebase I couldn't find many other edge cases. We could of course decide to only allow |
e860de0
to
30e2816
Compare
Looks good. No mutations were possible for these changes. |
Feels a bit random. In the example with the controller it is clear that But now that I think more about it maybe sometimes it is not clear at all Flux.range(0, 100)
.map(x -> error(...)); Is that |
30e2816
to
406f1b3
Compare
Looks good. No mutations were possible for these changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased. Alternative suggested commit message:
Update `{,Non}StaticImport` checks (#992)
Summary of changes:
- Disallow static import of `Mono` and `Flux` members.
- Allow static import of `empty` methods.
- Disallow static import of `Optional#empty`.
@mohamedsamehsalah anything else from your side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing else from my side ✅
Thanks for checking @Stephan202 🙏
406f1b3
to
de3fdcd
Compare
Quality Gate passedIssues Measures |
Looks good. No mutations were possible for these changes. |
Suggested commit message:
Slightly different then what we discussed. Instead of only adding
{Mono,Flux}#empty
, I figured we want to basically never import something fromMono
andFlux
. ForMono
we have ~26 static imports internally.