False Positive S2583

Make sure to read this post before raising a thread here:

Then tell us:

  • What language is this for? CSharp
  • Which rule? S2583
  • Why do you believe it’s a false-positive/false-negative? Analyzer is missing that there is a lambda which could assign a value to e below.
  • Are you using
    • SonarCloud? No
    • SonarQube - which version? No
    • SonarLint - which IDE/version? Nuget: SonarAnalyzer.CSharp Version="9.17.0.82934
      • 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)
                    Error? e = null;
                    deleteInfo.Switch(
                            info => doStuff(info),
                            err => e = err);

                    if (e is not null) // False positive here.
                    {
                        return e;
                    }
1 Like

Hi @mjconrad. This is a known False Positive. The S2583 rule uses our Symbolic Execution engine, which doesn’t track calls to lambdas when it analyzes a method. This is a major feature we plan to implement in the future, but we don’t have a timeline for it yet.