diff --git a/pmd-javascript/src/main/resources/rulesets/ecmascript/basic.xml b/pmd-javascript/src/main/resources/rulesets/ecmascript/basic.xml
index 775763483f..32e7ba49ab 100644
--- a/pmd-javascript/src/main/resources/rulesets/ecmascript/basic.xml
+++ b/pmd-javascript/src/main/resources/rulesets/ecmascript/basic.xml
@@ -1,91 +1,91 @@
+ 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">
- Rules concerning basic ECMAScript guidelines.
+ Rules concerning basic ECMAScript guidelines.
-
-
+
+
Avoid assignments in operands; this can make code more complicated and harder to read. This is sometime
indicative of the bug where the assignment operator '=' was used instead of the equality operator '=='.
-
+
2
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
-
-
+]]>
+
+
-
-
+
+
A 'return', 'break', 'continue', or 'throw' statement should be the last in a block. Statements after these
will never execute. This is a bug, or extremely poor style.
-
- 1
-
-
-
+
+ 1
+
+
+
-
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
The numeric literal will have at different value at runtime, which can happen if you provide too much
precision in a floating point number. This may result in numeric calculations being in error.
-
- 2
-
-
-
-
+ 2
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
ECMAScript does provide for return types on functions, and therefore there is no solid rule as to their usage.
However, when a function does use returns they should all have a value, or all with no value. Mixed return
usage is likely a bug, or at best poor style.
-
- 2
-
-
+ 2
+
+
-
-
+
+
-
-
+
+
A for-in loop in which the variable name is not explicitly scoped to the enclosing scope with the 'var' keyword can
refer to a variable in an enclosing scope outside the nearest enclosing scope. This will overwrite the
existing value of the variable in the outer scope when the body of the for-in is evaluated. When the for-in loop
has finished, the variable will contain the last value used in the for-in, and the original value from before
the for-in loop will be gone. Since the for-in variable name is most likely intended to be a temporary name, it
is better to explicitly scope the variable name to the nearest enclosing scope with 'var'.
-
- 1
-
-
-
-
+ 1
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
+
+
-
-
- Using == in condition may lead to unexpected results, as the variables are automatically casted to be of the
- same type. The === operator avoids the casting.
-
- 3
-
-
-
-
+
+Using == in condition may lead to unexpected results, as the variables are automatically casted to be of the
+same type. The === operator avoids the casting.
+
+ 3
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
+
+
-
+
This rule helps to avoid using accidently global variables by simply missing the "var" declaration.
Global variables can lead to side-effects that are hard to debug.
- 1
-
-
-
+ 1
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
This rule helps improve code portability due to differences in browser treatment of trailing commas in object or array literals.
- 1
-
-
-
+ 1
+
+
+
-
-
-
-
+
+
+
+
-
+
-
-
+
+
- TODO
- 1
+ externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_basic.html#usebasewithparseint">
+
+This rule checks for usages of parseInt. While the second parameter is optional and usually defaults
+to 10 (base/radix is 10 for a decimal number), different implementations may behave differently.
+It also improves readability, if the base is given.
+
+See also: [parseInt()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
+
+ 1
-
-
+
+
-
-
-
+]]>
+
+
+
+
+
+
+
diff --git a/pmd-javascript/src/main/resources/rulesets/ecmascript/braces.xml b/pmd-javascript/src/main/resources/rulesets/ecmascript/braces.xml
index e1fdfda54a..7a45898ea0 100644
--- a/pmd-javascript/src/main/resources/rulesets/ecmascript/braces.xml
+++ b/pmd-javascript/src/main/resources/rulesets/ecmascript/braces.xml
@@ -8,144 +8,144 @@
The Braces Ruleset contains a collection of braces rules.
-
-
+
+
Avoid using if statements without using curly braces.
-
- 3
-
-
-
-
+ 3
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+ x++;
+]]>
+
+
-
-
+
+
Avoid using if..else statements without using curly braces.
-
- 3
-
-
-
+
+ 3
+
+
+
-
-
-
-
+]]>
+
+
+
+
-
-
+
+
-
-
+
+
Avoid using 'while' statements without using curly braces.
-
- 3
-
-
-
+
+ 3
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
Avoid using 'for' statements without using curly braces.
-
- 3
-
-
-
+
+ 3
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
diff --git a/pmd-javascript/src/main/resources/rulesets/ecmascript/controversial.xml b/pmd-javascript/src/main/resources/rulesets/ecmascript/controversial.xml
index a7318ba6e4..3383da9f4f 100644
--- a/pmd-javascript/src/main/resources/rulesets/ecmascript/controversial.xml
+++ b/pmd-javascript/src/main/resources/rulesets/ecmascript/controversial.xml
@@ -1,9 +1,9 @@
+ 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">
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
+ externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_controversial.html#avoidwithstatement">
Avoid using with - it's bad news
+ 1
-
-
+
+
-
-
- 1
-
+
+
+
+
+
-
+]]>
+
+
+
diff --git a/pmd-javascript/src/main/resources/rulesets/ecmascript/rulesets.properties b/pmd-javascript/src/main/resources/rulesets/ecmascript/rulesets.properties
index 0cd6f8a321..f16abf3841 100644
--- a/pmd-javascript/src/main/resources/rulesets/ecmascript/rulesets.properties
+++ b/pmd-javascript/src/main/resources/rulesets/ecmascript/rulesets.properties
@@ -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
diff --git a/pmd-javascript/src/main/resources/rulesets/ecmascript/unnecessary.xml b/pmd-javascript/src/main/resources/rulesets/ecmascript/unnecessary.xml
index 473f9827b3..f5a7ad8eef 100644
--- a/pmd-javascript/src/main/resources/rulesets/ecmascript/unnecessary.xml
+++ b/pmd-javascript/src/main/resources/rulesets/ecmascript/unnecessary.xml
@@ -9,65 +9,67 @@ The Unnecessary Ruleset contains a collection of rules for unnecessary code.
+ externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_unnecessary.html#unnecessaryparentheses">
Unnecessary parentheses should be removed.
4
-
-
-
+
+
-
-
+]]>
+
+
-
+]]>
- 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.
+ externalInfoUrl="${pmd.website.baseurl}/pmd_rules_ecmascript_unnecessary.html#unnecessaryblock">
+
+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.
+
3
-
-
-
+
+
-
-
+//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)]
+]]>
+
+
-
+]]>
@@ -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">
- 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">
+
+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>
3
-
+
+
+]]>
+
+
-
+
+]]>
+
-
\ No newline at end of file
+