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: Throw should visit finally #9466

Closed
pavel-mikula-sonarsource opened this issue Jun 26, 2024 · 0 comments · Fixed by #9530
Closed

Fix S1854 FP: Throw should visit finally #9466

pavel-mikula-sonarsource opened this issue Jun 26, 2024 · 0 comments · Fixed by #9530
Assignees
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone

Comments

@pavel-mikula-sonarsource
Copy link
Contributor

pavel-mikula-sonarsource commented Jun 26, 2024

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;
    }
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. Area: CFG/SE CFG and SE related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants