Click or drag to resize

SA0183 : The commented out code reduces readability and should be deleted

The topic describes the SA0183 analysis rule.

Message

The commented out code reduces readability and should be deleted

Description

The rule reports blocks of comments, which contain syntax valid T-SQL statements.

The commented blocks of code reduce readability and must be avoided.

Even a later reuse of code was intended, it is a bad practice to have a commented blocks of unused code.

The unused code should be deleted and when needed, it can be retrieved from source control history.

Scope

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

Parameters
NameDescriptionDefault Value
MinCommentedBlockLines

The minimum number of lines a commented block, in order to be considered by the rule.

2

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Design Rules, New Rules

Additional Information

There is no additional info for this rule.

Example Test Script
 1CREATE TABLE Test.Greeting
 2(
 3GreetingId INT IDENTITY (1,1) PRIMARY KEY,
 4Message nvarchar(255) NOT NULL,
 5)
 6
 7INSERT INTO Test.Greeting (Message) 
 8SELECT 'Hello!'
 9UNION ALL 
10SELECT 'Hi!'
11UNION ALL
12SELECT 'Hello, world!'
13 -- DROP TABLE Test.Greeting
14INSERT INTO Test.Greeting (Message) 
15VALUES ('How do yo do?'),
16        ('Good morning!'), -- 1
17--2
18--3
19/* 4 
20            5 
21    6
22    7
23            8
249*/
25
26
27        ('Good night!')
28--Delete the steps from the Approval Policy
29DELETE  Test.Greeting WHERE GreetingId = 3
30/*
31SELECT 1 * FROM1 zTest.Greeting g 
32WHERE 
33g.Message like 'Hello%'
34
35DROP TABLE Test.Greeting*/
36

Analysis Results

 MessageLineColumn
1SA0183 : The commented out code reduces readability and should be deleted.300
See Also

Other Resources