Why do you believe it’s a false-positive/false-negative?
This rule seems to always trigger when AddRange is used, even when the parameter’s list is empty.
Using SonarLint - which IDE/version? Visual Studio 2022 17.11.2, SonarLint for Visual Studio 2022 8.2.2.98119
in connected mode with SonarQube or SonarCloud? No
How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
List<int> i = [];
i.AddRange([]);
if (i.Count != 0) //S2589 triggers here : Change this condition so that it does not always evaluate to 'True'.
{
Console.WriteLine("Foo");
}
Hi @Gameplushy, thanks for bringing this up again. The issue got miscategorized, leading to postponing work on it in the past. I fixed the categorization, and we will tackle the problem in the hopefully not-so-distant future.
I however do not see any recent label change in the issue, the last one goes back to February.
Are you talking about those changes? Or is it about changes you made recently but aren’t visible for the public?