I am using the 9.9 version of sonarqube and the last version of sonarscaner on Windows.
I have a problem with this nullable condition.
In this case sonar lint targets an S2259 :
var matchingClosingInline = matchingClosingInlines.FirstOrDefault();
if (matchingClosingInline is not null)
{
var siblings = matchingClosingInline.GetNextSiblings().ToArray();
matchingClosingInline.Remove(); // <--------------- S2259 here
}
And in this case sonar lint nothing :
var matchingClosingInline = matchingClosingInlines.FirstOrDefault();
if (matchingClosingInline != null)
{
var siblings = matchingClosingInline.GetNextSiblings().ToArray();
matchingClosingInline.Remove(); //
}
I don’t understand why sonar lint make difference between is not and != in this case.
I guess you mention your SonarQube version - even though your report is about SonarLint - because you’re in connected mode? If not, can you provide your SonarLint flavor and version?
And what language is this. I’m sure it’s obvious to those who code in your language, but…
Can you please tell us if matchingClosingInline is a nullable value type (struct)? If so, this is a known issue and will be fixed in a future version of the analyzer.
Do you see the issue in Visual Studio? If so, can you please tell which version of Visual Studio you are using.
There is one odd thing in the code sample you posted: The issues is raised on the second line in the true branch of the if. I would have expected to see the issue on the first line, as there is already an invocation taking place. Is there something missing in your example?