SA1513 fires in switch statements
See original GitHub issueSA1513 fires erroneously for switch statements with enforced braces. A block of code structured in the following manner
int i = 0;
switch (i)
{
case 1:
{
// Thing
break;
}
case 2:
{
// Other thing
break;
}
default:
{
break;
}
}
will raise two instances of the inspection at lines 8 and 13, respectively. I would assume that this is not intended behaviour, and that no instances should be raised. If this is intended, it would be a good candidate for addition into the json configuration, as it is a common pattern for switch statements and introducing blank lines between the cases would go against this.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:9 (5 by maintainers)
Top Results From Across the Web
c# - Trying to suppress StyleCop message SA1513: ...
I am trying to suppress the following StyleCop message for a specific property: SA1513: Statements or elements wrapped in curly brackets must ...
Read more >if and switch statements - select a code path to execute
The if-else statement allows you to choose which of the two code paths to follow based on a Boolean expression. The switch statement...
Read more >Untitled
Jamari traylor block, Wenatchee fire complex, Mahkota dimana pacarku, Thai wifi hotspot, ... Csir case 2013 expected exam date, Tablet advan vandroid t2ci, ......
Read more >switch - JavaScript - MDN Web Docs - Mozilla
The switch statement evaluates an expression, matching the expression's value against a series of case clauses, and executes statements ...
Read more >Strings in switch Statements
The switch statement compares the String object in its expression with the expressions associated with each case label as if it were using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I want to second this proposal. The rule also fires (I guess by design) when you put the break outside the block braces. At least in my eyes the following looks very weird:
From intuition I’d expect this form:
Is an external implementation that fixes this ready somewhere?