Make sure to read this post before raising a thread here:
Then tell us:
- What language is this for? C#
- Which rule? S2583
- Why do you believe it’s a false-positive/false-negative? The example below demonstrates as such
- Are you using
- SonarCloud? Yes
- SonarQube - which version?
- SonarLint - which IDE/version? VS2022 and 8.5.0.10497
- in connected mode with SonarQube or SonarCloud?
- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
List<int> ints = new();
List<int> retrievedInts = new();
ints.AddRange(retrievedInts);
if (ints.Count > 0) // This causes S2583 to be raised but can't always be true because ints is empty
{
throw new Exception();
}