Added new queries for switch statement anomalies

This commit is contained in:
Peter Villadsen 2021-05-10 21:16:50 -07:00
Родитель c218734f72
Коммит d0f341b322
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -5,7 +5,6 @@
Having more than one default part is semantically correct in X++
but makes maintenance much more difficult :)
(: Note: This does not find references updated with byref parameters :)
(: @Language Xpp :)
(: @Category Informational :)

Просмотреть файл

@ -0,0 +1,23 @@
(: Copyright (c) Microsoft Corporation.
Licensed under the MIT license. :)
(: Find switch statements that have case entries that are not constants :)
(: There is nothing semantically incorrect about this, except that it
may have maintainablity problems :)
(: @Language Xpp :)
(: @Category Informational :)
<SwitchNonConstantCases>
{
for $a in /(Class | Table | Form | Query)
for $sw in $a//SwitchStatement
for $cvs in $sw/CaseValues
where not( $cvs/(IntLiteralExpression | StringLiteralExpression | Int64LiteralExpression | RealLiteralExpression | QualifiedStaticFieldExpression | Intrinsic))
return <SwitchNonConstantCase Artifact='{$a/@Artifact}'
StartLine='{$sw/@StartLine}' StartCol='{$sw/@StartCol}' EndLine='{$sw/@EndLine}' EndCol='{$sw/@EndCol}'>
{
(: $cvs :)
}
</SwitchNonConstantCase>
}
</SwitchNonConstantCases>