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
Name Description Default 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

  Message Line Column
1 SEM008 : Range=1;0;1;5,Type=keyword,Token=begin 1 0
2 SEM008 : Range=2;0;2;7,Type=keyword,Token=declare 2 0
3 SEM008 : Range=2;8;2;13,Type=variable-local,Token=@like 2 8
4 SEM008 : Range=2;14;2;21,Type=predefined,Token=varchar 2 14
5 SEM008 : Range=2;22;2;24,Type=constant-exact-number,Token=20 2 22
6 SEM008 : Range=3;0;3;3,Type=keyword,Token=set 3 0
7 SEM008 : Range=3;4;3;9,Type=variable-local,Token=@like 3 4
8 SEM008 : Range=3;10;3;11,Type=opearator-assignment,Token== 3 10
9 SEM008 : Range=3;12;3;19,Type=constant-string,Token=’1,2,3′ 3 12
10 SEM008 : Range=6;0;6;6,Type=keyword,Token=select 6 0
46 SEM008 : Range=13;24;13;34,Type=constant-string,Token=’Example%’ 13 24
47 SEM008 : Range=20;0;20;3,Type=keyword,Token=end 20 0
See Also

Other Resources