Sonarlint does not show all findings

Please provide

  • Operating system: Windows 10
  • SonarLint plugin version: v4.11.1
  • Programming language you’re coding in: C++
  • Is connected mode used: Yes
    • Connected to SonarCloud or SonarQube (and which version): 10.7

I am reviewing some of our code and assisting other developers and recently we have started seeing Sonarlint not reporting all issues. We see e.g. cpp:S3230 not detected by Sonarlint. Others, such as cpp:S110, seem to be found correctly.

I have verified my connected mode is working and set to focus on overall code.
Other developers with similar setups have reported the same issue.

Hi @kkroier,

The analysis performed when using SonarLint in the IDE focuses on issues related to the code present in the currently viewed file. This design leads to quicker feedback for the issues and a more focused experience, where issues not related to edited files are not raised.

As a consequence of the above, the issues for which analysis requires information from multiple files, e.g., declaration of the class in headers and definition of constructor in body, are not visible in SonarLint and are raised only for full project analysis. This limitation can affect both rules that you have mentioned.

1 Like

Hi Tomasz.
Thanks for the answer. I understand the reason to limit the scope of analysis but for things like this I would prefer a small addition to analysis time instead to have the class analyzed. I assume most time is spent in the code file and so adding the header would be a minor addition.

Best regards
Kristian

Hi @kkroier,

The reason for this limit is not a question of performance, but it is more related to the way we interact with the IDE. The IDE is interested in knowing what issues we have in the current file, and so we filter out issues in other files.

For the rule S3230:

  • When the header is active in the IDE, we analyze the header only, but we miss data from the .cpp file to reach any conclusion
  • When the .cpp file is active in the IDE, we analyze it (with its included headers), and we can detect the issue, but since the issue is in the header, it is filtered out.

Even if we did not filter out the issue in the second case, switching back to the header in the IDE would trigger a new analysis of the header only, and such an analysis would not contain the issue.

1 Like

Hi Loïc.
Thanks for the explanation. It makes sense although I would still like to see it highlighted in the code file of the other when it is open. I just came across “Inherited functions should not be hidden” (cpp:S1242) which seems to analyze across several files as well. I know the rules is different but as mentioned a warning in the code file would help the developers a lot until initializing immediately gets worked into their workflow.

Kristian