Home
All branches in a conditional structure should not have exactly the same implementation
Rule description
- All branches in a conditional structure should not have exactly the same implementation
Non-compliant Code Example
BEGIN IF salary <= 20000 THEN EmpLevel := 'Average Salary'; ELSIF salary > 20000 and salary <= 60000 THEN EmpLevel := 'Average Salary'; --Non compliant code (IF Else condition is having same implementation) ELSIF salary > 6000 and salary <= 110000 THEN EmpLevel := 'Moderate Salary'; ELSE EmpLevel := 'High Salary'; END IF; END;
Compliant Code Example
BEGIN IF salary <= 20000 THEN EmpLevel := 'Low Salary'; ELSIF salary > 20000 and salary <= 60000 THEN EmpLevel := 'Average Salary'; --Compliant code (All IF Else condition is having different implementation) ELSIF salary > 6000 and salary <= 110000 THEN EmpLevel := 'Moderate Salary'; ELSE EmpLevel := 'High Salary'; END IF; END;