Why is this an issue?

Passing an empty finisher to Gatherer.of or to Gatherer.ofSequential provides no additional value and removing the finisher clearly communicates that no finisher is applied.

How to fix it

Call the overload of Gatherer.of or Gatherer.ofSequential that does not take a finisher.

Code examples

Noncompliant code example

Gatherer<Integer, AtomicInteger, Integer> gatherer = Gatherer.ofSequential(
  () -> new AtomicInteger(-1),
  (state, number, downstream) -> {
    if (state.get() < 0) {
      state.set(number);
      return true;
    }
    return downstream.push(number - state.get());
  },
  Gatherer.defaultFinisher()); // Noncompliant: useless finisher

Compliant solution

Gatherer<Integer, AtomicInteger, Integer> gatherer = Gatherer.ofSequential(
  () -> new AtomicInteger(-1),
  (state, number, downstream) -> {
    if (state.get() < 0) {
      state.set(number);
      return true;
    }
    return downstream.push(number - state.get());
  }); // Compliant

Resources