All Downloads are FREE. Search and download functionalities are using the official Maven repository.

resources.report.rules.pmd.UselessParentheses.html Maven / Gradle / Ivy

Go to download

Sanity4J was created to simplify running multiple static code analysis tools on the Java projects. It provides a single entry point to run all the selected tools and produce a consolidated report, which presents all findings in an easily accessible manner.

The newest version!


UselessParentheses

UselessParentheses

Useless parentheses should be removed.

          
//Expression/PrimaryExpression/PrimaryPrefix/Expression
[count(*)=1][count(./CastExpression)=0][count(./ConditionalExpression[@Ternary='true'])=0]
[not(./AdditiveExpression[//Literal[@StringLiteral='true']])]
|
//Expression/ConditionalAndExpression/PrimaryExpression/PrimaryPrefix/Expression[
    count(*)=1 and
    count(./CastExpression)=0 and
    count(./EqualityExpression/MultiplicativeExpression)=0 and
    count(./ConditionalExpression[@Ternary='true'])=0 and
    count(./ConditionalOrExpression)=0]
|
//Expression/ConditionalOrExpression/PrimaryExpression/PrimaryPrefix/Expression[
    count(*)=1 and
    count(./CastExpression)=0 and
    count(./ConditionalExpression[@Ternary='true'])=0 and
    count(./EqualityExpression/MultiplicativeExpression)=0]
|
//Expression/ConditionalExpression/PrimaryExpression/PrimaryPrefix/Expression[
    count(*)=1 and
    count(./CastExpression)=0 and
    count(./EqualityExpression)=0]
|
//Expression/AdditiveExpression[not(./PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true'])]/PrimaryExpression[1]/PrimaryPrefix/Expression[
    count(*)=1 and
    not(./CastExpression) and
    not(./AdditiveExpression[@Image = '-']) and
    not(./ShiftExpression) and
    not(./RelationalExpression) and
    not(./InstanceOfExpression) and
    not(./EqualityExpression) and
    not(./AndExpression) and
    not(./ExclusiveOrExpression) and
    not(./InclusiveOrExpression) and
    not(./ConditionalAndExpression) and
    not(./ConditionalOrExpression) and
    not(./ConditionalExpression)]
|
//Expression/EqualityExpression/PrimaryExpression/PrimaryPrefix/Expression[
    count(*)=1 and
    count(./CastExpression)=0 and
    count(./AndExpression)=0 and
    count(./InclusiveOrExpression)=0 and
    count(./ExclusiveOrExpression)=0 and
    count(./ConditionalExpression)=0 and
    count(./ConditionalAndExpression)=0 and
    count(./ConditionalOrExpression)=0 and
    count(./EqualityExpression)=0]
          

Example(s):

    
public class Foo {

   private int _bar1;
   private Integer _bar2;

   public void setBar(int n) {
      _bar1 = Integer.valueOf((n)); // here
      _bar2 = (n); // and here
   }

}
    




© 2015 - 2024 Weber Informatics LLC | Privacy Policy