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 - sonarlint-intellij.zip

An example project can be found here: GitHub - TheRealLenon/KoIdentity: KoIdentity is a lightweight Identity-Management library based on .NET. You also should see the pipeline run did catch the code smells: Implementing abstraction project 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?

We have similar issue. Omnisharp crash is as follow:

Omnisharp: [WARNING] Task attempted to find "AxImp.exe" in two locations. 1) Under the "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/4.5/" processor specific directory which is generated based on SdkToolsPath 2) The x86 specific directory under "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/4.5/" which is specified by the SDKToolsPath property. You may be able to solve the problem by doing one of the following:  1) Set the "SDKToolsPath" property to the location of the Microsoft Windows SDK.
Omnisharp: [ERROR] Task could not find "AxImp.exe" using the SdkToolsPath "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/4.5/" or the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.8\WinSDK-NetFx40Tools-x86". Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed

Interesting thing is I have solution file opened that doesn’t event include this project on which Omnisharp fails since we have some projects in source control that compile only on Windows, so we have separate solution to develop on Mac which contains only those projects that build properly on Mac.

Here is the stacktrace:

=================================================================
	Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1155ef7cd):0x1155ef7bd  f8 4d 8b f7 4d 8b e6 4d 85 f6 0f 84 46 00 00 00  .M..M..M....F...
0x1155ef7cd  49 8b 1e 49 8b 46 10 48 85 c0 0f 85 33 00 00 00  I..I.F.H....3...
0x1155ef7dd  0f b6 43 2c 48 83 f8 01 75 29 48 8b 03 48 8b 58  ..C,H...u)H..H.X
0x1155ef7ed  08 8b 43 60 48 3d a7 0b 00 00 72 17 48 8b 43 78  ..C`H=....r.H.Cx

=================================================================
	Managed Stacktrace:
=================================================================
	  at Microsoft.Build.BackEnd.TaskExecutionHost:GetItemOutputs <0x0007d>
	  at Microsoft.Build.BackEnd.TaskExecutionHost:Microsoft.Build.BackEnd.ITaskExecutionHost.GatherTaskOutputs <0x00222>
	  at Microsoft.Build.BackEnd.TaskBuilder:GatherTaskOutputs <0x004b6>
	  at <ExecuteInstantiatedTask>d__26:MoveNext <0x0203a>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x000fa>
	  at Microsoft.Build.BackEnd.TaskBuilder:ExecuteInstantiatedTask <0x0019a>
	  at <InitializeAndExecuteTask>d__24:MoveNext <0x00162>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x000f2>
	  at Microsoft.Build.BackEnd.TaskBuilder:InitializeAndExecuteTask <0x0019a>
	  at <ExecuteBucket>d__19:MoveNext <0x00832>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x000fa>
	  at Microsoft.Build.BackEnd.TaskBuilder:ExecuteBucket <0x0016a>
	  at <ExecuteTask>d__18:MoveNext <0x0068a>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x000fa>
	  at Microsoft.Build.BackEnd.TaskBuilder:ExecuteTask <0x00112>
	  at <ExecuteTask>d__13:MoveNext <0x005ea>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x000fa>
	  at Microsoft.Build.BackEnd.TaskBuilder:ExecuteTask <0x00262>
	  at <ProcessBucket>d__51:MoveNext <0x001f5>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x000fa>
	  at Microsoft.Build.BackEnd.TargetEntry:ProcessBucket <0x001ba>
	  at <ExecuteTarget>d__44:MoveNext <0x00d7a>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x000fa>
	  at Microsoft.Build.BackEnd.TargetEntry:ExecuteTarget <0x00172>
	  at <ProcessTargetStack>d__23:MoveNext <0x00f02>
	  at MoveNextRunner:InvokeMoveNext <0x000b0>
	  at System.Threading.ExecutionContext:RunInternal <0x001a9>
	  at System.Threading.ExecutionContext:Run <0x00042>
	  at MoveNextRunner:Run <0x000b9>
	  at <>c:<Run>b__2_0 <0x00058>
	  at System.Threading.Tasks.Task:InnerInvoke <0x0008f>
	  at System.Threading.Tasks.Task:Execute <0x00037>
	  at System.Threading.Tasks.Task:ExecutionContextCallback <0x0005b>
	  at System.Threading.ExecutionContext:RunInternal <0x001a9>
	  at System.Threading.ExecutionContext:Run <0x00042>
	  at System.Threading.Tasks.Task:ExecuteWithThreadLocal <0x000f6>
	  at System.Threading.Tasks.Task:ExecuteEntry <0x000e8>
	  at System.Threading.Tasks.TaskScheduler:TryExecuteTask <0x00043>
	  at DedicatedThreadsTaskScheduler:<InjectThread>b__6_0 <0x000c2>
	  at System.Threading.ThreadHelper:ThreadStart_Context <0x000aa>
	  at System.Threading.ExecutionContext:RunInternal <0x001a9>
	  at System.Threading.ExecutionContext:Run <0x00042>
	  at System.Threading.ExecutionContext:Run <0x00067>
	  at System.Threading.ThreadHelper:ThreadStart <0x00042>
	  at System.Object:runtime_invoke_void__this__ <0x000b0>
=================================================================
Error executing sensor: 'OmniSharp'
java.lang.IllegalStateException: Unable to start OmniSharp
	at org.sonarsource.sonarlint.omnisharp.OmnisharpSensor.execute(OmnisharpSensor.java:102)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:81)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.sensor.SensorsExecutor.execute(SensorsExecutor.java:72)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:122)
	at org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer.startComponents(ComponentContainer.java:119)
	at org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer.execute(ComponentContainer.java:104)
	at org.sonarsource.sonarlint.core.analysis.container.module.ModuleContainer.analyze(ModuleContainer.java:71)
	at org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand.execute(AnalyzeCommand.java:58)
	at org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand.execute(AnalyzeCommand.java:32)
	at org.sonarsource.sonarlint.core.analysis.AnalysisEngine$AsyncCommand.execute(AnalysisEngine.java:150)
	at org.sonarsource.sonarlint.core.analysis.AnalysisEngine.executeQueuedCommands(AnalysisEngine.java:70)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalStateException: Timeout waiting for solution/project configuration to be loaded
	at org.sonarsource.sonarlint.omnisharp.OmnisharpServer.doStart(OmnisharpServer.java:198)
	at org.sonarsource.sonarlint.omnisharp.OmnisharpServer.lazyStart(OmnisharpServer.java:148)
	at org.sonarsource.sonarlint.omnisharp.OmnisharpSensor.execute(OmnisharpSensor.java:96)
	... 11 more