Code Style

AssignmentInOperand

Since: PMD 5.0

Priority: Medium High (2)

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 ‘==’.

UnnecessaryBlock

Since: PMD 5.0

Priority: Medium (3)

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.

//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)]

Example(s):

if(foo){// Ok}if(bar){{// Bad}}

Use this rule by referencing it:

<ruleref="category/ecmascript/codestyle.xml/UnnecessaryBlock"/>

UnnecessaryParentheses

Since: PMD 5.0

Priority: Medium Low (4)

Unnecessary parentheses should be removed.

//ParenthesizedExpression/ParenthesizedExpression

Example(s):

varx=1;// Okvary=(1+1);// Okvarz=((1+1));// Bad

Use this rule by referencing it:

<ruleref="category/ecmascript/codestyle.xml/UnnecessaryParentheses"/>

UnreachableCode

Since: PMD 5.0

Priority: High (1)

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.