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

[java] ImmutableField - false positive with Lombok @Setter #4254

Closed
zman0900 opened this issue Dec 6, 2022 · 0 comments · Fixed by #4474
Closed

[java] ImmutableField - false positive with Lombok @Setter #4254

zman0900 opened this issue Dec 6, 2022 · 0 comments · Fixed by #4474
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@zman0900
Copy link

zman0900 commented Dec 6, 2022

Rule: ImmutableField

Given a simple class like:

import lombok.Setter;

public class Junk {
    @Setter
    private String value = "abc";

    public String something() {
        return "blah" + value;
    }
}

PMD 6.52.0 will report "Private field 'value' could be made final; it is only initialized in the declaration or constructor." This is a false positive because there is a generated setValue(String) method that can modify value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants