And a thorough description of the problem / question:
Code: new List<int>().Should().BeEquivalentTo([5]);
Result:
False positive rule activation: csharpsquid:S1116 (Empty statements should be removed)
Expected result:
no rule activation because there is no redundant semicolon and code is valid
Hi, I’ve been seeing this false positive as well and thought I’d hop in to provide some additional data points.
I tried building a minimal repro (See GitHub) for it using SonarAnalyzer.CSharp 9.15.0.81779 (which is currently the latest version) and noticed that, using Rider with the SonarLint Plugin, I would only get the false positive from the plugin, not from the analyzer:
Notice how both the plugin and the analyzer (on build) report S125 because of the commented out line of code, but the analyzer does not report S1116, only the plugin.
So it seems to be a plugin-specific thing i guess? Hope these observations help in finding the cause
Here’s the info from Rider’s about dialog:
JetBrains Rider 2023.3.1
Build #RD-233.11799.303, built on December 12, 2023
<... Lisencing / Subcription info ...>
Runtime version: 17.0.9+7-b1087.7 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
.NET Core v7.0.10 x64 (Server GC)
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 4
Registry:
editor.config.csharp.support=true
ide.experimental.ui=true
Non-Bundled Plugins:
<... Other plugins ...>
org.sonarlint.idea (10.1.1.77150)
and the relevant output from dotnet --info:
$ dotnet --info
.NET SDK:
Version: 8.0.100
Commit: 57efcf1350
Workload version: 8.0.100-manifests.6c33ef20
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.100\
.NET workloads installed:
Workload version: 8.0.100-manifests.6c33ef20
There are no installed workloads to display.
Host:
Version: 8.0.0
Architecture: x64
Commit: 5535e31a71
.NET SDKs installed:
6.0.100-rc.1.21458.32 [C:\Program Files\dotnet\sdk]
7.0.114 [C:\Program Files\dotnet\sdk]
8.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.0-rc.1.21451.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found