G-1040: Avoid dead code.

Minor

Maintainability

Reason

Any part of your code, which is no longer used or cannot be reached, should be eliminated from your programs to simplify the code.

Example (bad)

DECLARE
   co_dept_purchasing CONSTANT departments.department_id%TYPE := 30;
BEGIN
   IF 2=3 THEN
      NULL; -- some dead code here
   END IF;

   NULL; -- some enabled code here

   <<my_loop>>
   LOOP
      EXIT my_loop;    
      NULL; -- some dead code here
   END LOOP my_loop;

   NULL; -- some other enabled code here

   CASE 
      WHEN 1 = 1 AND 'x' = 'y' THEN
         NULL; -- some dead code here
      ELSE
         NULL; -- some further enabled code here
   END CASE;

   <<my_loop2>>
   FOR r_emp IN (SELECT last_name
                   FROM employees
                  WHERE department_id = co_dept_purchasing
                     OR commission_pct IS NOT NULL 
                    AND 5=6) 
                -- "OR commission_pct IS NOT NULL" is dead code 
   LOOP
      SYS.dbms_output.put_line(r_emp.last_name);
   END LOOP my_loop2;

   RETURN;
   NULL; -- some dead code here
END;
/

Example (good)

DECLARE
   co_dept_admin CONSTANT dept.deptno%TYPE := 10;
BEGIN
   NULL; -- some enabled code here
   NULL; -- some other enabled code here
   NULL; -- some further enabled code here

   <<my_loop2>>
   FOR r_emp IN (SELECT last_name
                   FROM employees
                  WHERE department_id = co_dept_admin
                     OR commission_pct IS NOT NULL) 
   LOOP
      sys.dbms_output.put_line(r_emp.last_name);
   END LOOP my_loop2;
END;
/