SA1500 fires for the while clause of do/while statement
See original GitHub issueThe following generates an SA1500 error when it shouldn’t:
bool condition = true;
do
{
condition = DetermineCondition();
} while( condition );
Forcing placement of while onto a separate line is counter to common code style practices. At the very least there should be a configuration option to set how this rule should handle the placement of the while clause.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:17 (12 by maintainers)
Top Results From Across the Web
StyleCopAnalyzers/documentation/SA1500.md at master
A violation of this rule occurs when the opening or closing brace within a statement, element, or expression is not placed on its...
Read more >do...while - JavaScript - MDN Web Docs - Mozilla
A statement that is executed at least once and is re-executed each time the condition evaluates to true. To execute multiple statements within...
Read more >Solved: Why is do while loop inside the do to loop not working?
The right answer is that you need to make sure that the condition will terminate. So in the case of DO WHILE() that...
Read more >While loop keeps running even when using break
The problem I am facing is that when I fire this function, the loop continues, and so if I fire it several times,...
Read more >C while and do...while Loop
Loops are used in programming to execute a block of code repeatedly until a specified condition is met. In this tutorial, you will...
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
@vweijsters Are we still discussing it?
This issues is really annoying, I want to keep this inspection, but additionally want to keep while on the same line with closing bracket.
I can prepare fix to ignore this for
do/while
.Do we need separate inspection, or separate setting in
stylecop.json
to show hint fordo/while
?I’m looking to include this because it takes the simpler approach of “ignoring” this location, as opposed to requiring the
while
to go on the same line as}
. This behavior aligns with all configurations of the Visual Studio formatter so it’s easy to see how it would make things a bit easier for people.