Unresolved variable in anonymous class (S1854: Remove this useless assignment to local variable "!unknown!")

Finally coming back at this, we are currently putting a lot of effort to avoid reporting issues when things are unresolved.

The first observation is that I was still unable to reproduce the issue… Still, during the investigation, I manage to identify problems in the logic to determine what is unresolved or not (see SONARJAVA-4126).
It should improve things, but I’m unsure this will solve your specific problem.

This report is now quite old, a lot of changes happened since. I encourage anyone facing a similar issue to try the latest version of SonarQube/SonarCloud and to create a new topic with as many information as possible to help us identify the cause (versions, scanner used, …)

In addition, let me remind you that unresolved variables are not supposed to happen, and are a sign that something is going wrong during the analysis. Here are the typical reasons:

  • For SonarLint, you should probably build completely your project and try again.

  • For SonarQube/SonarCloud, you should have a look at the logs of the analysis for something like:

Unresolved imports/types have been detected during analysis.

It should help you to understand what dependencies/libraries are missing in the configuration.