S4158: "Empty collections should not be accessed or iterated" False positive with local method

Hey there

Thanks for the report.

Please read this thread about reporting a false-positive/false-negative

Specifically, we’re missing what product(s) you’re using, and if relevant what version of those products.

And, I think you are probably facing the false-postive already reported here. S4158 FP: Collection filled in a local function · Issue #4478 · SonarSource/sonar-dotnet · GitHub