-
Notifications
You must be signed in to change notification settings - Fork 46
Introduce FluxCollectToImmutableList
Refaster rule
#570
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
Looks good. No mutations were possible for these changes. |
error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.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.
Added a commit with an extra rule :). Changes LGTM!
Slightly tweaked the suggested commit message.
*/ | ||
static final class FluxCollectListToCollectImmutableList<T> { | ||
@BeforeTemplate | ||
Mono<List<T>> before(Flux<T> 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.
We can add: flux.collect(toImmutableList()).map(ImmutableList::copyOf);
.
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.
Hmm, the ((Mono<ImmutableList<T>>) flux).map(ImmutableList::copyOf)
simplification should be in a rule of its own. (And is in fact a special case of a large range of rules.)
Looks good. No mutations were possible for these changes. |
error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java
Outdated
Show resolved
Hide resolved
Looks good. No mutations were possible for these changes. |
eb80bb2
to
013ba14
Compare
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 and added a commit.
Suggested commit message:
Introduce `FluxCollectToImmutableList` Refaster rule (#570)
And extend `MonoIdentity` to simplify `mono.map(ImmutableList::copyOf)`
expressions where possible, as the new rule may introduce such cases.
Mono<List<T>> after(Flux<T> flux) { | ||
return flux.collect(toImmutableList()); |
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.
Let's make explicit that strictly speaking this expression has a slightly different return type.
*/ | ||
static final class FluxCollectListToCollectImmutableList<T> { | ||
@BeforeTemplate | ||
Mono<List<T>> before(Flux<T> 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.
Hmm, the ((Mono<ImmutableList<T>>) flux).map(ImmutableList::copyOf)
simplification should be in a rule of its own. (And is in fact a special case of a large range of rules.)
Looks good. No mutations were possible for these changes. |
Kudos, SonarCloud Quality Gate passed!
|
013ba14
to
432ba2d
Compare
Rebased and resolved ✅ |
Looks good. No mutations were possible for these changes. |
432ba2d
to
1ef57fb
Compare
Changes LGTM! Will merge once 🟢. |
Looks good. No mutations were possible for these changes. |
Flux#collect(toImmutableList())
over Flux#collectList()
FluxCollectToImmutableList
Refaster rule
Based on internal inquiry
Suggested commit message: