Rider not showing CodeSmells

When using SonarLint with rider, i don´t get displayed any issues.

But when pushing it to SonarCloud i get some displayed:

The Project is linked to the Qube:

Is this a known Issue using Rider/SonarLint on a Mac?

1 Like

After checking with windows (where VS will show the smells) i suppose this is a bug.

The same behaviour is seen on rider, when even not using the qube binding.

@Julien_HENRY sorry for tagging, but i cant adjust the tags anymore.

1 Like

Hello @TheRealLenon,

Welcome to the community and thanks for this feedback.

What language are you trying to analyze ? Is it C# ? Could you show us some issues that you expect to be found in SonarLint ?

Also could you send us here the output of the Log view with verbose logs activated ? See here how to enable them. This will help us understand what is happening.

Thanks
Damien

1 Like

The expected Issues should be

Parameter validation in “async”/“await” methods should be wrapped
This is shown in VS2022 & Sonarcloud.

HERE you can see the full log Rider creates.

PS: When activating all rules, i get some rules displayed but still not all.

I see a few interesting traces:

1779: Couldn’t get a connected engine to check for update: Project is not bound to a SonarQube project

Could you check if your project is properly configured ? If you trigger a manual update from the settings, it should work without errors.

1780: Omnisharp: [ERROR] Failure while loading the analyzer reference ‘Microsoft.Extensions.Logging.Generators’: Could not load file or assembly ‘Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies.

There are a few similar error, in some cases this could cause issues not to be raised.

Omnisharp: [DEBUG] Attempting to resolve ‘SonarAnalyzer.CSharp.resources, Version=8.26.0.0, Culture=en-US, PublicKeyToken=c5b62af9de6d7244’
Omnisharp: [DEBUG] FAILURE: Could not locate ‘/Users/pko/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/213.5744.299/Rider.app.plugins/sonarlint-intellij/omnisharp/osx/omnisharp/.msbuild/Current/Bin/SonarAnalyzer.CSharp.resources.dll’.
Omnisharp: [INFORMATION] Solution initialized → queue all documents for code analysis. Initial document count: 15.
Omnisharp: [DEBUG] Attempting to resolve ‘Microsoft.CodeAnalysis.NetAnalyzers, Version=6.0.5.1905, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
Omnisharp: [DEBUG] FAILURE: Could not locate ‘/Users/pko/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/213.5744.299/Rider.app.plugins/sonarlint-intellij/omnisharp/osx/omnisharp/.msbuild/Current/Bin/Microsoft.CodeAnalysis.NetAnalyzers.dll’.
Omnisharp: [DEBUG] Attempting to resolve ‘Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
Omnisharp: [DEBUG] FAILURE: Could not locate ‘/Users/pko/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/213.5744.299/Rider.app.plugins/sonarlint-intellij/omnisharp/osx/omnisharp/.msbuild/Current/Bin/Microsoft.CodeAnalysis.dll’.
Omnisharp: [ERROR] Failure while loading the analyzer reference ‘Microsoft.Extensions.Logging.Generators’: Could not load file or assembly ‘Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies.
Omnisharp: [DEBUG] Attempting to resolve ‘Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
Omnisharp: [DEBUG] FAILURE: Could not locate ‘/Users/pko/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/213.5744.299/Rider.app.plugins/sonarlint-intellij/omnisharp/osx/omnisharp/.msbuild/Current/Bin/Microsoft.CodeAnalysis.dll’.
Omnisharp: [ERROR] Failure while loading the analyzer reference ‘System.Text.Json.SourceGeneration’: Could not load file or assembly ‘Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies.
Omnisharp: [DEBUG] Attempting to resolve ‘SonarLint.OmniSharp.DotNet.Services.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c5b62af9de6d7244’
Omnisharp: [DEBUG] FAILURE: Could not locate ‘/Users/pko/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/213.5744.299/Rider.app.plugins/sonarlint-intellij/omnisharp/osx/omnisharp/.msbuild/Current/Bin/SonarLint.OmniSharp.DotNet.Services.XmlSerializers.dll’.
{“Event”:“ProjectDiagnosticStatus”,“Body”:{“Type”:“background”,“Status”:0,“ProjectFilePath”:“/Users/pko/_development/Private/KoIdentity/src/Abstraction/Abstraction.csproj”},“Seq”:605,“Type”:“event”}

This is probably the most problematic trace, as Omnisharp (that we leverage to do the analysis) is not able to find our analyzer file. Could you please tell me what appears in /Users/pko/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/213.5744.299/Rider.app.plugins/sonarlint-intellij/omnisharp/osx and subfolders ? Also what version of SonarLint are you using ?

2 Likes

Could you provide a minimal reproducer project to help in the investigation ?

Also I confirm that given the traces you sent, you are not properly connected to SonarQube.

1 Like

@Damien_Urruty I´m so sorry, i accidentally pasted the wrong Log…

Here is a full log, after i was connected: RiderSonar.log · GitHub

I´m using the latest SonarLint from the JetBrains(Rider)-Marketplace. And Rider is 2021.3.1. You can find the whole sonarlint-intellij folder here: File-Upload.net - Datei nicht gefunden

An example project can be found here: GitHub - TheRealLenon/KoIdentity You also should see the pipeline run did catch the code smells: Implementing Basic Abstraction by TheRealLenon · Pull Request #1 · TheRealLenon/KoIdentity · GitHub

1 Like

Hello @TheRealLenon,

Thank you for sharing the project with us. I’ve checked out develop branch (where the PR was merged to) and it doesn’t compile on my side due to missing namespaces. Once I add the namespaces, the issue is there:


Can you please confirm if the project compiles on your side?

Also, would you mind please trying out the following sample code:

public static class Extensions
{
    public static async Task SkipLinesAsync(this TextReader reader, int linesToSkip) // Noncompliant
    {
        if (reader == null) { throw new ArgumentNullException(nameof(reader)); }
        if (linesToSkip < 0) { throw new ArgumentOutOfRangeException(nameof(linesToSkip)); }

        for (var i = 0; i < linesToSkip; ++i)
        {
            var line = await reader.ReadLineAsync().ConfigureAwait(false);
            if (line == null) { break; }
        }
    }
    
    public class TextReader
    {
        public Task<string> ReadLineAsync()
        {
            throw new NotImplementedException();
        }
    }
}

This produces S4457 on my side when added to your project.

Please let me know.

Thanks,
Rita

1 Like

Hello @rita.g ,

The solution builds on the current DEV-Branch. The error you faced was because of the namespace Tekoding.KoIdentity.Abstraction.Store; notation which is (i suppose) a .NET6 feature.

Even after pasting the example code, i don´t get displayed any errors.

@TheRealLenon I think the problem is that you are using a language feature that is not supported by the version of Roslyn used by OmniSharp.

I was able to get analysis results by disabling ImplicitUsings in the project file and adding the required explicit references.

OmniSharp ships with an embedded version of Roslyn. In fact, it seems to have two embedded versions, but the one it uses when analysing is v3.11, which doesn’t support implicit namespaces.

I can’t think of any easy workaround. We have a ticket to upgrade SonarLint for Rider to use a newer version of OmniSharp which should fix this issue. We’re hoping to release the next version in January, but that will depend on us finishing other sprints on time.

1 Like

Hi @TheRealLenon,
We’ve released a new version of SonarLint for Rider, 6.4.0.41939, would you mind please giving it a try?

A post was split to a new topic: Omnisharp uses the wrong solution to load