question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SA1500 fires for the while clause of do/while statement

See original GitHub issue

The 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:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
werwolfbycommented, Jun 9, 2020

@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 for do/while?

1reaction
sharwellcommented, May 19, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found