mirror of
https://github.com/jlengrand/error-prone-support.git
synced 2026-03-10 15:49:33 +00:00
Compare commits
6 Commits
sschroever
...
v0.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36654883e5 | ||
|
|
d5372934ec | ||
|
|
f810530599 | ||
|
|
6928381403 | ||
|
|
5657a48552 | ||
|
|
50aaf77a9e |
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>tech.picnic.error-prone-support</groupId>
|
||||
<artifactId>error-prone-support</artifactId>
|
||||
<version>0.1.1-SNAPSHOT</version>
|
||||
<version>0.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>error-prone-contrib</artifactId>
|
||||
@@ -128,11 +128,6 @@
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
|
||||
@@ -41,13 +41,11 @@ final class EqualityTemplates {
|
||||
// non-null.
|
||||
static final class EqualsPredicate<T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
Predicate<T> before(T v) {
|
||||
return e -> v.equals(e);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
Predicate<T> after(T v) {
|
||||
return v::equals;
|
||||
}
|
||||
|
||||
@@ -33,13 +33,11 @@ final class NullTemplates {
|
||||
/** Prefer {@link Objects#isNull(Object)} over the equivalent lambda function. */
|
||||
static final class IsNullFunction<T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
Predicate<T> before() {
|
||||
return o -> o == null;
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
Predicate<T> after() {
|
||||
return Objects::isNull;
|
||||
}
|
||||
@@ -48,13 +46,11 @@ final class NullTemplates {
|
||||
/** Prefer {@link Objects#nonNull(Object)} over the equivalent lambda function. */
|
||||
static final class NonNullFunction<T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
Predicate<T> before() {
|
||||
return o -> o != null;
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
Predicate<T> after() {
|
||||
return Objects::nonNull;
|
||||
}
|
||||
|
||||
@@ -81,13 +81,11 @@ final class OptionalTemplates {
|
||||
// generalization. If/when Refaster is extended to understand this, delete the template above.
|
||||
static final class OptionalOrElseThrowMethodReference<T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
Function<Optional<T>, T> before() {
|
||||
return Optional::get;
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@SuppressWarnings("NoFunctionalReturnType")
|
||||
Function<Optional<T>, T> after() {
|
||||
return Optional::orElseThrow;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import io.reactivex.Flowable;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.adapter.rxjava.RxJava2Adapter;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -39,12 +38,12 @@ final class RxJava2AdapterTemplates {
|
||||
*/
|
||||
static final class FlowableToFlux<T> {
|
||||
@BeforeTemplate
|
||||
Publisher<T> before(Flowable<T> flowable) {
|
||||
Flux<T> before(Flowable<T> flowable) {
|
||||
return Refaster.anyOf(
|
||||
flowable.compose(Flux::from),
|
||||
Flux.from(flowable),
|
||||
flowable.to(Flux::from),
|
||||
flowable.as(Flux::from),
|
||||
flowable.compose(RxJava2Adapter::flowableToFlux),
|
||||
RxJava2Adapter.flowableToFlux(flowable),
|
||||
flowable.to(RxJava2Adapter::flowableToFlux));
|
||||
}
|
||||
|
||||
@@ -60,12 +59,11 @@ final class RxJava2AdapterTemplates {
|
||||
*/
|
||||
static final class FluxToFlowable<T> {
|
||||
@BeforeTemplate
|
||||
Publisher<T> before(Flux<T> flux) {
|
||||
Flowable<T> before(Flux<T> flux) {
|
||||
return Refaster.anyOf(
|
||||
Flowable.fromPublisher(flux),
|
||||
flux.transform(Flowable::fromPublisher),
|
||||
flux.as(Flowable::fromPublisher),
|
||||
flux.transform(RxJava2Adapter::fluxToFlowable));
|
||||
RxJava2Adapter.fluxToFlowable(flux));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@@ -132,12 +130,11 @@ final class RxJava2AdapterTemplates {
|
||||
*/
|
||||
static final class MonoToFlowable<T> {
|
||||
@BeforeTemplate
|
||||
Publisher<T> before(Mono<T> mono) {
|
||||
Flowable<T> before(Mono<T> mono) {
|
||||
return Refaster.anyOf(
|
||||
Flowable.fromPublisher(mono),
|
||||
mono.transform(Flowable::fromPublisher),
|
||||
mono.as(Flowable::fromPublisher),
|
||||
mono.transform(RxJava2Adapter::monoToFlowable));
|
||||
RxJava2Adapter.monoToFlowable(mono));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
|
||||
@@ -1,272 +0,0 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
|
||||
import com.google.errorprone.refaster.annotation.AfterTemplate;
|
||||
import com.google.errorprone.refaster.annotation.BeforeTemplate;
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.Flowable;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Supplier;
|
||||
import org.assertj.core.util.Streams;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.adapter.rxjava.RxJava2Adapter;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/** Refaster templates which replace RxJava expressions with equivalent Reactor assertions. */
|
||||
// XXX: Document the approach and any limitations; see the `TestNGToAssertJTemplates` documentation.
|
||||
// XXX: Document that the templates use `Completable` rather than `CompletableSource`, etc.
|
||||
// XXX: Have separate files for Completable, Maybe, Single, Flowable?
|
||||
final class RxJavaToReactorTemplates {
|
||||
private RxJavaToReactorTemplates() {}
|
||||
|
||||
// XXX: Handle array and varargs cases.
|
||||
// XXX: Simplify rule with `Completable.amb(Arrays.asList(sources))`?
|
||||
static final class CompletableAmbArray {
|
||||
@BeforeTemplate
|
||||
Completable before(Completable... sources) {
|
||||
return Completable.ambArray(sources);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Completable... sources) {
|
||||
return Mono.firstWithSignal(
|
||||
Arrays.stream(sources)
|
||||
.map(RxJava2Adapter::completableToMono)
|
||||
.collect(toImmutableList()))
|
||||
.as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
static final class CompletableAmb {
|
||||
@BeforeTemplate
|
||||
Completable before(Iterable<? extends Completable> sources) {
|
||||
return Completable.amb(sources);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Iterable<? extends Completable> sources) {
|
||||
return Mono.firstWithSignal(
|
||||
Streams.stream(sources)
|
||||
.map(RxJava2Adapter::completableToMono)
|
||||
.collect(toImmutableList()))
|
||||
.as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
static final class CompletableComplete {
|
||||
@BeforeTemplate
|
||||
Completable before() {
|
||||
return Completable.complete();
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after() {
|
||||
return Mono.empty().as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Handle array and varargs cases.
|
||||
// XXX: Simplify rule with `Completable.amb(Arrays.asList(sources))`?
|
||||
static final class CompletableConcatArray {
|
||||
@BeforeTemplate
|
||||
Completable before(Completable... sources) {
|
||||
return Completable.concatArray(sources);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Completable... sources) {
|
||||
return Flux.concat(
|
||||
Arrays.stream(sources)
|
||||
.map(RxJava2Adapter::completableToMono)
|
||||
.collect(toImmutableList()))
|
||||
.then()
|
||||
.as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Simplify rule with `Completable.concat(Flux.fromIterable(sources))`?
|
||||
static final class CompletableConcatIterable {
|
||||
@BeforeTemplate
|
||||
Completable before(Iterable<? extends Completable> sources) {
|
||||
return Completable.concat(sources);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Iterable<? extends Completable> sources) {
|
||||
return Flux.concat(Flux.fromIterable(sources).map(RxJava2Adapter::completableToMono))
|
||||
.then()
|
||||
.as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Simplify rule with `Completable.concat(sources, 2)`?
|
||||
// XXX: Arguably we should, since the Reactor prefetch is `Queues.XS_BUFFER_SIZE`.
|
||||
static final class CompletableConcatPublisher {
|
||||
@BeforeTemplate
|
||||
Completable before(Publisher<? extends Completable> sources) {
|
||||
return Completable.concat(sources);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Publisher<? extends Completable> sources) {
|
||||
return Flux.concat(Flux.from(sources).map(RxJava2Adapter::completableToMono))
|
||||
.then()
|
||||
.as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
static final class CompletableConcatPublisherPrefetch {
|
||||
@BeforeTemplate
|
||||
Completable before(Publisher<? extends Completable> sources, int prefetch) {
|
||||
return Completable.concat(sources, prefetch);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Publisher<? extends Completable> sources, int prefetch) {
|
||||
return Flux.concat(Flux.from(sources).map(RxJava2Adapter::completableToMono), prefetch)
|
||||
.then()
|
||||
.as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Migrate `Completable#create(CompletableOnSubscribe)`
|
||||
|
||||
// XXX: Migrate `Completable#unsafeCreate(CompletableSource)`
|
||||
|
||||
static final class CompletableDefer {
|
||||
@BeforeTemplate
|
||||
Completable before(Callable<? extends Completable> completableSupplier) {
|
||||
return Completable.defer(completableSupplier);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Callable<? extends Completable> completableSupplier) {
|
||||
return Mono.defer(
|
||||
() ->
|
||||
RxJava2ReactorMigrationUtil.getUnchecked(completableSupplier)
|
||||
.as(RxJava2Adapter::completableToMono))
|
||||
.as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
static final class CompletableErrorDeferred {
|
||||
@BeforeTemplate
|
||||
Completable before(Callable<? extends Throwable> errorSupplier) {
|
||||
return Completable.error(errorSupplier);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Callable<? extends Throwable> errorSupplier) {
|
||||
return Mono.error(RxJava2ReactorMigrationUtil.callableAsSupplier(errorSupplier))
|
||||
.as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
static final class CompletableError {
|
||||
@BeforeTemplate
|
||||
Completable before(Throwable error) {
|
||||
return Completable.error(error);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Throwable error) {
|
||||
return Mono.error(error).as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Migrate `Completable#fromAction(Action)`
|
||||
|
||||
static final class CompletableFromCallable<T> {
|
||||
@BeforeTemplate
|
||||
Completable before(Callable<T> callable) {
|
||||
return Completable.fromCallable(callable);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(Callable<T> callable) {
|
||||
return Mono.fromSupplier(RxJava2ReactorMigrationUtil.callableAsSupplier(callable))
|
||||
.as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Also handle `Future`s that don't extend `CompletableFuture`.
|
||||
static final class CompletableFromFuture<T> {
|
||||
@BeforeTemplate
|
||||
Completable before(CompletableFuture<T> future) {
|
||||
return Completable.fromFuture(future);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Completable after(CompletableFuture<T> future) {
|
||||
return Mono.fromFuture(future).as(RxJava2Adapter::monoToCompletable);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Next up: migrate `Completable#fromMaybe(Maybe)`
|
||||
|
||||
// XXX: Move to a separate Maven module.
|
||||
static final class RxJava2ReactorMigrationUtil {
|
||||
private RxJava2ReactorMigrationUtil() {}
|
||||
|
||||
// XXX: Rename.
|
||||
// XXX: Introduce Refaster rules to drop this wrapper when possible.
|
||||
static <T> T getUnchecked(Callable<T> callable) {
|
||||
try {
|
||||
return callable.call();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Callable threw checked exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Rename.
|
||||
// XXX: Introduce Refaster rules to drop this wrapper when possible.
|
||||
static <T> Supplier<T> callableAsSupplier(Callable<T> callable) {
|
||||
return () -> {
|
||||
try {
|
||||
return callable.call();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Callable threw checked exception", e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static <T, U, R> BiFunction<? super T, ? super U, ? extends R> toJdkBiFunction(
|
||||
io.reactivex.functions.BiFunction<? super T, ? super U, ? extends R> biFunction) {
|
||||
return (t, u) -> {
|
||||
try {
|
||||
return biFunction.apply(t, u);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("BiFunction threw checked exception", e);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////// FLOWABLE - MOVE!
|
||||
|
||||
static final class FlowableCombineLatest<T1, T2, R> {
|
||||
@BeforeTemplate
|
||||
Flowable<R> before(
|
||||
Publisher<? extends T1> publisher1,
|
||||
Publisher<? extends T2> publisher2,
|
||||
io.reactivex.functions.BiFunction<? super T1, ? super T2, ? extends R> combiner) {
|
||||
return Flowable.combineLatest(publisher1, publisher2, combiner);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Flowable<R> after(
|
||||
Publisher<? extends T1> publisher1,
|
||||
Publisher<? extends T2> publisher2,
|
||||
io.reactivex.functions.BiFunction<? super T1, ? super T2, ? extends R> combiner) {
|
||||
// XXX: Generic type parameters are specified to appease IDEA; review.
|
||||
return RxJava2Adapter.fluxToFlowable(
|
||||
Flux.<T1, T2, R>combineLatest(
|
||||
publisher1, publisher2, RxJava2ReactorMigrationUtil.toJdkBiFunction(combiner)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,9 @@ import com.google.errorprone.refaster.annotation.AlsoNegation;
|
||||
import com.google.errorprone.refaster.annotation.BeforeTemplate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Refaster templates related to expressions dealing with {@link String}s. */
|
||||
@@ -106,6 +108,40 @@ final class StringTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefer direct invocation of {@link String#valueOf(Object)} over the indirection introduced by
|
||||
* {@link Objects#toString(Object)}.
|
||||
*/
|
||||
static final class StringValueOf {
|
||||
@BeforeTemplate
|
||||
String before(Object object) {
|
||||
return Objects.toString(object);
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
String after(Object object) {
|
||||
return String.valueOf(object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefer direct delegation to {@link String#valueOf(Object)} over the indirection introduced by
|
||||
* {@link Objects#toString(Object)}.
|
||||
*/
|
||||
// XXX: This template is analogous to `StringValueOf` above. Arguably this is its generalization.
|
||||
// If/when Refaster is extended to understand this, delete the template above.
|
||||
static final class StringValueOfMethodReference<T> {
|
||||
@BeforeTemplate
|
||||
Function<Object, String> before() {
|
||||
return Objects::toString;
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
Function<Object, String> after() {
|
||||
return String::valueOf;
|
||||
}
|
||||
}
|
||||
|
||||
/** Don't unnecessarily use the two-argument {@link String#substring(int, int)}. */
|
||||
static final class SubstringRemainder {
|
||||
@BeforeTemplate
|
||||
|
||||
@@ -7,8 +7,6 @@ import io.reactivex.Flowable;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import java.util.Arrays;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.adapter.rxjava.RxJava2Adapter;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -21,24 +19,20 @@ final class RxJava2AdapterTemplatesTest implements RefasterTemplateTestCase {
|
||||
Completable.complete().to(RxJava2Adapter::completableToMono));
|
||||
}
|
||||
|
||||
ImmutableSet<Publisher<Integer>> testFlowableToFlux() {
|
||||
// The `Arrays.asList` is to avoid confusing `javac`; `ImmutableSet.of` uses varargs from the
|
||||
// seventh parameter onwards.
|
||||
return ImmutableSet.copyOf(
|
||||
Arrays.asList(
|
||||
Flowable.just(1).compose(Flux::from),
|
||||
Flowable.just(2).to(Flux::from),
|
||||
Flowable.just(3).as(Flux::from),
|
||||
Flowable.just(4).compose(RxJava2Adapter::flowableToFlux),
|
||||
Flowable.just(5).<Publisher<Integer>>to(RxJava2Adapter::flowableToFlux)));
|
||||
ImmutableSet<Flux<Integer>> testFlowableToFlux() {
|
||||
return ImmutableSet.of(
|
||||
Flux.from(Flowable.just(1)),
|
||||
Flowable.just(2).to(Flux::from),
|
||||
Flowable.just(3).as(Flux::from),
|
||||
RxJava2Adapter.flowableToFlux(Flowable.just(4)),
|
||||
Flowable.just(5).to(RxJava2Adapter::flowableToFlux));
|
||||
}
|
||||
|
||||
ImmutableSet<Publisher<String>> testFluxToFlowable() {
|
||||
ImmutableSet<Flowable<String>> testFluxToFlowable() {
|
||||
return ImmutableSet.of(
|
||||
Flowable.fromPublisher(Flux.just("foo")),
|
||||
Flux.just("bar").transform(Flowable::fromPublisher),
|
||||
Flux.just("baz").as(Flowable::fromPublisher),
|
||||
Flux.just("qux").transform(RxJava2Adapter::fluxToFlowable));
|
||||
Flux.just("bar").as(Flowable::fromPublisher),
|
||||
RxJava2Adapter.fluxToFlowable(Flux.just("baz")));
|
||||
}
|
||||
|
||||
ImmutableSet<Observable<Integer>> testFluxToObservable() {
|
||||
@@ -61,12 +55,11 @@ final class RxJava2AdapterTemplatesTest implements RefasterTemplateTestCase {
|
||||
RxJava2Adapter.monoToCompletable(Mono.empty()));
|
||||
}
|
||||
|
||||
ImmutableSet<Publisher<Integer>> testMonoToFlowable() {
|
||||
ImmutableSet<Flowable<Integer>> testMonoToFlowable() {
|
||||
return ImmutableSet.of(
|
||||
Flowable.fromPublisher(Mono.just(1)),
|
||||
Mono.just(2).transform(Flowable::fromPublisher),
|
||||
Mono.just(3).as(Flowable::fromPublisher),
|
||||
Mono.just(4).transform(RxJava2Adapter::monoToFlowable));
|
||||
Mono.just(2).as(Flowable::fromPublisher),
|
||||
RxJava2Adapter.monoToFlowable(Mono.just(3)));
|
||||
}
|
||||
|
||||
Maybe<String> testMonoToMaybe() {
|
||||
|
||||
@@ -7,8 +7,6 @@ import io.reactivex.Flowable;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import java.util.Arrays;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.adapter.rxjava.RxJava2Adapter;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -21,24 +19,20 @@ final class RxJava2AdapterTemplatesTest implements RefasterTemplateTestCase {
|
||||
Completable.complete().as(RxJava2Adapter::completableToMono));
|
||||
}
|
||||
|
||||
ImmutableSet<Publisher<Integer>> testFlowableToFlux() {
|
||||
// The `Arrays.asList` is to avoid confusing `javac`; `ImmutableSet.of` uses varargs from the
|
||||
// seventh parameter onwards.
|
||||
return ImmutableSet.copyOf(
|
||||
Arrays.asList(
|
||||
Flowable.just(1).as(RxJava2Adapter::flowableToFlux),
|
||||
Flowable.just(2).as(RxJava2Adapter::flowableToFlux),
|
||||
Flowable.just(3).as(RxJava2Adapter::flowableToFlux),
|
||||
Flowable.just(4).as(RxJava2Adapter::flowableToFlux),
|
||||
Flowable.just(5).as(RxJava2Adapter::flowableToFlux)));
|
||||
ImmutableSet<Flux<Integer>> testFlowableToFlux() {
|
||||
return ImmutableSet.of(
|
||||
Flowable.just(1).as(RxJava2Adapter::flowableToFlux),
|
||||
Flowable.just(2).as(RxJava2Adapter::flowableToFlux),
|
||||
Flowable.just(3).as(RxJava2Adapter::flowableToFlux),
|
||||
Flowable.just(4).as(RxJava2Adapter::flowableToFlux),
|
||||
Flowable.just(5).as(RxJava2Adapter::flowableToFlux));
|
||||
}
|
||||
|
||||
ImmutableSet<Publisher<String>> testFluxToFlowable() {
|
||||
ImmutableSet<Flowable<String>> testFluxToFlowable() {
|
||||
return ImmutableSet.of(
|
||||
Flux.just("foo").as(RxJava2Adapter::fluxToFlowable),
|
||||
Flux.just("bar").as(RxJava2Adapter::fluxToFlowable),
|
||||
Flux.just("baz").as(RxJava2Adapter::fluxToFlowable),
|
||||
Flux.just("qux").as(RxJava2Adapter::fluxToFlowable));
|
||||
Flux.just("baz").as(RxJava2Adapter::fluxToFlowable));
|
||||
}
|
||||
|
||||
ImmutableSet<Observable<Integer>> testFluxToObservable() {
|
||||
@@ -61,12 +55,11 @@ final class RxJava2AdapterTemplatesTest implements RefasterTemplateTestCase {
|
||||
Mono.empty().as(RxJava2Adapter::monoToCompletable));
|
||||
}
|
||||
|
||||
ImmutableSet<Publisher<Integer>> testMonoToFlowable() {
|
||||
ImmutableSet<Flowable<Integer>> testMonoToFlowable() {
|
||||
return ImmutableSet.of(
|
||||
Mono.just(1).as(RxJava2Adapter::monoToFlowable),
|
||||
Mono.just(2).as(RxJava2Adapter::monoToFlowable),
|
||||
Mono.just(3).as(RxJava2Adapter::monoToFlowable),
|
||||
Mono.just(4).as(RxJava2Adapter::monoToFlowable));
|
||||
Mono.just(3).as(RxJava2Adapter::monoToFlowable));
|
||||
}
|
||||
|
||||
Maybe<String> testMonoToMaybe() {
|
||||
|
||||
@@ -10,7 +10,9 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Streams;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase;
|
||||
|
||||
@@ -18,7 +20,7 @@ final class StringTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(
|
||||
Arrays.class, Joiner.class, Stream.class, Streams.class, joining(), UTF_8);
|
||||
Arrays.class, Joiner.class, Objects.class, Stream.class, Streams.class, joining(), UTF_8);
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testStringIsEmpty() {
|
||||
@@ -59,6 +61,14 @@ final class StringTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableList.of("foo", "bar").stream().collect(joining("f")));
|
||||
}
|
||||
|
||||
String testStringValueOf() {
|
||||
return Objects.toString("foo");
|
||||
}
|
||||
|
||||
Function<Object, String> testStringValueOfMethodReference() {
|
||||
return Objects::toString;
|
||||
}
|
||||
|
||||
String testSubstringRemainder() {
|
||||
return "foo".substring(1, "foo".length());
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Streams;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase;
|
||||
|
||||
@@ -19,7 +21,7 @@ final class StringTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(
|
||||
Arrays.class, Joiner.class, Stream.class, Streams.class, joining(), UTF_8);
|
||||
Arrays.class, Joiner.class, Objects.class, Stream.class, Streams.class, joining(), UTF_8);
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testStringIsEmpty() {
|
||||
@@ -59,6 +61,14 @@ final class StringTemplatesTest implements RefasterTemplateTestCase {
|
||||
String.join("f", ImmutableList.of("foo", "bar")));
|
||||
}
|
||||
|
||||
String testStringValueOf() {
|
||||
return String.valueOf("foo");
|
||||
}
|
||||
|
||||
Function<Object, String> testStringValueOfMethodReference() {
|
||||
return String::valueOf;
|
||||
}
|
||||
|
||||
String testSubstringRemainder() {
|
||||
return "foo".substring(1);
|
||||
}
|
||||
|
||||
25
pom.xml
25
pom.xml
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>tech.picnic.error-prone-support</groupId>
|
||||
<artifactId>error-prone-support</artifactId>
|
||||
<version>0.1.1-SNAPSHOT</version>
|
||||
<version>0.2.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Picnic :: Error Prone Support</name>
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:PicnicSupermarket/error-prone-support.git</developerConnection>
|
||||
<tag>HEAD</tag>
|
||||
<tag>v0.2.0</tag>
|
||||
<url>https://github.com/PicnicSupermarket/error-prone-support</url>
|
||||
</scm>
|
||||
<issueManagement>
|
||||
@@ -147,7 +147,6 @@
|
||||
<version.error-prone-fork>v${version.error-prone-orig}-picnic-2</version.error-prone-fork>
|
||||
<version.error-prone-orig>2.14.0</version.error-prone-orig>
|
||||
<version.error-prone-slf4j>0.1.13</version.error-prone-slf4j>
|
||||
<version.findbugs-format-string>3.0.0</version.findbugs-format-string>
|
||||
<version.guava-beta-checker>1.0</version.guava-beta-checker>
|
||||
<version.jdk>11</version.jdk>
|
||||
<version.maven>3.8.6</version.maven>
|
||||
@@ -240,13 +239,6 @@
|
||||
<artifactId>auto-value-annotations</artifactId>
|
||||
<version>${version.auto-value}</version>
|
||||
</dependency>
|
||||
<!-- Specified as a workaround for
|
||||
https://github.com/mojohaus/versions-maven-plugin/issues/244. -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jFormatString</artifactId>
|
||||
<version>${version.findbugs-format-string}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
@@ -405,11 +397,6 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reactivestreams</groupId>
|
||||
<artifactId>reactive-streams</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
@@ -746,6 +733,7 @@
|
||||
<module name="VisibilityModifier" />
|
||||
</module>
|
||||
<module name="UniqueProperties" />
|
||||
<module name="io.spring.nohttp.checkstyle.check.NoHttpCheck" />
|
||||
</module>
|
||||
</checkstyleRules>
|
||||
<failOnViolation>false</failOnViolation>
|
||||
@@ -771,6 +759,11 @@
|
||||
<artifactId>checkstyle</artifactId>
|
||||
<version>10.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.spring.nohttp</groupId>
|
||||
<artifactId>nohttp-checkstyle</artifactId>
|
||||
<version>0.0.10</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -1245,7 +1238,7 @@
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-maven</artifactId>
|
||||
<version>1.9.4</version>
|
||||
<version>1.9.5</version>
|
||||
<configuration>
|
||||
<!-- Use multiple threads to speed things up. Extend
|
||||
timeouts to prevent false positives as a result of
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>tech.picnic.error-prone-support</groupId>
|
||||
<artifactId>error-prone-support</artifactId>
|
||||
<version>0.1.1-SNAPSHOT</version>
|
||||
<version>0.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>refaster-compiler</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>tech.picnic.error-prone-support</groupId>
|
||||
<artifactId>error-prone-support</artifactId>
|
||||
<version>0.1.1-SNAPSHOT</version>
|
||||
<version>0.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>refaster-runner</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>tech.picnic.error-prone-support</groupId>
|
||||
<artifactId>error-prone-support</artifactId>
|
||||
<version>0.1.1-SNAPSHOT</version>
|
||||
<version>0.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>refaster-support</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>tech.picnic.error-prone-support</groupId>
|
||||
<artifactId>error-prone-support</artifactId>
|
||||
<version>0.1.1-SNAPSHOT</version>
|
||||
<version>0.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>refaster-test-support</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user