How to work with large code files, with too many issues, if VS2019 stops reacting on Sonar Lints work

Must-share information (formatted with Markdown):

  • I’m using Visual Studio 2019 16.11 and the Sonar Lint extension 4.37.0.34839
  • The code base is very old and so many issues are found while scanning. There are files, that slow down so much, that it is impossible to work on them, since Sonar Lint periodically scans those files listing hundreds of warnings and infos every few seconds. Every few seconds VS2019 stops, isn’t reacting anymore while Sonar Lint works with one of this critical files.
  • I took a look at the most often harmed rules and if those are “harmless” or won’t change anything in our way to develop, I deactivated those rules. But this didn’t really help to be able to work on those mentioned files.
  • I tried to find a possibility to exclude such problematic files temporarily, but had no success

So - what to do?

Yes, work on those files, to change them to be really better in the code quality.
But my job is not this one, but to develop functionality and I can’t, if VS2019 stops reacting periodically.

Hi @MartinLemburgSISW - welcome to the community.

A couple of questions:

  • Which language(s) are you using?
  • Are you using connected mode or standalone mode?

If the languages that are causing you problems are C# or VB.NET then the analysis is controlled by Visual Studio, and you can use the normal VS mechanisms to limit what is analysed (e.g. changing the Background analysis scope in Tools, Options).

Thanks for pointing out missing information!

The language we use is C++ and I thought we would use Sonar Lint in the standalone mode.
I simply installed Sonar LInt and started to use it.

Could you try upgrading to the latest version (v4.38) please? I wouldn’t necessarily expect it to make much difference, but we did make a few changes to move some processing off the UI thread.

Unfortunately, there isn’t a way to exclude individual files from analysis.

FYI the actual analysis is done by a separate process, so the work in VS is limited to collecting the configuration information necessary to trigger the analysis, and rendering the results. Also, a file is only analysed when it is opened or saved.

A couple more questions to help with troubleshooting the root cause:

  1. are you seeing the delays only when opening/saving, or at other times too e.g. when changing tabs?

  2. how many LOCs do the “problem” files have, and how many issues are reported?

Thanks.

Thanks Duncan for your response,

I hoped the installed extension would update automatically. But yes, I’ll update Sonar Lint.

I hoped there would be a way to exclude individual files, since our code base has for sure after 30y working on/with it more than one file, which exceeds the “limits”.

To your question:

  1. I experience the delays while working, while editing, not while opening or saving.
    Reading the docs I expected, too to have such delays only while opening or saving, but … no … while editing. And having not saved, only editing the file, regulary in the status bar was to read something like “Sonar Lint finished scanning” (or similar).
  2. The specific file had, after excluding several rules, I would not discuss with my team, ca 400 warnings and 400 information messages in ca. 11530 LOC.

All the best

Me again Duncan,

Since there is no way to exclude individual files, I will need to deactivate the extension and activate it if I want to use it.
Since our code base is such old any static code checker applying modern rules will list tons of issues.
No matter if we have the time to work on the issues or just do care for the new code to be “compliant”.

So - isn’t there a way to give Sonar Lint in the standalone mode for C++ this desired exclusion feature?

Best regards

A last reply.

I know about the sub process, it crashes regularly while working at the specific file:

2021-09-28 22_16_57-subprocess.exe

Auto-update: Visual Studio should auto-update the extension if you have configured it to do so. It isn’t something that extension authors have any control over.

Could you create a post in New features - SonarSource Community describing how you’d like the feature to work? Thanks.

Subprocess crash: so the process only crashes on the “old” files, and those are the only files on which you see VS freezing?

I’ll ask one of my CFamily colleagues to jump in at this point as we definitely want to troubleshoot the bug that’s causing the subprocess to crash.

1 Like

Hi Duncan,

I’ll create a new feature posting.

And yes, the “sub process” crashes on those “complex” old files!
But I haven’t tested it using the whole code base!

And yes, the UI freezes seemingly right before the “sub process” crashes, but not always I get the message, that a “sub process” crashed!

I tried to debug the crashed “sub process”, but it seems impossible.

Best regards

Hello @MartinLemburgSISW,

Can you generate reproducer files for the file that leads to the crash?
This might help us investigate the reason behind the crash.
Does the crash happen consistently when analyzing a specific file?

Thanks,

Hello @Abbas_Sabra,

I’ll try to generate reproducer files!

On some files, on the one I started this topic, the crash happens consistently.

Best regards

Sorry, to have such a delay in responding.

I needed to disable the extension Sonar Lint to continue working fluently.

Now I enabled Sonar Lint and produced the reproducer file, but …
… the file contains intellectual property of my employer and I’m sure, that I don’t have the allowance to send this file to you.

Does the crashing “sub process” leave some traces, some crash information, some bread crumbs to collect somewhere in its environment or in the system (OS), like in the event viewer?

Best regards

Martin

Hello @MartinLemburgSISW,

Unfortunetly, no… It contains all these details to be able to reproduce the same problem you are facing on our side. Will you be able to share it privately?

Thanks,