Sonarlint never finds a C# issue in Rider

Hi! As we were suggested over the recent SonarLint C# analysis in Rider announcement, I give you feedback about a problem I’m facing with.

  • Using Sonarlint version 5.1 recently launched, which works now for Rider. Tried both Rider 2021.1.3 and 2021.1.4.
  • Just after install SonarLint on Rider 2021.1.3 or 2021.1.4, using default options. Hitting Analyze with Sonarlint button when it says “No analysis done on the current opened file” ends with “No issues found in the current opened file” a few moments later. Then, as well as you hit that button, after a flashing instant it says the same thing — you can see how the stop button turns to red at the same time play and settings icons turn grey, but just for those few moments —.
  • Hit such a button whenever you want. Tried waiting for Rider to load completely, with/without Unity opened — just in case —, hitting the button just as it’s available after reload, hitting after “Clear SonarLint Issues”, trying different files, different projects, different PCs with 2021.1.3 as well, and so forth.
  • I have not a clue how to make it work. I have also tried a clean SonarLint reinstalling — deleting SonarLint plugin, deleting any other Sonar-related plugin, installing SonarLint again. The same environment is working on a different PC with Rider 2021.1 (Build #RD-211.6693.105).
    I think some additional valuable info is about “This file is not automatically analyzed” warning appearing at the bottom of SonarLint Current file tab, despite it’s enabled at SonarLint options. Hover hint says about check SonarLint log but there is not any useful information there, just “Server started on…, Creating container, Analysing, Found 0 issues, Analysing, Found 0 issues…”. Rider is not showing this same warning just in the working project, with such Rider 2021.1 version, aforementioned.

Hi @RGV

Thanks for trying SonarLint on Rider. What would be really helpful is to collect verbose logs. Please check the two options in the SonarLint log panel:

Then can you close and reopen the solution, and try to analyze a single file where you expect at least one issue. It should produce a lot of logs, so please store that in a file, and share it with us. If you are concerned about privacy, you can send them to me directly.

Would be great if you could do the same on both environments (one that reports issues, and the one not working) so that we could compare.

Other information that could be useful to compare your different environments:

  • operating system (Windows/Linux/Mac)
  • version of dotnet cli configured in the Rider settings

Of course, here you have.

It’s on Windows 10 Pro, both updated frequently.
One of those not working has a reference to the folder where .NET Core SDK 3.1.411 lives.
image
The working one has no reference in .NETCore CLI, as hasn’t other of those not working.

About the logs, they are so so different.
The working one throws a long log, full of Omnisharp debugs.
Any not working PC shows a scarce log, wherein the only OmniSharp reference says “‘OmniSharp’ skipped because there is no related file in current project”.

PS Maybe the main log line which makes the difference is “0 files indexed” in those not working, just before the OmniSharp missing warning, whereas the working one says “1 file indexed” before “Execute Sensor: OmniSharp” and then the whole analysis starts by Omnisharp.

I can send you both of them as well as plenty more info if you need it. :slight_smile:

Ok we found a weird workaround. Problem is definitely on the indexing side. We tried to force indexing process. Here is how: having a not-indexed file, anything but a C#, right click in Rider’s Explorer Window over that file, then Tools, then Start Index.
After that, any C# file is properly analyzed by SonarLint, despite the first one takes a few seconds — I guess because it’s running the whole analysis on the background.

Thanks for the investigation. I’m still interested by the non working case logs, or by a way to reproduce. How do you end up having files not indexed by Rider? Is it an option somewhere?

It is expected that the first analysis takes longer, because in the background, Omnisharp will load the entire project only when the first file analysis is triggered.

1 Like

We don’t have a clue about how some people in the team have ended with, supposedly, not-indexed files. I mean, Rider says at the beginning of the execution it’s indexing files, as always have said. I have searched about it but I can’t figure out what nor why it’s happening.
I didn’t say but, of course, restarting Rider makes the problem arises again until you use the aforementioned “Start index” option in Tools over any non-C# file.

I could attach you any useful file to you: :smiley:

2 posts were split to a new topic: No issues reported in Rider: Filepath was not resolved

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.