Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ void compliant() {
.collect(Collectors.toList()); // Compliant, list5 needs to be mutable

list5.removeIf(s -> true);

List<String> list6 = Stream.of("B", "C", "D")
.collect(Collectors.toList()); // Compliant, list6 needs to be mutable

list6.addFirst("A");

List<String> list7 = Stream.of("A", "B", "C")
.collect(Collectors.toList()); // Compliant, list7 needs to be mutable

list7.addLast("D");

List<String> list8 = Stream.of("A", "B", "C")
.collect(Collectors.toList()); // Compliant, list8 needs to be mutable

list8.removeFirst();

List<String> list9 = Stream.of("A", "B", "C")
.collect(Collectors.toList()); // Compliant, list9 needs to be mutable

list9.removeLast();
}

void addX() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public class CollectorsToListCheck extends AbstractMethodDetection implements Ja

private static final MethodMatchers LIST_MODIFICATION_METHODS = MethodMatchers.create()
.ofSubTypes("java.util.List")
.names("add", "addAll", "remove", "removeAll", "retainAll", "replaceAll", "set", "sort", "clear", "removeIf")
.names("add", "addAll", "remove", "removeAll", "retainAll", "replaceAll", "set", "sort", "clear", "removeIf",
"addFirst", "addLast", "removeFirst", "removeLast")
.withAnyParameters()
.build();

Expand Down