SonarQube does not seem to recognise that an NUnit assertion has already validated a value is not null:
HttpResponse response = someObject As HttpResponse;
Assert.That(response, Is.Not.Null);
Assert.That(response.StatusCode, Is.EqualTo(StatusCodes.Status200OK));
Given that the first Assert Is.Not.Null ensures the value cannot be null, S2259 should not bedetected in the second assert since it is not possible to reach that line in any execution path
Indeed this is a false positive.
There’s already an open issue in our repository for this.
I’m aware that the issue has been open for quite some time, but given that this rule is currently getting migrated to a new symbolic execution engine, it should be tackled in the near future.