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

Introduce Reactor MonoJustRepeatTakeOne Refaster rule #1253

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tijana-ninkovic
Copy link

Summary

This PR introduces the MonoJustRepeatTakeOne rule, which replaces the following pattern

Mono.just(value).repeat().take(1);

with

Flux.just(value);

Suggested Commit Message

Introduce Reactor `MonoJustRepeatTakeOne` Refaster rule

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

sonarcloud bot commented Jul 17, 2024

@rickie rickie added this to the 0.17.0 milestone Jul 17, 2024
@@ -1727,6 +1727,19 @@ PublisherProbe<T> after() {
}
}

/** Prefer {@link Flux#just(Object)} over more verbose alternatives. */
static final class MonoJustRepeatTakeOne<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a undocumented rule about the naming of Refaster rules, we name them like the content of their after template. In this case that would clash with the already existing FluxJust Refaster rule, didn't know that was already there.

That changes some things a little bit;

  • We can move this rule up a bit to be together with that one. We should rename the other one then as that has a limitation that it only works for Integers.
  • Didn't see this upfront, but I think we can combine the two rules into one! Let's take a look together tomorrow @tijana-ninkovic :).

@@ -584,6 +584,10 @@ ImmutableSet<PublisherProbe<Void>> testPublisherProbeEmpty() {
return ImmutableSet.of(PublisherProbe.of(Mono.empty()), PublisherProbe.of(Flux.empty()));
}

Flux<Integer> testMonoJustRepeatTakeOne() {
return Mono.just(5).repeat().take(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within each test, we usually start with value 0 and go up from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants