<?xml version="1.0"?>

<ruleset name="Unnecessary"
    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 Unnecessary Ruleset contains a collection of rules for unnecessary code.
  </description>

  <rule name="UnnecessaryParentheses"
  		language="ecmascript"
        since="5.0"
        message="Unnecessary parentheses."
        class="net.sourceforge.pmd.lang.rule.XPathRule"
        externalInfoUrl="${pmd.website.baseurl}/rules/ecmascript/unnecessary.html#UnnecessaryParentheses">
    <description>Unnecessary parentheses should be removed.</description>
    <priority>4</priority>
    <properties>
       <property name="xpath">
          <value>
          <![CDATA[
//ParenthesizedExpression/ParenthesizedExpression
          ]]>
          </value>
       </property>
    </properties>
    <example>
    <![CDATA[
var x = 1; // Ok
var y = (1 + 1); // Ok
var z = ((1 + 1)); // Bad
    ]]>
    </example>
  </rule>

  <rule name="UnnecessaryBlock"
  		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>
    <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)]
|
	//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[
if (foo) {
   // Ok
}
if (bar) {
   {
      // Bad
   }
}
    ]]>
    </example>
  </rule>

</ruleset>