Risk of null pointer exception not detected

Hi,

I just install a fresh docker service from image sonarqube:25.7.0.110598-community with Embeded database for testing.

I analyse a C# project and some issues are well detected but I can’t understand why the “Risk of null pointer exception” (I’m not sure what is the correct name for this control) is not detected for the code below :

foreach (PlanarFace face in topFaces)
{
Edge longestEdge = null;
foreach (EdgeArray edgeArray in face.EdgeLoops)
{
foreach (Edge edge in edgeArray)
{
if (longestEdge == null || longestEdge.ApproximateLength < edge.ApproximateLength) longestEdge = edge;
}
}

output.Add(longestEdge.AsCurve());

}

I expect the output.Add(longestEdge.AsCurve()); to be detected as “Risk of null pointer exception”, why not?

Note that I’ve previously made some test with image sonarqube:9.9.8-community and the issue was detected on this version.

Hi,

You’re looking for rule S2259, which is available on SonarQube Cloud but only in commercial editions on-prem.

 
HTH,
Ann