Home

Jump statements should not be redundant

Rule description

  • Jump statements should not be redundant

 

Non-compliant Code Example

BEGIN
	FOR i IN 1 .. CUSTOMER_TABLE.COUNT  
		LOOP	
			EXIT WHEN CUSTOMER_TABLE(i).Id > 25; 
			IF CUSTOMER_TABLE(i) IS NOT NULL THEN
				DBMS_OUTPUT.PUT( i || ' = (' || CUSTOMER_TABLE(i).Name || ', ' || CUSTOMER_TABLE(i).PhoneNumber || ')' );
			END IF;
			CONTINUE; --Non compliant code (Jump statements is redundant)
		END LOOP;
EXCEPTION
  WHEN ERRORS THEN
	RETURN;
END CUSTOMER_TABLE_ITERATION;

Compliant Code Example

BEGIN
	FOR i IN 1 .. CUSTOMER_TABLE.COUNT  
		LOOP	
			EXIT WHEN CUSTOMER_TABLE(i).Id > 25; 
			IF CUSTOMER_TABLE(i) IS NOT NULL THEN
				DBMS_OUTPUT.PUT( i || ' = (' || CUSTOMER_TABLE(i).Name || ', ' || CUSTOMER_TABLE(i).PhoneNumber || ')' );
			END IF;
		END LOOP;
EXCEPTION
  WHEN ERRORS THEN
	RETURN;
END CUSTOMER_TABLE_ITERATION;
Visual Expert 2020
 VEPLSQLRULE110