"goto" statement should not be used (UsingGoto)¶
| Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
|---|---|---|---|---|---|
Code smell |
BSLOS |
Critical |
Yes |
5 |
standardbadpractice |
Description¶
goto is an unstructured control flow statement. It makes code less readable and maintainable.
Structured control flow statements such as if, for, while, continue or break should be used instead.
Examples¶
Bad:
I = 0;
~loop: Message(StrTemplate("i = %1", i));
i = i + 1;
If i < 10 Then
Goto ~Loop;
EndIf;
Good:
For Counter = 0 To 10 Do
Message(StrTemplate("Counter = %1", Counter))
EndDo;
Sources¶
Snippets¶
Diagnostic ignorance in code¶
// BSLLS:UsingGoto-off
// BSLLS:UsingGoto-on
Parameter for config¶
"UsingGoto": false