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 S1854 FP: Raises when variable is assigned in expression that is part of ternary condition #9471

Closed
mary-georgiou-sonarsource opened this issue Jun 26, 2024 · 1 comment · Fixed by #9533
Assignees
Labels
Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone

Comments

@mary-georgiou-sonarsource
Copy link
Contributor

mary-georgiou-sonarsource commented Jun 26, 2024

Repro steps

void Repro(bool condition)
{
    byte[]? tempArray = null;
    _ = condition
        ? tempArray = new byte[42]  // Noncompliant FP
        : new byte[24];
    if (tempArray != null)
    {
        Console.WriteLine(tempArray);
    }
}
@sebastien-marichal
Copy link
Contributor

This is the same root cause as #9472.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Projects
None yet
4 participants