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:
You're right and I've created the following Jira ticket https://jira.sonarsource.com/browse/SONARJAVA-1924. Thanks for your feedback !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With