Home

WHEN clauses should not have too many lines

Rule description

  • WHEN clauses should not have too many lines

 

Non-compliant Code Example

DECLARE
	price NUMBER:=29500;

BEGIN
GetCarDetails(:price, car_record);
CASE (price)         
    WHEN price > 0 AND price  < 500000 THEN  		--Non compliant code (WHEN clauses is having lines more then default defined 6 limit)
		DBMS_OUTPUT.PUT_LINE('Low Model');
		DBMS_OUTPUT.PUT_LINE('Model Number:'|| car_record.modelnumber);
		DBMS_OUTPUT.PUT_LINE('Power Generation :'|| car_record.power);
		DBMS_OUTPUT.PUT_LINE('Engine :'|| car_record.engine_size);
		DBMS_OUTPUT.PUT_LINE('Size (LxWxH) :'|| car_record.car_size);
		DBMS_OUTPUT.PUT_LINE('Year Of Model:'|| car_record.yearmodel);
		DBMS_OUTPUT.PUT_LINE('Ex Showroom Price:'|| car_record.price);
	WHEN price >= 500000 AND price < 1200000
        THEN 'Hatchback Model'
    WHEN price >= 1200000 AND price < 1500000
        THEN 'Sedan Model'
  END;
END;
Visual Expert 2020
 VEPLSQLRULE171