-
Notifications
You must be signed in to change notification settings - Fork 26
/
NestedSearch.xq
23 lines (22 loc) · 1013 Bytes
/
NestedSearch.xq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(: Finds x++ nested "while select" statements :)
(: @Language Xpp :)
(: @Author bertd@microsoft.com :)
<Diagnostics Category='Best practice' href='docs.microsoft.com/Socratex/NestedSearch' Version='1.0'>
{
for $a in /*
for $m in $a/Method
for $nested in $m//(SearchStatement | DoWhileStatement | ForStatement | WhileStatement)//SearchStatement
return
<Diagnostic>
<Moniker>NestedSearch</Moniker>
<Severity>Warning</Severity>
<Path>{string($a/@PathPrefix)}/Method/{string($m/@Name)}</Path>
<Message>This method contains a nested "while select" statement. Whenever possible, use a join in the select statement, rather than using an inner while loop on the related table.</Message>
<DiagnosticType>AppChecker</DiagnosticType>
<Line>{string($nested/@StartLine)}</Line>
<Column>{string($nested/@StartCol)}</Column>
<EndLine>{string($nested/@EndLine)}</EndLine>
<EndColumn>{string($nested/@EndCol)}</EndColumn>
</Diagnostic>
}
</Diagnostics>