A stream is created only to call forEach, which the collection has itself
What it finds
items.stream().forEach(action) builds a stream pipeline for what items.forEach(action) does directly, and may visit the elements in another order.
Reported is forEach called directly on stream() without arguments.
From the rule's source, stream_for_each.rs.
import java.util.List; class Print { void print(List<String> items) { items.stream().forEach(System.out::println);tx0 reports: without a stream items.forEach(System.out::println); }} 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:stream-for-each" = "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:stream-for-each] reason="..."tx0 explain tx0/java:stream-for-each shows the same in the terminal. Found a false positive? Report it.