Skip to content

SEM008 : List all tokens in the batch

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

The rule is only informational.

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

Name Description Default Value
SkipComments The parameter controls whether to ignore comments. yes

The rule does not need Analysis Context or SQL Connection.

Not configured.

Metrics

There is no additional info for this rule.

begin
declare @like varchar(20)
set @like = '1,2,3';
-- non-ANSI inner join syntax:
SELECT a.au_id ,
t.titlr e
FROM titles AS t ,
authors AS a ,
titleauthor AS ta
WHERE a.au_id = ta.au_id
AND ta.title_id = t.title_id
AND t.title LIKE 'Example%'
-- ANSI inner join syntax:
/* some comment */
end
  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

Analysis Rules