'Why SonarQube shows this as Noncompliant code (Refactor the code so this stream pipeline is used.)?

I have a few simple Java Streams in my code for these Streams SonarQube/Sonarlint shows as Noncompliant with the message:

Refactor the code so this stream pipeline is used.

Following are my Java Methods/Streams:

private static List<String> format(List<String> input) {
    return input.stream().map(i -> DomainName + "/path/file-" + i).toList();
}

Another Noncompliant code sample is:

private static List<String> format1(List<String> input) {
    return input.stream().map(String::toLowerCase).toList();
}

I believe these are simple Java Streams and they are working as expected for my requirement so not sure what's wrong with this. Can someone please explain what's wrong with this and how to fix the SonarQube issue?

Following is the Bug which is thrown by SonarQube: enter image description here

Another Clarification

Which of the below is good to use as per Sonar and coding perspective?

I am currently creating a List something like this:

final List<String> myList = new ArrayList<>();

Update

So SonarCube tells me to declare it as var so is it good to change it to

  1. var myList = new ArrayList<>(); or
  2. final var myList = new ArrayList<>();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source