SonarLint not functioning on VS Studio 2022 Enterprise

Please provide

  • Operating system: Windows 11
  • Visual Studio version: Visual Studio Enterprise 2022
  • SonarLint plugin version: 8.0.0.56719
  • Programming language you’re coding in: C#
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): Sonarcloud

And a thorough description of the problem / question:

SonarLint does not seem to work on a colleague’s Windows machine. It works for everyone else in the company except on his PC. I have installed OpenJDK 17, added JAVA_HOME and JDK_HOME variables, also utilizing the latest version of NodeJS. He has also uninstalled and reinstalled his Visual Studio, but this has not solved anything.

When I open the SonarLint Extension in VS Studio, and use Connected Mode, I had the credentials as per usual and link the Sonarcloud Project to the VS Studio Project using the bindings. Once completed, I can see that SonarLint scans the files, but no lines are drawn under the lines that have issues been reported in the Sonarcloud console. Show Error Squiggles is enabled in Visual Studio.

Here is the output log when SonarLint scans the project:

Initializing the telemetry package...
Finished initializing the telemetry package...
Initializing the daemon package...
[SLCoreHandler] Creating SLCore instance
[SLCoreHandler] Starting SLCore instance
Settings file does not exist at "C:\Users\xxxx\AppData\Roaming\SonarLint for Visual Studio\settings.json".
Default settings will be used
Current VS version:
    Visual Studio Enterprise 2022
    17.11.35312.102
    17.11.4
[NodeJSLocator] Checking environment variable SONAR_NODEJS_PATH
[NodeJsLocator] Environment variable value: C:\Program Files\nodejs\node.exe
Finished initializing the daemon package.
Connecting to '
https://sonarcloud.io/'.
[SLCORE] Can't open directory channel. Log directory fsync won't be performed.
[FileTracker] Service Provider is unavailable
[SLCoreAnalyzer] Analyzing C:\dev\xxxxx\projects\xxxxxx\Services\FeatureRequestService.cs with id 
[SLCoreAnalyzer] Analysis  not ready for file C:\dev\xxxxxxx\projects\xxxxxxxx\Services\FeatureRequestService.cs: Configuration scope not initialized
Initializing the SonarLint package...
Finishing initializing the SonarLint package
Connected to SonarCloud '8.0.0.56719'.
Binding has changed. Open documents will be re-analysed.
Starting job: "re-analyzing 1 document(s)...". Time: 08:33:38
Finished job "re-analyzing 1 document(s)..." started at 08:33:38. Elapsed time: 297ms
[SLCoreAnalyzer] Analyzing C:\dev\xxxxxx\projects\xxxxx\Services\FeatureRequestService.cs with id 
Initializing the notifications package...
[SLCoreAnalyzer] Analysis  not ready for file C:\dev\xxxxxxxx\projects\xxxxxxxxx\Services\FeatureRequestService.cs: Configuration scope not initialized
Loading notifications settings...
Connected: checking for notifications
Finished initializing the notifications package
[ConnectedMode] Initializing package...
[ConnectedMode] Package initialized
ERROR: Could not find factory for 'IGetSonarLintEventStream'.
[Suppressions] Fetching all suppressions...
[Hotspots] Fetching all hotspots...
[Taint] Initializing taint issues synchronization package...
[ConnectedMode/BranchMapping] Matching Sonar server branch: develop
[ConnectedMode/BranchMapping] Matching Sonar server branch: develop
[ConnectedMode/BranchMapping] Matching Sonar server branch: develop
[ConnectedMode/BranchMapping] Closest Sonar server branch: develop
[ConnectedMode/BranchMapping] Closest Sonar server branch: develop
[ConnectedMode/BranchMapping] Closest Sonar server branch: develop
[Hotspots] Finished fetching all hotspots
[ServerIssueStore] Raising change event...
[Suppressions] Finished fetching all suppressions
Updated analysis readiness: True
Starting job: "re-analyzing 1 document(s)...". Time: 08:33:40
Finished job "re-analyzing 1 document(s)..." started at 08:33:40. Elapsed time: 16ms
[Taint] Fetched 17 taint vulnerabilities.
[SLCoreAnalyzer] Analyzing C:\dev\xxxxxxx\projects\xxxxxxxx\Services\FeatureRequestService.cs with id 
[SLCoreAnalyzer] Finished analyzing C:\dev\xxxxxxxx\projects\xxxxxxx\Services\FeatureRequestService.cs with id 60a5c30d-4a56-46c0-a5da-e08f1a5d5396, analysis time: 0s
[SLCoreAnalyzer] Found 0 issue(s) for C:\dev\xxxxxxx\projects\xxxxxxx\Services\FeatureRequestService.cs
[SLCoreAnalyzer] Finished analyzing C:\dev\xxxxxxxx\projects\xxxxxxx\Services\FeatureRequestService.cs with id 60a5c30d-4a56-46c0-a5da-e08f1a5d5396, analysis time: 0s
[SLCoreAnalyzer] Found 0 issue(s) for C:\dev\xxxxxxx\projects\xxxxxxxxx\Services\FeatureRequestService.cs
Initializing security package...
Finished initializing security package.
[Taint] Finished initializing taint issues synchronization package.

Hi,

