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

List getter setter check should ignore private getter, setter and constructor #439

Closed
Luro02 opened this issue Feb 15, 2024 · 0 comments · Fixed by #503
Closed

List getter setter check should ignore private getter, setter and constructor #439

Luro02 opened this issue Feb 15, 2024 · 0 comments · Fixed by #503
Labels
bug Something isn't working false-positive A lint triggers on something that is correct. unresolved Some decisions have not been made yet or it is not obvious what should be detected.

Comments

@Luro02
Copy link
Collaborator

Luro02 commented Feb 15, 2024

Summary

If they are private, it is not essential to make a copy. Should this be detected? Maybe make an annotation without subtracting points?

Lint Name

LIST_NOT_COPIED_IN_GETTER

Reproducer

import java.util.List;

public class A {
    private final List<String> list;

    public A() {
        this(List.of("a", "b", "c"));
    }

    private A(List<String> list) {
        this.list = list; //# ok
    }
    
    private void setList(List<String> list) {
        this.list = list; //# ok
    }
    
    private List<String> getList() {
        return this.list; //# ok
    }
}
@Luro02 Luro02 added bug Something isn't working false-positive A lint triggers on something that is correct. unresolved Some decisions have not been made yet or it is not obvious what should be detected. labels Feb 15, 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. unresolved Some decisions have not been made yet or it is not obvious what should be detected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant