I have a Java project running in Java 17 version. I have pushed my code to the organization repository where SonarQube
is running. In that repository, I am getting issues/bugs for all the Java Streams List
that I have used in my project. Even for the simple ones.
Can someone please inform me why am I getting the issue for following Java Streams?
1. return input.stream().filter(Objects::nonNull).toList();
2. return input.stream().map(String::toLowerCase).toList();
3. return input.stream().filter(Objects::nonNull).map(i -> DOMAIN + "/" + i).toList();
For all the above mentioned Java Streams I am getting the following issue:
Refactor the code so this stream pipeline is used.
I tried to use the .collect(Collectors.toList());
instead of .toList();
, if I do that then my Intellij/SonarLint
shows that I need to use the .toList();
. So I am bit confused.
Can someone please tell me what's wrong with these Java Streams? I do not have any issue with this?
Posting the answer as it can be helpful to someone in the future:
This was happening because the SonarQube was using the old version. I updated the SonarQube and this error vanished.
The issue was happening in some 6.3.x version I updated it to 9.x version and everything is solved now.