Feuermagier / autograder

Automatic grading of student's Java code
MIT License
13 stars 7 forks source link

addAll suggestion when converting primitive array to List #548

Closed Fenmore closed 6 days ago

Fenmore commented 1 month ago

Summary

When converting a primitive array into a List of its wrapper type, boxing has to be done explicitly. Therefore the conversion with Arrays.asList(T...) cannot be used in this case but it wrongfully suggested in order to use Collection#addAll instead of single add by looping through the array.

Lint Name

COMMON_REIMPLEMENTATION_ADD_ALL

Reproducer

String origin;
List<Character> target = new ArrayList<>();
for (char single : origin.toCharArray()) {
    target.add(single);
}