Skip to content

Fix S1854 FP: Throw should visit finally #9466

@pavel-mikula-sonarsource

Description

We need to add a branch for Throw semantics to connect the blocks

    public int ReadInFinallyAfterCatch()
    {
        var value = 0;
        try
        {
            CanThrow();
            value = 42;
        }
        catch
        {
            value = 1;  // Noncompliant FP, used in finally after the throw
            throw;
        }
        finally
        {
            Log(value);
        }
        return value;
    }

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