Skip to content

Conversation

@sebastien-marichal
Copy link
Contributor

@sebastien-marichal sebastien-marichal commented Jul 16, 2024

Fixes #9466
Depends on #9528

@sebastien-marichal sebastien-marichal marked this pull request as draft July 16, 2024 15:46
@sebastien-marichal sebastien-marichal linked an issue Jul 17, 2024 that may be closed by this pull request
Base automatically changed from mary/lva-connect-throw to master July 18, 2024 14:57
Copy link
Contributor

@mary-georgiou-sonarsource mary-georgiou-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some refactoring

@sebastien-marichal sebastien-marichal marked this pull request as ready for review July 18, 2024 15:37
Copy link
Contributor

@mary-georgiou-sonarsource mary-georgiou-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed I'm not sure why you get the first or default catch or throw.
Please take a look.

{
AddBranch(block, catchBlock);
}
if (reachableCatchAndFinallyBlocks.Any() && reachableCatchAndFinallyBlocks.First() is { EnclosingRegion.Kind: ControlFlowRegionKind.Finally } finallyBlock)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (reachableCatchAndFinallyBlocks.Any() && reachableCatchAndFinallyBlocks.First() is { EnclosingRegion.Kind: ControlFlowRegionKind.Finally } finallyBlock)
if (reachableCatchAndFinallyBlocks.FirstOrDefault() is { EnclosingRegion.Kind: ControlFlowRegionKind.Finally } finallyBlock)

@sonarqubecloud
Copy link

@sonarqubecloud
Copy link

Copy link
Contributor

@mary-georgiou-sonarsource mary-georgiou-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mary-georgiou-sonarsource mary-georgiou-sonarsource merged commit 19c58d5 into master Jul 19, 2024
@mary-georgiou-sonarsource mary-georgiou-sonarsource deleted the sma/lva-throw-finally branch July 19, 2024 14:18
public void Using_Nested_Block_LiveInUntilTheEnd()
{
var code = """
const string code = """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cons string has no performance benefit over var:
https://stackoverflow.com/a/49224799
This creates unnecessary visual noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix S1854 FP: Throw should visit finally

3 participants