java:S6204 does not recognize Collections.shuffle as a mutator

var myMutableList = blah.stream()
  .collect(Collectors.toList());
Collections.shuffle(myMutableList);

Sonar complains that I should use toList() instead, but shuffle requires that the list be mutable.

SonarSource 7.1.1.54565
SonarQube 9.6.0.59041
Java 17.0.4

Hey there.

Thanks for the feedback!

Please take a look at this thread:

We’re missing some important information (like what product(s) you’re using, and which version if relevant).

SonarLint 7.1.1.54565
SonarQube 9.6.0.59041
Java 17.0.4

Hello @lbenedetto,

Thanks for your message and sorry for such a late reply. I was able to reproduce your issue and I confirm it’s a False-positive.

Here is the ticket to fix it:

https://sonarsource.atlassian.net/browse/SONARJAVA-4372

Regards,
Margarita

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.