Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix S2259: FP with null conditional operator #2361

Closed
nnpcYvIVl opened this issue Mar 28, 2019 · 2 comments · Fixed by #2497
Closed

Fix S2259: FP with null conditional operator #2361

nnpcYvIVl opened this issue Mar 28, 2019 · 2 comments · Fixed by #2497
Labels
Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@nnpcYvIVl
Copy link

The following code flags S2259 on exception after it has been checked by a null-conditional operator. Is this a false positive?

using System;
using System.Collections;

namespace S2259_False_Positive
{
    class C
    {
        void M(Exception exception)
        {
            if (exception?.Data is IDictionary data)
            {
                if (exception.InnerException?.Data is IDictionary innerexceptiondata)
                {

                }
            }
        }
    }
}
  • SonarC# Version: Latest
  • Visual Studio Version: 15.9.10
@andrei-epure-sonarsource
Copy link
Contributor

Probably #2361 , #2164 and #1837 are all related to how we interpret the null-conditional operator

@andrei-epure-sonarsource andrei-epure-sonarsource changed the title S2259 False Positive S2259 False Positive with null conditional operator Apr 17, 2019
@andrei-epure-sonarsource andrei-epure-sonarsource modified the milestones: 7.14, 7.15 May 2, 2019
@andrei-epure-sonarsource andrei-epure-sonarsource removed this from the 7.15 milestone Jun 7, 2019
@andrei-epure-sonarsource
Copy link
Contributor

I removed this from 7.15 milestone as there should be a separate milestone dedicated to fixing advanced rules which use Symbolic Execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants