From 42c798093227174534b882952fd3c585bc7e746e Mon Sep 17 00:00:00 2001 From: "Travis CI (pmd-bot)" Date: Wed, 16 Aug 2017 18:28:00 +0000 Subject: [PATCH] Update documentation --- docs/pages/pmd/rules/java.md | 1 - docs/pages/pmd/rules/java/controversial.md | 27 --------------- docs/pages/pmd/rules/java/design.md | 4 ++- docs/pages/pmd/rules/java/unnecessary.md | 40 +++++++++++++--------- 4 files changed, 26 insertions(+), 46 deletions(-) diff --git a/docs/pages/pmd/rules/java.md b/docs/pages/pmd/rules/java.md index 9f2019db28..95f179e362 100644 --- a/docs/pages/pmd/rules/java.md +++ b/docs/pages/pmd/rules/java.md @@ -116,7 +116,6 @@ List of rulesets and rules contained in each ruleset. * [OnlyOneReturn](pmd_rules_java_controversial.html#onlyonereturn): A method should have only one exit point, and that should be the last statement in the method. * [SuspiciousOctalEscape](pmd_rules_java_controversial.html#suspiciousoctalescape): A suspicious octal escape sequence was found inside a String literal.The Java language specificat... * [UnnecessaryConstructor](pmd_rules_java_controversial.html#unnecessaryconstructor): This rule detects when a constructor is not necessary; i.e., when there is only one constructor,i... -* [UnnecessaryParentheses](pmd_rules_java_controversial.html#unnecessaryparentheses): Sometimes expressions are wrapped in unnecessary parentheses, making them look like function calls. * [UseConcurrentHashMap](pmd_rules_java_controversial.html#useconcurrenthashmap): Since Java5 brought a new implementation of the Map designed for multi-threaded access, you canpe... * [UseObjectForClearerAPI](pmd_rules_java_controversial.html#useobjectforclearerapi): When you write a public method, you should be thinking in terms of an API. If your method is publ... diff --git a/docs/pages/pmd/rules/java/controversial.md b/docs/pages/pmd/rules/java/controversial.md index 6a42df6e7a..e47b6b6075 100644 --- a/docs/pages/pmd/rules/java/controversial.md +++ b/docs/pages/pmd/rules/java/controversial.md @@ -627,33 +627,6 @@ public class Foo { } ``` -## UnnecessaryParentheses - -**Since:** PMD 3.1 - -**Priority:** Medium (3) - -Sometimes expressions are wrapped in unnecessary parentheses, making them look like function calls. - -``` -//Expression - /PrimaryExpression - /PrimaryPrefix - /Expression[count(*)=1] - /PrimaryExpression - /PrimaryPrefix -``` - -**Example(s):** - -``` -public class Foo { - boolean bar() { - return (true); - } -} -``` - ## UseConcurrentHashMap **Since:** PMD 4.2.6 diff --git a/docs/pages/pmd/rules/java/design.md b/docs/pages/pmd/rules/java/design.md index 7f26c79c65..49a2e96c7e 100644 --- a/docs/pages/pmd/rules/java/design.md +++ b/docs/pages/pmd/rules/java/design.md @@ -1530,7 +1530,9 @@ constructors it is easier to distinguish between intentional (commented) and unintentional empty constructors. ``` -//ConstructorDeclaration[@Private='false'][count(BlockStatement) = 0 and ($ignoreExplicitConstructorInvocation = 'true' or not(ExplicitConstructorInvocation)) and @containsComment = 'false'] +//ConstructorDeclaration[@Private='false'] + [count(BlockStatement) = 0 and ($ignoreExplicitConstructorInvocation = 'true' or not(ExplicitConstructorInvocation)) and @containsComment = 'false'] + [not(../Annotation/MarkerAnnotation/Name[typeof(@Image, 'javax.inject.Inject', 'Inject')])] ``` **Example(s):** diff --git a/docs/pages/pmd/rules/java/unnecessary.md b/docs/pages/pmd/rules/java/unnecessary.md index 02e4dc8fe7..8863ae5513 100644 --- a/docs/pages/pmd/rules/java/unnecessary.md +++ b/docs/pages/pmd/rules/java/unnecessary.md @@ -244,9 +244,14 @@ public Long getId() { 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[not(parent::PrimaryPrefix)]/PrimaryExpression[count(*)>1] + /PrimaryPrefix/Expression + [not(./CastExpression)] + [not(./ConditionalExpression[@Ternary='true'])] + [not(./AdditiveExpression[//Literal[@StringLiteral='true']])] +| +//Expression[not(parent::PrimaryPrefix)]/PrimaryExpression[count(*)=1] + /PrimaryPrefix/Expression | //Expression/ConditionalAndExpression/PrimaryExpression/PrimaryPrefix/Expression[ count(*)=1 and @@ -257,16 +262,17 @@ Useless parentheses should be removed. | //Expression/ConditionalOrExpression/PrimaryExpression/PrimaryPrefix/Expression[ count(*)=1 and - count(./CastExpression)=0 and - count(./ConditionalExpression[@Ternary='true'])=0 and - count(./EqualityExpression/MultiplicativeExpression)=0] + not(./CastExpression) and + not(./ConditionalExpression[@Ternary='true']) and + not(./EqualityExpression/MultiplicativeExpression)] | //Expression/ConditionalExpression/PrimaryExpression/PrimaryPrefix/Expression[ count(*)=1 and - count(./CastExpression)=0 and - count(./EqualityExpression)=0] + not(./CastExpression) and + not(./EqualityExpression)] | -//Expression/AdditiveExpression[not(./PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true'])]/PrimaryExpression[1]/PrimaryPrefix/Expression[ +//Expression/AdditiveExpression[not(./PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true'])] + /PrimaryExpression[1]/PrimaryPrefix/Expression[ count(*)=1 and not(./CastExpression) and not(./AdditiveExpression[@Image = '-']) and @@ -283,14 +289,14 @@ Useless parentheses should be removed. | //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] + not(./CastExpression) and + not(./AndExpression) and + not(./InclusiveOrExpression) and + not(./ExclusiveOrExpression) and + not(./ConditionalExpression) and + not(./ConditionalAndExpression) and + not(./ConditionalOrExpression) and + not(./EqualityExpression)] ``` **Example(s):**