I believe the warning in the following code should not be raised, because Collections.emptyList()
is immutable:
import java.util.Collections;
import java.util.List;
class S2384 {
private final List<String> myList = Collections.emptyList();
public List<String> getMyList() {
return myList; // SonarLint: Return a copy of "myList".
}
}
This warning is reported by SonarLint for IntelliJ 6.3.1.40498