SA0035 : TODO,HACK or UNDONE phrase found in a comment

The topic describes the SA0035 analysis rule.

Message

TODO,HACK or UNDONE phrase found in a comment

Description

This rule checks comments for one of TODO,HACK and UNDONE phrases.

How to fix

Review the comments, and the commented code, and consider completing the unfinished tasks.

Scope

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

Parameters
Name Description Default Value
Tokens

A comma separated list of tokens, which to be matched in comments and reported.

HACK,TODO,UNDONE

Remarks

The rule does not need Analysis Context or SQL Connection.

Effort To Fix
1 hour per issue.
Categories

Design Rules, Bugs

Additional Information

There is no additional info for this rule.

Example Test SQL
SQL
 1CREATE PROCEDURE [dbo].[uspGetWhereUsedProductID]
 2  @StartProductID  [int]
 3, @CheckDate  [datetime]
 4AS 
 5BEGIN
 6    SET  nocount ON;
 7    -- TODO : Validate parameters and check @CheckDate is not null.        
 8
 9    WITH  [BOM_cte](  [ProductAssemblyID]
10                    , [ComponentID]
11                    , [ComponentDesc]
12                    , [PerAssemblyQty]
13                    , [StandardCost]
14                    , [ListPrice]
15                    , [BOMLevel]
16                    , [RecursionLevel]) -- CTE name and columns
17        AS (SELECT    
18                        b.[ProductAssemblyID]
19                      , b.[ComponentID]
20                      , p.[Name]
21                      , b.[PerAssemblyQty]
22                      , p.[StandardCost]
23                      , p.[ListPrice]
24                      , b.[BOMLevel]
25                      , 0 -- Get the initial list of components for the bike assembly ( HACK test )
26
27            FROM      
28                        [Production].[BillOfMaterials] b
29            INNER JOIN  [Production].[Product] p
30            ON          b.[ProductAssemblyID]=p.[ProductID]
31            WHERE   
32                        b.[ComponentID]=@StartProductID
33                    AND @CheckDate>=b.[StartDate]
34                    AND @CheckDate<=ISNULL(  b.[EndDate]
35                                           , @CheckDate)
36            UNION ALL
37            SELECT    
38                        b.[ProductAssemblyID]
39                      , b.[ComponentID]
40                      , p.[Name]
41                      , b.[PerAssemblyQty]
42                      , p.[StandardCost]
43                      , p.[ListPrice]
44                      , b.[BOMLevel]
45                      , [RecursionLevel]+1 -- Join recursive member to anchor
46
47            FROM      
48                        [BOM_cte] cte
49            INNER JOIN  [Production].[BillOfMaterials] b
50            ON          cte.[ProductAssemblyID]=b.[ComponentID]
51            INNER JOIN  [Production].[Product] p
52            ON          b.[ProductAssemblyID]=p.[ProductID]
53            WHERE   
54                        @CheckDate>=b.[StartDate]
55                    AND @CheckDate<=ISNULL(  b.[EndDate]
56                                           , @CheckDate))
57    SELECT    
58                b.[ProductAssemblyID]
59              , b.[ComponentID]
60              , b.[ComponentDesc]
61              , sum(b.[PerAssemblyQty]) AS [TotalQuantity]
62              , b.[StandardCost]
63              , b.[ListPrice]
64              , b.[BOMLevel]
65              , b.[RecursionLevel]
66    FROM      
67                [BOM_cte] b
68    GROUP BY  
69                b.[ComponentID]
70              , b.[ComponentDesc]
71              , b.[ProductAssemblyID]
72              , b.[BOMLevel]
73              , b.[RecursionLevel]
74              , b.[StandardCost]
75              , b.[ListPrice]
76    ORDER BY  
77                b.[BOMLevel]
78              , b.[ProductAssemblyID]
79              , b.[ComponentID]
80    OPTION(  maxrecursion 25)
81END

Analysis Results
  Message Line Column
1 SA0035 : Text `TODO` found inside comments. 7 4
2 SA0035 : Text `HACK` found inside comments. 25 26
See Also

Other Resources