pixee / codemodder-java

a framework for building java codemods
https://codemodder.io
GNU Affero General Public License v3.0
39 stars 6 forks source link

(Sonar) Fixed finding: "`Stream.toList()` should be used instead of `collectors`" #430

Closed pixeebot[bot] closed 2 months ago

pixeebot[bot] commented 2 months ago

Remediation

This change fixes "Stream.toList() should be used instead of collectors" (id = java:S6204) identified by Sonar.

Details

This change modernizes a stream's List creation to be driven from the simple, and more readable [Stream#toList()](https://docs.oracle.com/javase/16/docs/api/java.base/java/util/stream/Collectors.html#toList()) method.

Our changes look something like this:

- List<Integer> numbers = someStream.collect(Collectors.toList());
+ List<Integer> numbers = someStream.toList();
More reading * [https://rules.sonarsource.com/java/RSPEC-6204/](https://rules.sonarsource.com/java/RSPEC-6204/)

🧚🤖 Powered by Pixeebot

Feedback | Community | Docs | Codemod ID: sonar:java/replace-stream-collectors-to-list-s6204

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
21.4% Duplication on New Code

See analysis details on SonarCloud

ryandens commented 2 months ago

@pixeebot next

pixeebot-test[bot] commented 2 months ago

@ryandens, I don't have any suggestions at this time, but I am always learning, and I will let you know if anything comes up!

pixeebot[bot] commented 2 months ago

@ryandens, I don't have any suggestions at this time, but I am always learning, and I will let you know if anything comes up!