sonar-dotnet
sonar-dotnet copied to clipboard
Fix S2589 FP with nullable value types
Description
S2589 raises a false positive when used with nullable value types.
Repro steps
protected void Test(decimal? value1, decimal? value2)
{
if (value1 == null || value2 == null || value1 != value2)
{
Console.WriteLine("test");
}
}
Expected behavior
No issue is raised.
Actual behavior
An issue is riased.
Related information
- C#/VB.NET Plugins version: 8.33.0.40503
S2589 will trigger on null, too, e. g.
int? foo = (int?)6 ?? null;
Fixed by https://github.com/SonarSource/sonar-dotnet/pull/7750