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 2fbee57d69..1f97c40fd3 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 @@ -481,15 +481,20 @@ Flux after() { } /** Prefer {@link Flux#just(Object)} over more contrived alternatives. */ - static final class FluxJust { + static final class FluxJust { @BeforeTemplate - Flux before(int start) { - return Flux.range(start, 1); + Flux before(int value) { + return Flux.range(value, 1); + } + + @BeforeTemplate + Flux before(T value) { + return Mono.just(value).repeat().take(1); } @AfterTemplate - Flux after(int start) { - return Flux.just(start); + Flux after(T value) { + return Flux.just(value); } } @@ -1728,19 +1733,6 @@ 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 dc5df7bc18..9325e1f9ce 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 @@ -183,8 +183,8 @@ ImmutableSet> testFluxEmpty() { Flux.range(0, 0)); } - Flux testFluxJust() { - return Flux.range(0, 1); + ImmutableSet> testFluxJust() { + return ImmutableSet.of(Flux.range(0, 1), Mono.just(1).repeat().take(1)); } ImmutableSet> testMonoIdentity() { @@ -585,10 +585,6 @@ 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 129926c06c..203a521203 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 @@ -187,8 +187,8 @@ ImmutableSet> testFluxEmpty() { Flux.empty()); } - Flux testFluxJust() { - return Flux.just(0); + ImmutableSet> testFluxJust() { + return ImmutableSet.of(Flux.just(0), Flux.just(1)); } ImmutableSet> testMonoIdentity() { @@ -574,10 +574,6 @@ 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));