Error 'unused local variables should be removed' issue in consumer interface

  • version:SonarQube :sonarqube: 8.1.31237

I used the foreach method of list,I defined a variable in it and used it.But sonarqube analyzed it as an issue -'unused local variables should be removed '.

After that, I changed the code to an enhanced loop, and the issue didn’t appear,

I didn’t find this problem when I used the previous version.

And I think it’s just a sonarqube issue, not a sonarlint issue.

In my project, I found that it only appears in the consumer interface, while other FunctionalInterface did not.


#bug:fault

Hello @muii, thanks for the feedback.

Indeed, it looks like a wrong behavior of the rule, it seems to be related to this problem, and I’m glad to say that we tackled it two days ago.

You should not face this issue anymore with (soon to be released) SonarJava 6.1.

Hope this helps,
Quentin