Null check fallback value is reported as bug but it's not


(Georgy Grigoryev) #1

We use sonar cloud to perform check in the VSTS pipeline. Some of the bugs reported seem to be apparently wrong.

if (entityBaselineBlocks?.Any() ?? false)

it’s a combination of two c# features:

  • null propagation
  • null coalescing operator

Using that combination we’re doing two checks in one if statement. However, sonar report says that the code underneath that condition will be never executed. Could you please check and make appropriate changes?

(Amaury Levé) #2

Hi @iamkarlson,

Thank you for your feedback! We are aware that we have a couple of limitations on our rules when using some new syntax like ?, ??, tuple

We sadly cannot commit on a date where we will be able to fix this limitation.


You can track this ticket

(Georgy Grigoryev) #3

Hi, I haven’t found any solution on github. So let’s keep this ticket open until the issue is resolved. How is it?

(Amaury Levé) #4

@iamkarlson Fine by me (I was just pointing you to the ticket we will use when working on the fix).