A stream pipeline ends without a terminal operation, so none of its steps run

tx0/java:unused-streamdefaultwarningbug

What it finds

names.stream().filter(n -> n.isEmpty()).map(String::trim); as a statement does nothing: stream operations such as filter, map and peek only describe a pipeline, and nothing runs until a terminal operation such as forEach, collect or count consumes it. Here no terminal operation follows, so the lambdas never run.

Reported are expression statements that end in an intermediate operation of a chain that starts with stream(), parallelStream(), Arrays.stream, or range, rangeClosed or iterate of IntStream, LongStream or Stream.

From the rule's source, unused_stream.rs.

Example from the rule's tests
import java.util.List;import java.util.stream.IntStream; class Report {  void print(List<String> names) {    names.stream().filter(n -> n.isEmpty()).map(String::trim);tx0 reports: the stream ends in map, so nothing runs    names.stream().peek(System.out::println);tx0 reports: the stream ends in peek    IntStream.range(0, 3).map(i -> i * 2);tx0 reports: the stream ends in map    names.stream().filter(n -> n.isEmpty()).forEach(System.out::println);    names.forEach(System.out::println);  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/java:unused-stream" = "off"

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:unused-stream] reason="..."

tx0 explain tx0/java:unused-stream shows the same in the terminal. Found a false positive? Report it.