Home

Control flow statements IF, WHILE and TRY should not be nested too deeply

Rule description

  • Control flow statements IF, WHILE and TRY should not be nested too deeply

 

Non-compliant Code Example

DECLARE @Number int;  
SET @Number = 50;  
IF @Number < 10  
	PRINT 'The number is less than 10.';  
ELSE IF @Number < 20  
	PRINT 'The number is less than 20.';  
ELSE IF @Number < 30  
	PRINT 'The number is less than 30.';  
ELSE IF @Number < 40  
	PRINT 'The number is less than 40.';  
ELSE IF @Number < 50  
	PRINT 'The number is less than 50.';   --Non compliant code (Control flow statements are nested beyond default defined limit 4)
ELSE IF @Number < 60  
	PRINT 'The number is less than 60.';   --Non compliant code (Control flow statements are nested beyond default defined limit 4)
GO
Visual Expert 2020
 VETSQLRULE61