"Unused local variables should be removed" is broken


Thanks for your report. I was able to reproduce this issue when analyzing the single file. However, when I analyze the whole project, this issue disappears. This means that the problem is that SonarLint wasn’t able to locate the .class files of your project correctly. And without semantics, the analyzer is not able to resolve variables, types, and bindings correctly, which leads to the incorrect result.

For now, I can suggest you build your project with Gradle (either from the IDE or command line), make sure that the build folder is generated, and then run the analysis. The issue should disappear.

Meanwhile, I created a ticket to not report FPs in case of incomplete semantics:


Kind regards,

1 Like