Must-share information (formatted with Markdown):
- Sonarqube Enterprise Edition Version 9.9.1 (build 69595)
- Gradle Sonar Plugin 4.4.1.3373
- Java 17
- how is SonarQube deployed: Self Deployed
- We face an issue that Sonarqube doesn’t report unused fields issue(rule java:S1068) for classes where Lombok used
I have 2 classes:
First class
public class ClassWithUnusedField {
private final String result;
public ClassWithUnusedField(String result) {
this.result = result;
}
public String calculate() {
return "success" + LocalDate.now();
}
}
Second class:
@AllArgsConstructor
public class LombokClassWithUnusedField {
private final String result;
public String calculate() {
return "success" + LocalDate.now();
}
}
In result the issue will be reported only for the first class. However that’s obvious that it doesn’t used in both cases.
The rule java:S1068 in SonarQube says about exceptions:
The rule admits 3 exceptions:
- Serialization id fields
- Annotated fields
- Fields from classes with native methods
However, I don’t have any of the mentioned cases above in my code. Please help how to fix that.
Reproducer project:
unused-field-issue-reproducer.zip (3.4 KB)