Skip to content

Duplicated code blocks in If...Then...ElseIf... statements (IfElseDuplicatedCodeBlock)

Type Scope Severity Activated
by default
Minutes
to fix
Tags
Code smell BSL
OS
Minor Yes 10 suspicious

Description

If...Then...ElseIf... statement should not have duplicated code blocks.

Examples

If p = 0 Then
    t = 0;
ElseIf p = 1 Then
    t = 1;
ElseIf p = 2 Then
    t = 1;
Else
    t = -1;
EndIf;

Snippets

Diagnostic ignorance in code

// BSLLS:IfElseDuplicatedCodeBlock-off
// BSLLS:IfElseDuplicatedCodeBlock-on

Parameter for config

"IfElseDuplicatedCodeBlock": false