S2583 false positive

csharp

(Paul Hickman) #1

Version 7.5.0.6605

The following function triggers rule S2583 with a claim the “if” always returns false. It returns true if s == “blah”

        private void func(string s)
        {
            if (s?.Equals("blah", StringComparison.OrdinalIgnoreCase) ?? false)
            {
                doSomething(s);
            }
        }

(Duncan Pocklington) #2

Thanks for reporting this Paul.

I’ve created https://github.com/SonarSource/sonar-csharp/issues/1870 to track it.

Regards,
Duncan