Pular para o conteúdo principal

Branches in the same conditional structure should not have exactly the same implementation

Having two branches in the same if structure 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 they should be combined.

Noncompliant Code Example

IF var BETWEEN 0 AND 10 THEN
do_the_thing();
ELSIF var BETWEEN 10 AND 20 THEN
do_the_thing(); -- Noncompliant; duplicates first condition
ELSIF var BETWEEN 20 AND 50 THEN
do_the_another_thing();
ELSE
do_the_rest()
END IF;

Compliant Solution

IF var BETWEEN 0 AND 10 THEN
do_the_thing();
ELSIF var BETWEEN 10 AND 20 THEN
do_the_second_thing();
ELSIF var BETWEEN 20 AND 50 THEN
do_the_another_thing();
ELSE
do_the_rest()
END IF;