Ter duas branches na mesma estrutura if
com a mesma implementação é código duplicado na melhor das hipóteses,
na pior é um erro de programação. Se a mesma lógica é realmente necessária para as duas situações, então as condições devem ser combinadas.
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;
IF (var BETWEEN 0 AND 20) THEN do_the_thing(); ELSIF var BETWEEN 10 AND 20 THEN do_the_another_thing(); ELSE do_the_rest() END IF;
ou
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;