Disable automatic analysis for Sonarlint in vscode

  • Operating system: wsl Ubuntu
  • IDE name and flavor/env: VSCode
  • SonarLint plugin version: v3.4.1
  • Is connected mode used: Connected to SonarQube (7.9.4)

Hello, Is this possible to turn off automatic analysis for SonarLint in vscode every time I edit a file? Right now I have a file, that have a lot of issues, and I can’t work efficiently, because after every change I make it reloads all 1000+ issues.

I saw there is an checkbox for this in other IDEs but not in vscode, I also saw that I can edit the “sonarlint.analyzerProperties” option in the settings.json, but I don’t know what to write there (Is there a list of properties or doc somewher to check it?)

Thank you!

Hi @zszluka

Before jumping too fast into the easy (but not satisfactory) solution of disabling analysis, would you like to help us investigate this performance issue?
We have made some changes in the last version of SonarLint that may explain this performance issue, but I would like to be sure.

  • What is the language of your file with 1000+ issues?
  • Why do you have some much issues? Is the file really big (how many LoC)? Is one rule particularly verbose for this file (which rule)?

Last but not least, would you be able to temporarily revert to SonarLint 3.3.3 (https://github.com/SonarSource/sonarlint-vscode/releases/download/3.3.3%2B43439/sonarlint-vscode-3.3.3.vsix) and check if there is still a performance issue when displaying the 1000+ issues.

Thanks!

Hello

Well, I think the performance issue is mostly comming from my work environment.
I have a windows10, where I have wsl2 ubuntu installed, and in that wsl I start a centos docker container, which has all the libs/headers and cmake I can use to compile the code.
These containers contains a lot of company specific libs, that’s why we use that. Now, I start the vscode in this remote container and also install sonarlint into this container. I need to do this so it can find all the header files as well. I think this is the reason for the performance issue mostly.
Also the wsl is limited to 8GB RAM and 8 virtual cores.

But to answer your other questions about the files:

Currently the 3.4.1 SonarLint version is installed and this repo contains 28K cpp code and 2.3K C code.
This repo has some huge files unfortunately, but I always open one file at a time. For just one example there is this one .cpp file, where:

first.cpp::
The number of lines is 3812
There are 1.8k code smells in it, from which:
- 904 is cpp:S994 - A variable which is not modified shall be const qualified
- 416 is cpp:S1172 - Unused function parameters should be removed
- 315 is cpp:S109 - Magic numbers should not be used

[Debug - 07:24:54.018] Downloaded issues in 53ms
[Info  - 07:25:05.786] Found 1825 issues
[Debug - 07:25:39.598] GET 200 https://sonarqube.int.net.blabla.com/api/developers/search_events?projects=blabla-project&from=2022-05-21T07%3A25%3A39%2B0000 | response time=289ms
[Debug - 07:26:39.559] GET 200 https://sonarqube.int.net.blabla.com/api/developers/search_events?projects=blabla-project&from=2022-05-21T07%3A25%3A39%2B0000 | response time=256ms

All the “Problems” are loaded and shown in the file at the second “GET 200” OK response.

second.cpp::
There is another cpp file tho, which has 15k lines (I know, I know refactor is comming…)
There are 2.7k code smells in it, from which:
- 1.6k is cpp:S994 - A variable which is not modified shall be const qualified
- 400 is cpp:S1172 - Unused function parameters should be removed
- 454 is cpp:S109 - Magic numbers should not be used


[Debug - 07:17:35.081] Downloaded issues in 226ms
[stderr] May 21, 2022 7:18:14 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
[stderr] WARNING: Unmatched cancel notification for request id 3
[stderr] May 21, 2022 7:18:19 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
[stderr] WARNING: Unmatched cancel notification for request id 4

etc, etc.. the same logs from request id 5-29

[stderr] May 21, 2022 7:19:04 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
[stderr] WARNING: Unmatched cancel notification for request id 30
[stderr] May 21, 2022 7:19:06 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
[stderr] WARNING: Unmatched cancel notification for request id 31

Then this popup window comes up and I need to repload vscode:
popup_error

I tried to make the same measurements with 3.3.3 but for some reason it only found lik 150-200 issues for both files. I don’t know what settings I had wrong.

Thank you, Zoli

Hi @zszluka

Thanks for providing all those details.

We added support of C++ analysis only in SonarLint 3.4, so I would expect no issues (your first post didn’t mentioned it was C++ code). Out of curiosity, what are the few issues you got (which rule)?

Anyway, with all the provided information, I will try to reproduce.

Hi @Julien_HENRY

You are actually right. I tried again to check if I did something wrong, and unfortunately my “extension automatic upgrade” option was tunred on in vscode, so during a “window reload” it upgraded SonarLint back to 3.4.1, but with 3.3.3 I got 0 issue. I was also probably on another branch, that’s why I got thi lower number probably.

Thank you, Zoli

I forgot to mention that I have created this ticket to improve performance when a file contains many issues:
https://jira.sonarsource.com/browse/SLLS-80

1 Like