Reputation: 4296
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:
@Getter
annotation on class level and I got the same warning.I have tested with the following versions:
Upvotes: 7
Views: 2202
Reputation: 2850
You're right and I've created the following Jira ticket https://jira.sonarsource.com/browse/SONARJAVA-1924. Thanks for your feedback !
Upvotes: 5