Unreachable Code (UnreachableCode)¶
Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
---|---|---|---|---|---|
Error |
BSL OS |
Minor |
Yes |
10 |
design suspicious |
Description¶
Code located after operators "Return", "GoTo", "Raise", "Break", "Continue" never will be executed.
Errors of unreachable code can be caused by developer carelessness when editing another's code.
Examples¶
Procedure Example()
Return;
// Code below operator Return will never be executed
For each Line from Lines Do
If Condition2 Then
Method();
EndIf;
EndDo;
EndProcedure
Function Example(Parameter1, Parameter2)
If Error Then
Raise "Error occurred";
// After rise exception the code bellow will be ignored
Parameter1 = Parameter2;
EndIf;
Return Parameter1;
EndFunction
Snippets¶
Diagnostic ignorance in code¶
// BSLLS:UnreachableCode-off
// BSLLS:UnreachableCode-on
Parameter for config¶
"UnreachableCode": false