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 !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.