Josef Reichardt
Josef Reichardt

Reputation: 4296

SonarQube false positive squid:S1450 for @Getter (lombok) annotated fields

I think I have found a false positive while using the @Getter annotation from Project Lombok.

In the following example class I got the warning "Private fields only used as local variables in methods should become local variables" (squid:S1450).

public class Example {

    @Getter
    private String exampleField; // <-- squid:S1450

    public Example(final String value) {
        setExampleField(value);
    }

    private void setExampleField(final String exampleField) {
        this.exampleField = exampleField;
    }

}

Can someone confirm this? Is it a bug in the SonarQube rule or is there something wrong with my class or with my understanding of this rule or the @Getter annotation?

Just for the sake of completeness:

I have tested with the following versions:

Upvotes: 7

Views: 2202

Answers (1)

You're right and I've created the following Jira ticket https://jira.sonarsource.com/browse/SONARJAVA-1924. Thanks for your feedback !

Upvotes: 5

Related Questions