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.
Call the overload of Gatherer.of or Gatherer.ofSequential that does not take a finisher.
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
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