- Operating system: Ubuntu 22.04LTS
- IDE name and flavor/env: IntelliJ IDEA version 2022.2.3
- SonarLint version: 7.1.1.54565
Consider the following snippet,
public class PrivateFieldWrittenButNotRead {
private int x;
public PrivateFieldWrittenButNotRead(int x, int y) {
this.x = x + y;
}
}
Field x is marked as unused as it violates S1068 and SonarLint also has a quickfix for it. However, if the quickfix is accepted, compilation error is introduced because of the statement inside the constructor.
A better fix would also be to remove all writes to the field.