-
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
Add Refaster rule for Flux#concat
for a single Mono or Flux
#20
Conversation
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.
I pushed some suggestions, PTAL :). Nice template Phil 🚀
@@ -161,6 +161,32 @@ private ReactorTemplates() {} | |||
} | |||
} | |||
|
|||
/** Don't use {@link Flux#concat(Publisher)} with only a single {@link Mono}. */ | |||
abstract static class FluxConcatOfOneMono<T> { |
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.
We can use static final
here instead of abstract
. abstract
for templates is only when we need to use the Refaster @Placeholder
.
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.
Additionally, the convention for naming the templates is almost exactly describing the beforetemplate content. So it seems that we can even drop OfOne
.
I'll push something :)
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 @rickie !
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.
I don't know why I described it precisely the other way around here.. My bad 😅
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.
Added a commit :)
...r-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ReactorTemplates.java
Outdated
Show resolved
Hide resolved
...contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/ReactorTemplatesTestInput.java
Outdated
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.
Tnx!
/** Don't unnecessarily invoke {@link Flux#concat(Publisher)}. */ | ||
static final class FluxIdentity<T> { | ||
@BeforeTemplate | ||
Flux<T> before(Flux<T> flux) { | ||
return Flux.concat(flux); | ||
} | ||
|
||
@AfterTemplate | ||
Flux<T> after(Flux<T> flux) { | ||
return flux; | ||
} | ||
} |
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.
@rickie This template could be folded into the "vacuous conversion" bug checker we discussed a while back.
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.
Nice! Will add it to the list @Stephan202
Thx to @rickie for contributing 👍