Skip to content

SEM007 : Statement metrics for detecting duplicated code

Metrics rule - hash,tokens and lines count of each statement. For use by copy-paste detection.

The rule is only informational.

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

Rule has no parameters.

The rule does not need Analysis Context or SQL Connection.

Not configured.

Metrics

There is no additional info for this rule.

begin
-- 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:
/*
SELECT a.au_id ,
t.title
FROM authors AS a
INNER JOIN titleauthor AS ta
ON a.au_id = ta.au_id
INNER JOIN titles AS t
ON ta.title_id = t.title_id
WHERE t.title LIKE 'Example%'
*/
SELECT a.au_id ,
t.title
FROM authors AS a
INNER JOIN titleauthor AS ta
ON a.au_id = ta.au_id
INNER JOIN titles AS t
ON ta.title_id = t.title_id
WHERE t.title LIKE 'Example%' -- Ignore
SELECT a.au_id ,
t.title
FROM authors AS a
INNER JOIN titleauthor AS ta
ON a.au_id = ta.au_id
INNER JOIN titles AS t
ON ta.title_id = t.title_id
WHERE t.title LIKE 'Example%' -- Ignore
end
  Message Line Column
1 SEM007 : Hash=BCC52F87,Statements=4,Tokens=138,Lines=48,Position=1,StatementLength=1026 1 0
2 SEM007 : Hash=F01E538,Statements=1,Tokens=43,Lines=21,Position=2,StatementLength=495 3 0
3 SEM007 : Hash=EA388B09,Statements=1,Tokens=45,Lines=8,Position=3,StatementLength=233 25 0
4 SEM007 : Hash=EA388B09,Statements=1,Tokens=45,Lines=12,Position=4,StatementLength=241 34 0

Analysis Rules