[doc] [javascript] Adjust externalInfoUrl properties to new site - Part 6
Note: I also took the chance to fix tab damage
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -8,144 +8,144 @@
|
||||
The Braces Ruleset contains a collection of braces rules.
|
||||
</description>
|
||||
|
||||
<rule name="IfStmtsMustUseBraces"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Avoid using if statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/ecmascript/braces.html#IfStmtsMustUseBraces">
|
||||
<description>
|
||||
<rule name="IfStmtsMustUseBraces"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Avoid using if statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_braces.html#ifstmtsmustusebraces">
|
||||
<description>
|
||||
Avoid using if statements without using curly braces.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//IfStatement[@Else = "false" and not(child::Scope)]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
// Ok
|
||||
if (foo) {
|
||||
x++;
|
||||
x++;
|
||||
}
|
||||
|
||||
// Bad
|
||||
if (foo)
|
||||
x++;
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
x++;
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="IfElseStmtsMustUseBraces"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Avoid using 'if...else' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/ecmascript/braces.html#IfElseStmtsMustUseBraces">
|
||||
<description>
|
||||
<rule name="IfElseStmtsMustUseBraces"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Avoid using 'if...else' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_braces.html#ifelsestmtsmustusebraces">
|
||||
<description>
|
||||
Avoid using if..else statements without using curly braces.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ExpressionStatement[parent::IfStatement[@Else = "true"]]
|
||||
[not(child::Scope)]
|
||||
[not(child::IfStatement)]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
// Ok
|
||||
if (foo) {
|
||||
x++;
|
||||
x++;
|
||||
} else {
|
||||
y++;
|
||||
y++;
|
||||
}
|
||||
|
||||
// Bad
|
||||
if (foo)
|
||||
x++;
|
||||
x++;
|
||||
else
|
||||
y++;
|
||||
y++;
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="WhileLoopsMustUseBraces"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Avoid using 'while' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/ecmascript/braces.html#WhileLoopsMustUseBraces">
|
||||
<description>
|
||||
<rule name="WhileLoopsMustUseBraces"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Avoid using 'while' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_braces.html#whileloopsmustusebraces">
|
||||
<description>
|
||||
Avoid using 'while' statements without using curly braces.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//WhileLoop[not(child::Scope)]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
// Ok
|
||||
while (true) {
|
||||
x++;
|
||||
x++;
|
||||
}
|
||||
|
||||
// Bad
|
||||
while (true)
|
||||
x++;
|
||||
x++;
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="ForLoopsMustUseBraces"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Avoid using 'for' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/ecmascript/braces.html#ForLoopsMustUseBraces">
|
||||
<description>
|
||||
<rule name="ForLoopsMustUseBraces"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Avoid using 'for' statements without curly braces"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_braces.html#forloopsmustusebraces">
|
||||
<description>
|
||||
Avoid using 'for' statements without using curly braces.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ForLoop[not(child::Scope)]
|
||||
//ForLoop[not(child::Scope)]
|
||||
|
|
||||
//ForInLoop[not(child::Scope)]
|
||||
//ForInLoop[not(child::Scope)]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
// Ok
|
||||
for (var i = 0; i < 42; i++) {
|
||||
foo();
|
||||
foo();
|
||||
}
|
||||
|
||||
// Bad
|
||||
for (var i = 0; i < 42; i++)
|
||||
foo();
|
||||
foo();
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="Controversial Ecmascript"
|
||||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
|
||||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
|
||||
|
||||
<description>
|
||||
The Controversial ruleset contains rules that, for whatever reason, are considered controversial.
|
||||
@ -12,22 +12,28 @@ They are held here to allow people to include them as they see fit within their
|
||||
|
||||
<rule name="AvoidWithStatement"
|
||||
message="Avoid using with - it's bad news"
|
||||
language="ecmascript" since="5.0.1"
|
||||
language="ecmascript"
|
||||
since="5.0.1"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/ecmascript/basic.html#AvoidWithStatement">
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_controversial.html#avoidwithstatement">
|
||||
<description>Avoid using with - it's bad news</description>
|
||||
<priority>1</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value><![CDATA[
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//WithStatement
|
||||
]]></value>
|
||||
</property>
|
||||
</properties>
|
||||
<priority>1</priority>
|
||||
<example><![CDATA[
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
with (object) {
|
||||
property = 3; // Might be on object, might be on window: who knows.
|
||||
property = 3; // Might be on object, might be on window: who knows.
|
||||
}
|
||||
]]></example>
|
||||
</rule>
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
|
@ -2,4 +2,8 @@
|
||||
# BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
#
|
||||
|
||||
rulesets.filenames=rulesets/ecmascript/basic.xml,rulesets/ecmascript/braces.xml,rulesets/ecmascript/unnecessary.xml
|
||||
rulesets.filenames=\
|
||||
rulesets/ecmascript/basic.xml,\
|
||||
rulesets/ecmascript/braces.xml,\
|
||||
rulesets/ecmascript/controversial.xml,\
|
||||
rulesets/ecmascript/unnecessary.xml
|
||||
|
@ -9,65 +9,67 @@ The Unnecessary Ruleset contains a collection of rules for unnecessary code.
|
||||
</description>
|
||||
|
||||
<rule name="UnnecessaryParentheses"
|
||||
language="ecmascript"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Unnecessary parentheses."
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/ecmascript/unnecessary.html#UnnecessaryParentheses">
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_unnecessary.html#unnecessaryparentheses">
|
||||
<description>Unnecessary parentheses should be removed.</description>
|
||||
<priority>4</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ParenthesizedExpression/ParenthesizedExpression
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
var x = 1; // Ok
|
||||
var y = (1 + 1); // Ok
|
||||
var z = ((1 + 1)); // Bad
|
||||
]]>
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="UnnecessaryBlock"
|
||||
language="ecmascript"
|
||||
language="ecmascript"
|
||||
since="5.0"
|
||||
message="Unnecessary block."
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/ecmascript/unnecessary.html#UnnecessaryBlock">
|
||||
<description>An unnecessary Block is present. Such Blocks are often used in other languages to
|
||||
introduce a new variable scope. Blocks do not behave like this in ECMAScipt, and using them can
|
||||
be misleading. Considering removing this unnecessary Block.</description>
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_unnecessary.html#unnecessaryblock">
|
||||
<description>
|
||||
An unnecessary Block is present. Such Blocks are often used in other languages to
|
||||
introduce a new variable scope. Blocks do not behave like this in ECMAScipt, and using them can
|
||||
be misleading. Considering removing this unnecessary Block.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//Block[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
|
||||
or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)]
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//Block[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
|
||||
or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)]
|
||||
|
|
||||
//Scope[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
|
||||
or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
//Scope[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
|
||||
or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
if (foo) {
|
||||
// Ok
|
||||
// Ok
|
||||
}
|
||||
if (bar) {
|
||||
{
|
||||
// Bad
|
||||
}
|
||||
{
|
||||
// Bad
|
||||
}
|
||||
}
|
||||
]]>
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
@ -76,32 +78,39 @@ if (bar) {
|
||||
since="5.5.0"
|
||||
message="The else block is unnecessary"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/rules/ecmascript/unnecessary.html#NoElseReturn">
|
||||
<description>The else block in a if-else-construct is unnecessary if the `if` block contains a return.
|
||||
Then the content of the else block can be put outside.
|
||||
|
||||
See also: http://eslint.org/docs/rules/no-else-return
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_unnecessary.html#noelsereturn">
|
||||
<description>
|
||||
The else block in a if-else-construct is unnecessary if the `if` block contains a return.
|
||||
Then the content of the else block can be put outside.
|
||||
|
||||
See also: <http://eslint.org/docs/rules/no-else-return>
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath"><value><![CDATA[
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//IfStatement[@Else="true"][Scope[1]/ReturnStatement]
|
||||
]]></value></property>
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example><![CDATA[
|
||||
<example>
|
||||
<![CDATA[
|
||||
// Bad:
|
||||
if (x) {
|
||||
return y;
|
||||
return y;
|
||||
} else {
|
||||
return z;
|
||||
return z;
|
||||
}
|
||||
|
||||
// Good:
|
||||
if (x) {
|
||||
return y;
|
||||
return y;
|
||||
}
|
||||
return z;
|
||||
]]></example>
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
</ruleset>
|
||||
|
Reference in New Issue
Block a user