Why is this an issue?
Having two branches in an IF
/ELSIF
chain with the same implementation is at best duplicate code, and at worst a coding
error.
If the same logic is truly needed for both instances, then in an IF
chain they should be combined.
Noncompliant code example
IF param = 1 THEN
sort_order := 0;
column := 'LastName';
ELSIF param = 2 THEN
sort_order := 0;
column := 'LastName'; -- Noncompliant
ELSE
sort_order := 1;
column := 'FirstName';
END IF;
Exceptions
Branches in an IF
/ELSIF
chain with implementation that contains a single line of code are ignored.
IF param = 1 THEN
sort_order := 0;
ELSIF param = 2 THEN
sort_order := 1;
ELSE
sort_order := 0; -- No issue, usually this is done on purpose to increase the readability
END IF;
But this exception does not apply to IF
chains without ELSE
-s when all branches have the same single line of code. In
case of IF
chains with ELSE
-s rule {rule:plsql:S3923} raises a bug.
IF param = 1 THEN -- Noncompliant, this might have been done on purpose but probably not
sort_order := 0;
ELSIF param = 2 THEN
sort_order := 0;
END IF;