Update XPath rules to 2.0

This commit is contained in:
Clément Fournier
2019-02-21 16:51:07 +01:00
parent 3269b48add
commit eaceefc39e
17 changed files with 117 additions and 114 deletions

View File

@ -82,7 +82,7 @@ Global variables can lead to side-effects that are hard to debug.
<property name="xpath">
<value>
<![CDATA[
//Assignment[Name/@GlobalName = 'true']
//Assignment[Name/@GlobalName = true()]
]]>
</value>
</property>

View File

@ -25,17 +25,17 @@ indicative of the bug where the assignment operator '=' was used instead of the
<property name="xpath">
<value>
<![CDATA[
//IfStatement[$allowIf = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//IfStatement[$allowIf = false()]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//WhileLoop[$allowWhile = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//WhileLoop[$allowWhile = false()]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//DoLoop[$allowWhile = "false"]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//DoLoop[$allowWhile = false()]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//ForLoop[$allowFor = "false"]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//ForLoop[$allowFor = false()]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//ConditionalExpression[$allowTernary = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//ConditionalExpression[$allowTernary = false()]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//ConditionalExpression[$allowTernaryResults = "false"]/child::node()[position() = 2 or position() = 3]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//ConditionalExpression[$allowTernaryResults = false()]/child::node()[position() = 2 or position() = 3]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
]]>
</value>
</property>
@ -110,7 +110,7 @@ Avoid using if..else statements without using curly braces.
<property name="xpath">
<value>
<![CDATA[
//ExpressionStatement[parent::IfStatement[@Else = "true"]]
//ExpressionStatement[parent::IfStatement[@Else = true()]]
[not(child::Scope)]
[not(child::IfStatement)]
]]>
@ -149,7 +149,7 @@ Avoid using if statements without using curly braces.
<property name="xpath">
<value>
<![CDATA[
//IfStatement[@Else = "false" and not(child::Scope)]
//IfStatement[@Else = false() and not(child::Scope)]
]]>
</value>
</property>

View File

@ -23,9 +23,9 @@ This rule helps improve code portability due to differences in browser treatment
<property name="xpath">
<value>
<![CDATA[
//ObjectLiteral[$allowObjectLiteral = "false" and @TrailingComma = 'true']
//ObjectLiteral[$allowObjectLiteral = false() and @TrailingComma = true()]
|
//ArrayLiteral[$allowArrayLiteral = "false" and @TrailingComma = 'true']
//ArrayLiteral[$allowArrayLiteral = false() and @TrailingComma = true()]
]]>
</value>
</property>
@ -62,7 +62,7 @@ same type. The === operator avoids the casting.
<![CDATA[
//InfixExpression[(@Image = "==" or @Image = "!=")
and
(child::KeywordLiteral[@Image = "true" or @Image = "false"]
(child::KeywordLiteral[@Image = true() or @Image = false()]
or
child::NumberLiteral)
]