Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addAll suggestion when converting primitive array to List #548

Closed
Fenmore opened this issue Jun 7, 2024 · 0 comments · Fixed by #556
Closed

addAll suggestion when converting primitive array to List #548

Fenmore opened this issue Jun 7, 2024 · 0 comments · Fixed by #556
Labels
bug Something isn't working false-positive A lint triggers on something that is correct.

Comments

@Fenmore
Copy link
Contributor

Fenmore commented Jun 7, 2024

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);
}
@Fenmore Fenmore added bug Something isn't working false-positive A lint triggers on something that is correct. labels Jun 7, 2024
@Luro02 Luro02 closed this as completed in ff2f1ef Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working false-positive A lint triggers on something that is correct.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant