SA0193 : Avoid unused labels to improve readability

The topic describes the SA0193 analysis rule.

Message

Avoid unused labels to improve readability

Description

The rule code and reports the unused labels.

The labels, which are declared, but not used should be removed in order to improve maintainability and avoid confusion about what is the label meant for.

How to fix

Remove the unused labels.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Effort To Fix
2 minutes per issue.
Categories

Design Rules, Code Smells

Additional Information

There is no additional info for this rule.

Example Test SQL
SQL
 1DECLARE @Counter int;
 2SET @Counter = 1;
 3WHILE @Counter < 10
 4BEGIN 
 5    SELECT @Counter
 6    SET @Counter = @Counter + 1
 7    IF @Counter = 4 GOTO Branch_One -- Jumps to the first branch.
 8 --   IF @Counter = 5 GOTO Branch_Two  -- This will never execute.
 9END
10Branch_One:
11    SELECT 'Jumping To Branch One.'
12    GOTO Branch_Three; --This will prevent Branch_Two from executing.
13Branch_Two:
14    SELECT 'Jumping To Branch Two.'
15Branch_Three:
16    SELECT 'Jumping To Branch Three.'

Analysis Results
  Message Line Column
1 SA0193 : Avoid unused labels to improve readability. 13 0
See Also

Other Resources