A gatherer is built with an explicit default initializer, combiner or finisher, which a shorter factory method leaves out
What it finds
Gatherer.of and Gatherer.ofSequential have overloads without an initializer or a finisher. Passing Gatherer.defaultInitializer(), defaultCombiner() or defaultFinisher() to the longer ones spells out what the shorter ones do, and a gatherer whose combiner is the default is sequential, as ofSequential says.
Reported is such an argument to Gatherer.of or Gatherer.ofSequential.
From the rule's source, explicit_default_gatherer_part.rs.
import java.util.stream.Gatherer; class Gatherers { Object run() { Object a = Gatherer.ofSequential(() -> 0, (s, e, d) -> true, Gatherer.defaultFinisher());tx0 reports: shorter factory Object b = Gatherer.ofSequential((s, e, d) -> true); return a; }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:explicit-default-gatherer-part" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:explicit-default-gatherer-part] reason="..."tx0 explain tx0/java:explicit-default-gatherer-part shows the same in the terminal. Found a false positive? Report it.