rspec/rules/S3706/java/rule.adoc

38 lines
660 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
There's no need to invoke ``++stream()++`` on a ``++Collection++`` before a ``++forEach++`` call because each ``++Collection++`` has its own ``++forEach++`` method.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
identifiers.stream().forEach(System.out::println); // Noncompliant
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
identifiers.forEach(System.out::println); // Noncompliant
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Drop this use of "stream()"; it is unneeded.
=== Highlighting
``++stream()++``
endif::env-github,rspecator-view[]