-
Notifications
You must be signed in to change notification settings - Fork 26
/
DeleteFromNotUsed.xq
28 lines (27 loc) · 1.14 KB
/
DeleteFromNotUsed.xq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(: Check for single delete statement in search statement, on the search query buffer :)
(: @Language Xpp :)
(: @Author bertd@microsoft.com :)
<Diagnostics Category='Best practice' href='docs.microsoft.com/Socratex/DeleteFromNotUsed' Version='1.0'>
{
for $a in /*
for $m in $a//Method
for $s in $m//SearchStatement
where count($s/CompoundStatement/*) = 1
let $bn := string($s/Query/@BufferName)
for $qc in $s/CompoundStatement/ExpressionStatement/QualifiedCall[@MethodName = "delete"]
for $sq in $qc/SimpleQualifier
where string($sq/@Name) = $bn
return
<Diagnostic>
<Moniker>DeleteFromNotUsed</Moniker>
<Severity>Warning</Severity>
<Path>{string($a/@PathPrefix)}/Method/{string($m/@Name)}</Path>
<Message>Validate if delete_from can be used for this operation. Use set based instead of row based database operations when possible.</Message>
<DiagnosticType>AppChecker</DiagnosticType>
<Line>{string($qc/@StartLine)}</Line>
<Column>{string($qc/@StartCol)}</Column>
<EndLine>{string($qc/@EndLine)}</EndLine>
<EndColumn>{string($qc/@EndCol)}</EndColumn>
</Diagnostic>
}
</Diagnostics>