Click or drag to resize

SEM008 : List all tokens in the batch

The topic describes the SEM008 analysis rule.

Message

List all tokens in the batch

Description

Metrics rule - reports all tokens. For use with SonarQube CPD.

Scope

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

Parameters
NameDescriptionDefault Value
SkipComments

The parameter controls whether to ignore comments.

yes

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Metrics

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1begin
 2declare @like varchar(20) 
 3set @like = '1,2,3';
 4
 5-- non-ANSI inner join syntax: 
 6SELECT     a.au_id ,
 7           t.titlr e
 8FROM       titles AS t ,
 9           authors AS a ,
10           titleauthor AS ta
11WHERE      a.au_id = ta.au_id
12       AND ta.title_id = t.title_id
13       AND t.title LIKE 'Example%'
14
15-- ANSI inner join syntax: 
16
17/* some comment */
18
19
20end

Analysis Results

 MessageLineColumn
1SEM008 : Range=1;0;1;5,Type=keyword,Token=begin10
2SEM008 : Range=2;0;2;7,Type=keyword,Token=declare20
3SEM008 : Range=2;8;2;13,Type=variable-local,Token=@like,Type=variable-local28
4SEM008 : Range=2;14;2;21,Type=predefined,Token=varchar,Type=predefined214
5SEM008 : Range=2;22;2;24,Type=constant-exact-number,Token=20222
6SEM008 : Range=3;0;3;3,Type=keyword,Token=set30
7SEM008 : Range=3;10;3;11,Type=opearator-assignment,Token==310
8SEM008 : Range=3;4;3;9,Type=variable-local,Token=@like,Type=variable-local34
9SEM008 : Range=3;12;3;19,Type=constant-string,Token='1,2,3'312
10SEM008 : Range=6;0;6;6,Type=keyword,Token=select60
...
46SEM008 : Range=13;24;13;34,Type=constant-string,Token='Example%'1324
47SEM008 : Range=20;0;20;3,Type=keyword,Token=end200
See Also

Other Resources