diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java index 273e0eea17..2fbee57d69 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java @@ -1728,6 +1728,19 @@ PublisherProbe after() { } } + /** Prefer {@link Flux#just(Object)} over more verbose alternatives. */ + static final class MonoJustRepeatTakeOne { + @BeforeTemplate + Flux before(T value) { + return Mono.just(value).repeat().take(1); + } + + @AfterTemplate + Flux after(T value) { + return Flux.just(value); + } + } + /** Prefer {@link Mono#as(Function)} when creating a {@link StepVerifier}. */ static final class StepVerifierFromMono { @BeforeTemplate diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java index 1efc888cc4..dc5df7bc18 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java @@ -585,6 +585,10 @@ ImmutableSet> testPublisherProbeEmpty() { return ImmutableSet.of(PublisherProbe.of(Mono.empty()), PublisherProbe.of(Flux.empty())); } + Flux testMonoJustRepeatTakeOne() { + return Mono.just(5).repeat().take(1); + } + ImmutableSet> testStepVerifierFromMono() { return ImmutableSet.of( StepVerifier.create(Mono.just(1)), Mono.just(2).flux().as(StepVerifier::create)); diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java index 7e4c325bf1..129926c06c 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java @@ -574,6 +574,10 @@ ImmutableSet> testPublisherProbeEmpty() { return ImmutableSet.of(PublisherProbe.empty(), PublisherProbe.empty()); } + Flux testMonoJustRepeatTakeOne() { + return Flux.just(5); + } + ImmutableSet> testStepVerifierFromMono() { return ImmutableSet.of( Mono.just(1).as(StepVerifier::create), Mono.just(2).as(StepVerifier::create));