The current version of SonarLint for Visual Studio is 8.3.0. Could you upgrade and see if this is still replicable?

 
Thx,
Ann

Upgraded to version 8.4.0.10426, the same issue persists. Logs are the same. I am wondering if it is not related to this line:

ERROR: Could not find factory for ‘IGetSonarLintEventStream’.

1 Like

Hi,

Thanks for checking. I’m going to flag this for the team.

 
Ann

1 Like

We have seen this problem with multiple users on our team. Seems to be more of an issue if the file is on the root level of the project, not in a subfolder. The file here is quite simple and we see it on different files.

[SLCoreAnalyzer] Analyzing C:\SourceCode\PP-AssemblyPlanner\Proplanner\ChartDoubleClickEventHandler.cs with id 
[SLCORE] Internal error: java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.getParent()" because "file" is null
[SLCoreAnalyzer] Failed to analyze C:\SourceCode\PP-AssemblyPlanner\Proplanner\ChartDoubleClickEventHandler.cs with id : StreamJsonRpc.RemoteInvocationException: Internal error.
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__154`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarLint.VisualStudio.SLCore.Analysis.SLCoreAnalyzer.<ExecuteAnalysisInternalAsync>d__7.MoveNext()
1 Like

Hello MichaelduPreez, Juan Foegen

Thank you for using SonarLint and sharing your feedback.

Juan Foegen: After reviewing the details, the two issues you mentioned do not appear to be exactly related. To help us provide the best attention to both, I kindly ask you to open a separate community thread for it.

MichaelduPreez: It’s still unclear where the issue originates, and I’ll need some additional information to investigate further. Could you please provide the verbose logs by following the instructions?

Best regards,
Vasileios

SonarLint_20241007.log (97.3 KB)

Not sure if these log files will show anything as well

SonarLintLog.txt (119.1 KB)

Added log

did you manage to find out any information with the supplied log files perhaps?

Hello MichaelduPreez,

Thank you for sharing the logs. From what I can see, everything appears to be configured and instantiated correctly. The analysis of your C# file also completed without errors, aside from the ERROR: Could not find factory for ‘IGetSonarLintEventStream’. This particular error is not critical and shouldn’t affect functionality.

However, I did notice that the verbose logs you provided seem to be missing some lines (for example, [ThreadId 63] Initializing the daemon package...). Based on the attached logs, I haven’t identified any specific issues, but it would be helpful if you could share the complete verbose logs, including the SonarLint initialization sequence. Depending on your Visual Studio settings, certain log lines may have been trimmed.

Could you also clarify what you meant by “no lines are drawn under the lines that have issues reported in the SonarCloud console”? On SonarCloud, are the reported findings categorized as issues, security hotspots, or taint vulnerabilities?

As a quick sanity check, could you please add a // TODO: comment to your code and save the file? This should trigger an issue in SonarLint, which you should be able to see in Visual Studio’s Error List. Please note that when starting Visual Studio, it may take a few minutes for SonarLint to fully initialize and begin its analysis.

I appreciate your patience and understanding!

Hi Vasileios,

I have done the // TODO: already and no line squiggles are added inside of Visual Studio. It is working on all the colleagues machines though. And with regards to categories, ALL category issues are not appearing on this persons machines (issues, security hotspots, or taint vulnerabilities). The only squiggles that are appearing seem to be the built in IntelliSense from Visual Studio for C# code.

Essentially what is happening with said Employees PC, is that he has no idea what is happening with his code with SonarLint on his PC. Only when he creates a PullRequest and has a Validation build running, does he see that Sonarcloud reports issues for him such as Issues, Vulnerabilities, Duplicate code, etc. This is not ideal as he could’ve sorted the issues before making the pull request.

With that said, I will try and get a full log for you in the morning from said employees PC as requested.

Thank you for the prompt reply!

Could you also please check if that happens on a specific solution or if any solution is affected? If you haven’t already tried, maybe you could create a new solution with just a TODO comment. This could narrow down our investigation.

Have a great day!

SonarLint.txt (27.9 KB)

Try this one. I hope it is sufficient.

I deleted some of the Cache files and have SonarLint create new cache files, it didn’t seem to resolve it.

We have been experiencing the same/a similar issue to this. SonarLint fails to analyse JavaScript files when configured in connected mode, but has no issues in standalone with no settings changed. Surprisingly it works fine for C#, just not JavaScript.

This is with SonarLint VS 8.3.0.10161 as we are currently stuck on SonarQube 8.9.1.4454 so can’t use any later versions of SonarLint. I did also try with 7.8 and 8.1 with the same result.

I’ve attached the log to see if any of it is useful.

sonarlint_log.txt (29.2 KB)

Hi @wrich,

Sorry, but we’re just not going to be able to help you with EOL versions.

 
Ann

Hi Team, I finally managed to solve this issue. It seems like the issue lies with the NodeJS installation.

When installing NodeJS, there is a checkbox to Install Additional Tools (Visual studio add-ons, python, npx, etc.) which is not selected by default. If this checkbox is not selected, then I find that the SonarQube Lint does not work as expected. But if this checkbox is selected, then it does work.

I came across the issue again when setting up a Brand new PC, where the Sonarqube Lint wasn’t working again. And after sitting around I reinstalled everything again but then noticed this checkbox which sorted everything out

2 Likes