Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rickie committed Sep 10, 2022
1 parent dcd5811 commit 0016ccf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.function.Function;
import java.util.function.Supplier;
import reactor.core.publisher.Flux;
import tech.picnic.errorprone.bugpatterns.util.NestedTypesUtils;
import tech.picnic.errorprone.bugpatterns.util.NestedTypes;

/**
* A {@link BugChecker} which flags usages of {@link Flux#flatMap(Function)} and {@link
Expand Down Expand Up @@ -72,7 +72,7 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState
Iterables.getOnlyElement(tree.getArguments()), ", " + MAX_CONCURRENCY_ARG_NAME)
.build();

if (NestedTypesUtils.isSameTypeNested(FLUX, tree, state)) {
if (NestedTypes.isSameTypeNested(FLUX, tree, state)) {
return buildDescription(tree)
.addFix(maxConcurrencyFix)
.setMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.sun.source.tree.MethodInvocationTree;
import com.sun.tools.javac.code.Type;
import java.util.Optional;
import tech.picnic.errorprone.bugpatterns.util.NestedTypesUtils;
import tech.picnic.errorprone.bugpatterns.util.NestedTypes;

/** A {@link BugChecker} which flags nesting of {@link Optional Optionals}. */
@AutoService(BugChecker.class)
Expand All @@ -31,7 +31,7 @@ public final class NestedOptionals extends BugChecker implements MethodInvocatio

@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
return NestedTypesUtils.isSameTypeNested(OPTIONAL, tree, state)
return NestedTypes.isSameTypeNested(OPTIONAL, tree, state)
? describeMatch(tree)
: Description.NO_MATCH;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.sun.tools.javac.util.List;

/** Utility class that can be used to identify nesting of the same type. */
public final class NestedTypesUtils {
private NestedTypesUtils() {}
public final class NestedTypes {
private NestedTypes() {}

/**
* Checks nesting of the same type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ void identification() {
" // BUG: Diagnostic contains:",
" Flux.just(1).<String>flatMapSequential(i -> Flux.just(String.valueOf(i)));",
" // BUG: Diagnostic contains:",
" Flux.just(\"test_1\", \"test\").groupBy(String::length).flatMap(Flux::just);",
" Flux.just(1, 2).groupBy(i -> i).flatMap(Flux::just);",
" // BUG: Diagnostic contains:",
" Flux.just(\"test_1\", \"test\").groupBy(String::length).flatMapSequential(Flux::just);",
" Flux.just(1, 2).groupBy(i -> i).flatMapSequential(Flux::just);",
"",
" Mono.just(1).flatMap(Mono::just);",
" Flux.just(1).concatMap(Flux::just);",
Expand Down Expand Up @@ -80,8 +80,8 @@ void replacementFirstSuggestedFix() {
" void m() {",
" Flux.just(1).flatMap(Flux::just);",
" Flux.just(1).flatMapSequential(Flux::just);",
" Flux.just(\"test_1\", \"test\").groupBy(String::length).flatMap(Flux::just);",
" Flux.just(\"test_1\", \"test\").groupBy(String::length).flatMapSequential(Flux::just);",
" Flux.just(1, 2).groupBy(i -> i).flatMap(Flux::just);",
" Flux.just(1, 2).groupBy(i -> i).flatMapSequential(Flux::just);",
" }",
"}")
.addOutputLines(
Expand All @@ -94,10 +94,8 @@ void replacementFirstSuggestedFix() {
" void m() {",
" Flux.just(1).concatMap(Flux::just);",
" Flux.just(1).concatMap(Flux::just);",
" Flux.just(\"test_1\", \"test\").groupBy(String::length).flatMap(Flux::just, MAX_CONCURRENCY);",
" Flux.just(\"test_1\", \"test\")",
" .groupBy(String::length)",
" .flatMapSequential(Flux::just, MAX_CONCURRENCY);",
" Flux.just(1, 2).groupBy(i -> i).flatMap(Flux::just, MAX_CONCURRENCY);",
" Flux.just(1, 2).groupBy(i -> i).flatMapSequential(Flux::just, MAX_CONCURRENCY);",
" }",
"}")
.doTest();
Expand Down

0 comments on commit 0016ccf

Please sign in to comment.