Skip to content

Fix S1854 FP: Raises when variable is assigned in expression that is part of ternary condition #9471

@mary-georgiou-sonarsource

Description

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);
    }
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions