From d079eaff2baa7cd3d6f2d1d6f588ecd880ae521b Mon Sep 17 00:00:00 2001 From: Bertrand Desmarest Date: Fri, 1 Mar 2019 13:05:15 -0800 Subject: [PATCH] Minor update on existing rules --- rules/X++/BalancedTtsStatement.xq | 2 +- rules/X++/BooleanExpressionWithLiteral.xq | 2 +- rules/X++/Breakpoint.xq | 2 +- rules/X++/ComplexityIndentationCombined.xq | 2 +- rules/X++/DeleteFromNotUsed.xq | 2 +- rules/X++/DirectSQL.xq | 2 +- rules/X++/ExtensionsWithoutPrefix.xq | 4 ++-- rules/X++/InsertInLoop.xq | 2 +- rules/X++/MissingClassDocumentation.xq | 2 +- rules/X++/MissingMethodDocumentation.xq | 16 ++++++++-------- rules/X++/NestedSearch.xq | 2 +- rules/X++/SelectForUpdateAbsent.xq | 2 +- rules/X++/SelectUsingFirstOnly.xq | 2 +- rules/X++/SystemReflection.xq | 2 +- rules/X++/TableIndex.xq | 2 +- 15 files changed, 23 insertions(+), 23 deletions(-) diff --git a/rules/X++/BalancedTtsStatement.xq b/rules/X++/BalancedTtsStatement.xq index 8ae4272..9db4fdc 100644 --- a/rules/X++/BalancedTtsStatement.xq +++ b/rules/X++/BalancedTtsStatement.xq @@ -6,7 +6,7 @@ { let $scopes := ("IfStatement", "IfThenElseStatement", "WhileStatement", "DoWhileStatement", "ForStatement", "TryStatement", "CatchStatement", "FinallyStatement", "SearchStatement", "SwitchEntryStatement", "Method", "FunctionDeclaration") -for $a in //(Table | Class | Form | Query) +for $a in /* for $m in $a//Method for $s in ($m, $m//*[local-name() = $scopes]) let $ttsbegin := count( ($s/CompoundStatement/TtsBeginStatement) | ($s/TtsBeginStatement) ) diff --git a/rules/X++/BooleanExpressionWithLiteral.xq b/rules/X++/BooleanExpressionWithLiteral.xq index 1678ad0..1f37137 100644 --- a/rules/X++/BooleanExpressionWithLiteral.xq +++ b/rules/X++/BooleanExpressionWithLiteral.xq @@ -5,7 +5,7 @@ { - for $c in //(Class | Table | Form | Query) + for $c in /* for $m in $c//Method let $exprs := $m//OrExpression/BooleanLiteralExpression | $m//AndExpression/BooleanLiteralExpression diff --git a/rules/X++/Breakpoint.xq b/rules/X++/Breakpoint.xq index a96328d..12379f0 100644 --- a/rules/X++/Breakpoint.xq +++ b/rules/X++/Breakpoint.xq @@ -4,7 +4,7 @@ { - for $a in //(Class | Table | Form | Query) + for $a in /* for $m in $a//Method for $s in $m//BreakpointStatement return diff --git a/rules/X++/ComplexityIndentationCombined.xq b/rules/X++/ComplexityIndentationCombined.xq index f812f85..d2bfbdb 100644 --- a/rules/X++/ComplexityIndentationCombined.xq +++ b/rules/X++/ComplexityIndentationCombined.xq @@ -63,7 +63,7 @@ declare function local:visitMethod($m as element(Method)) as xs:integer let $complexityLimit := xs:integer(30) let $indentationLimit := xs:integer(2) - for $c in //(Class | Table | Form | Query) + for $c in /* for $m in $c//Method let $cmpl := local:MethodComplexity($m) where $cmpl > $complexityLimit diff --git a/rules/X++/DeleteFromNotUsed.xq b/rules/X++/DeleteFromNotUsed.xq index 30d1165..04ba38c 100644 --- a/rules/X++/DeleteFromNotUsed.xq +++ b/rules/X++/DeleteFromNotUsed.xq @@ -4,7 +4,7 @@ { - for $a in //(Class | Table | Form | Query) + for $a in /* for $m in $a//Method for $s in $m//SearchStatement where count($s/CompoundStatement/*) = 1 diff --git a/rules/X++/DirectSQL.xq b/rules/X++/DirectSQL.xq index 5193b62..f6db291 100644 --- a/rules/X++/DirectSQL.xq +++ b/rules/X++/DirectSQL.xq @@ -4,7 +4,7 @@ { - for $a in //(Class | Table | Form | Query) + for $a in /* for $m in $a/Method for $qc in $m//QualifiedCall where $qc/ExpressionQualifier[@Type = "Statement"] diff --git a/rules/X++/ExtensionsWithoutPrefix.xq b/rules/X++/ExtensionsWithoutPrefix.xq index 0aebf7a..87170af 100644 --- a/rules/X++/ExtensionsWithoutPrefix.xq +++ b/rules/X++/ExtensionsWithoutPrefix.xq @@ -4,9 +4,9 @@ { - for $a in //Class + for $a in /Class where $a/AttributeList/Attribute[@Name = "ExtensionOf"] - let $targetClass := $a/string(@ExtensionTarget) + let $targetClass := $a/AttributeList/Attribute[@Name = "ExtensionOf"]/AttributeExpression/IntrinsicAttributeLiteral[@FunctionName = "classStr"]/string(@Arg1) where $a/@Name = fn:concat($targetClass, "_Extension") return diff --git a/rules/X++/InsertInLoop.xq b/rules/X++/InsertInLoop.xq index a6f40fb..e122574 100644 --- a/rules/X++/InsertInLoop.xq +++ b/rules/X++/InsertInLoop.xq @@ -5,7 +5,7 @@ { let $ins := ("Insert", "doInsert") - for $a in //(Class | Table | Form | Query) + for $a in /* for $m in $a//Method for $s in $m//(SearchStatement | DoWhileStatement | ForStatement | WhileStatement) for $e in $s//CompoundStatement/ExpressionStatement//QualifiedCall[@MethodName = $ins] diff --git a/rules/X++/MissingClassDocumentation.xq b/rules/X++/MissingClassDocumentation.xq index bdb4056..ec347bf 100644 --- a/rules/X++/MissingClassDocumentation.xq +++ b/rules/X++/MissingClassDocumentation.xq @@ -10,7 +10,7 @@ declare function functx:trim ( $arg as xs:string? ) as xs:string { - for $c in //(Class | Table | Form | Query)[@IsPrivate = "false" and functx:trim(@Comments) = ""] + for $c in /(Class | Table | Form | Query)[@IsPrivate = "false" and functx:trim(@Comments) = ""] return MissingClassDocumentation diff --git a/rules/X++/MissingMethodDocumentation.xq b/rules/X++/MissingMethodDocumentation.xq index 554d076..d54a261 100644 --- a/rules/X++/MissingMethodDocumentation.xq +++ b/rules/X++/MissingMethodDocumentation.xq @@ -10,19 +10,19 @@ declare function functx:trim ( $arg as xs:string? ) as xs:string { - for $c in //(Class | Table | Form)[@IsPrivate = "false"] - for $m in $c//Method[@IsPrivate = "false" and functx:trim(@Comments) = ""] + for $c in /(Class | Table | Form)[@IsPrivate = "false"] + where $c//Method[@IsPrivate = "false" and functx:trim(@Comments) = ""] return MissingMethodDocumentation Warning - {string($c/@PathPrefix)}/Method/{string($m/@Name)} - Documentation is missing for non-private method on non-private class. XML documentation should be created to provide information related to usage. + {string($c/@PathPrefix)} + Documentation is missing for non-private method on this non-private class. XML documentation should be created to provide information related to usage. AppChecker - {string($m/@StartLine)} - {string($m/@StartCol)} - {string($m/@EndLine)} - {string($m/@EndCol)} + {string($c/@StartLine)} + {string($c/@StartCol)} + {string($c/@EndLine)} + {string($c/@EndCol)} } \ No newline at end of file diff --git a/rules/X++/NestedSearch.xq b/rules/X++/NestedSearch.xq index 2e2fc94..156cbe8 100644 --- a/rules/X++/NestedSearch.xq +++ b/rules/X++/NestedSearch.xq @@ -4,7 +4,7 @@ { - for $a in //(Class | Table | Form | Query) + for $a in /* for $m in $a/Method for $nested in $m//(SearchStatement | DoWhileStatement | ForStatement | WhileStatement)//SearchStatement return diff --git a/rules/X++/SelectForUpdateAbsent.xq b/rules/X++/SelectForUpdateAbsent.xq index eee6154..d8e1709 100644 --- a/rules/X++/SelectForUpdateAbsent.xq +++ b/rules/X++/SelectForUpdateAbsent.xq @@ -4,7 +4,7 @@ { - for $a in //(Class | Table | Form | Query) + for $a in /* for $m in $a/Method for $q in $m//Query where $q/data(SelectionHints) = "ForUpdate" diff --git a/rules/X++/SelectUsingFirstOnly.xq b/rules/X++/SelectUsingFirstOnly.xq index 06a0d32..135908e 100644 --- a/rules/X++/SelectUsingFirstOnly.xq +++ b/rules/X++/SelectUsingFirstOnly.xq @@ -5,7 +5,7 @@ { let $hints := ("FirstOnly1", "FirstOnly", "NoFetch") - for $a in //(Class | Table | Form | Query) + for $a in /* for $m in $a//Method for $q in $m//Query where string(node-name($q/..)) != "JoinSpecification" (: only outermost query :) diff --git a/rules/X++/SystemReflection.xq b/rules/X++/SystemReflection.xq index f65e9d9..f3345fc 100644 --- a/rules/X++/SystemReflection.xq +++ b/rules/X++/SystemReflection.xq @@ -4,7 +4,7 @@ { - for $a in //(Class | Table | Form | Query) + for $a in /* for $m in $a//Method where $m//*[starts-with(@Type, "System.Reflection")] return diff --git a/rules/X++/TableIndex.xq b/rules/X++/TableIndex.xq index 072a999..e6ea2ad 100644 --- a/rules/X++/TableIndex.xq +++ b/rules/X++/TableIndex.xq @@ -4,7 +4,7 @@ { - for $t in //Table + for $t in /Table where not (exists ($t//ClusteredIndex)) return