Skip to content

Fix S1854 FP: Raises when variable is reassigned in a using body after it has been already assigned in using statement. #9473

@mary-georgiou-sonarsource

Description

S1854 FP

void Repro(IDisposable data)
{
    using (data = Something()) // Noncompliant
    {
        data = Something();   // Noncompliant FP
    }

    if (data != null)
    {
        Console.WriteLine("Hello");
    }
    IDisposable Something() => null;
}

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