Merge branch 'issue-199' into pmd/5.5.x
Closes #203 (rebased onto pmd/5.4.x)
This commit is contained in:
@ -230,11 +230,13 @@ public class Test {
|
|||||||
count(*)=1 and
|
count(*)=1 and
|
||||||
count(./CastExpression)=0 and
|
count(./CastExpression)=0 and
|
||||||
count(./EqualityExpression/MultiplicativeExpression)=0 and
|
count(./EqualityExpression/MultiplicativeExpression)=0 and
|
||||||
|
count(./ConditionalExpression[@Ternary='true'])=0 and
|
||||||
count(./ConditionalOrExpression)=0]
|
count(./ConditionalOrExpression)=0]
|
||||||
|
|
|
|
||||||
//Expression/ConditionalOrExpression/PrimaryExpression/PrimaryPrefix/Expression[
|
//Expression/ConditionalOrExpression/PrimaryExpression/PrimaryPrefix/Expression[
|
||||||
count(*)=1 and
|
count(*)=1 and
|
||||||
count(./CastExpression)=0 and
|
count(./CastExpression)=0 and
|
||||||
|
count(./ConditionalExpression[@Ternary='true'])=0 and
|
||||||
count(./EqualityExpression/MultiplicativeExpression)=0]
|
count(./EqualityExpression/MultiplicativeExpression)=0]
|
||||||
|
|
|
|
||||||
//Expression/ConditionalExpression/PrimaryExpression/PrimaryPrefix/Expression[
|
//Expression/ConditionalExpression/PrimaryExpression/PrimaryPrefix/Expression[
|
||||||
@ -242,7 +244,7 @@ public class Test {
|
|||||||
count(./CastExpression)=0 and
|
count(./CastExpression)=0 and
|
||||||
count(./EqualityExpression)=0]
|
count(./EqualityExpression)=0]
|
||||||
|
|
|
|
||||||
//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
|
count(*)=1 and
|
||||||
not(./CastExpression) and
|
not(./CastExpression) and
|
||||||
not(./AdditiveExpression[@Image = '-']) and
|
not(./AdditiveExpression[@Image = '-']) and
|
||||||
@ -263,6 +265,7 @@ public class Test {
|
|||||||
count(./AndExpression)=0 and
|
count(./AndExpression)=0 and
|
||||||
count(./InclusiveOrExpression)=0 and
|
count(./InclusiveOrExpression)=0 and
|
||||||
count(./ExclusiveOrExpression)=0 and
|
count(./ExclusiveOrExpression)=0 and
|
||||||
|
count(./ConditionalExpression)=0 and
|
||||||
count(./ConditionalAndExpression)=0 and
|
count(./ConditionalAndExpression)=0 and
|
||||||
count(./ConditionalOrExpression)=0 and
|
count(./ConditionalOrExpression)=0 and
|
||||||
count(./EqualityExpression)=0]
|
count(./EqualityExpression)=0]
|
||||||
@ -339,4 +342,4 @@ public class Foo {
|
|||||||
</example>
|
</example>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.java.rule.unnecessary;
|
|||||||
import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
|
import net.sourceforge.pmd.testframework.SimpleAggregatorTst;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rule tests for the runnecessary ruleset
|
* Rule tests for the unnecessary ruleset
|
||||||
*/
|
*/
|
||||||
public class UnnecessaryRulesTest extends SimpleAggregatorTst {
|
public class UnnecessaryRulesTest extends SimpleAggregatorTst {
|
||||||
|
|
||||||
|
@ -324,6 +324,49 @@ public class Useless {
|
|||||||
// now without the outer parenthesis - no additional violation.
|
// now without the outer parenthesis - no additional violation.
|
||||||
boolean isSkipped3 = pokeNick.equals(pokemon.getNickname()) && renameResult.getNumber() == NicknamePokemonResponse.Result.UNSET_VALUE;
|
boolean isSkipped3 = pokeNick.equals(pokemon.getNickname()) && renameResult.getNumber() == NicknamePokemonResponse.Result.UNSET_VALUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>#199 UselessParentheses false positive on multiple logical and operators</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Useless {
|
||||||
|
public boolean test(Useless team) {
|
||||||
|
return (mNumber != null ? mNumber.equals(team.mNumber) : team.mNumber == null)
|
||||||
|
&& (mKey != null ? mKey.equals(team.mKey) : team.mKey == null)
|
||||||
|
&& (mTemplateKey != null ? mTemplateKey.equals(team.mTemplateKey) : team.mTemplateKey == null)
|
||||||
|
&& (mName != null ? mName.equals(team.mName) : team.mName == null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>#199 UselessParentheses false positive on multiple logical or operators</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Useless {
|
||||||
|
public boolean test(Useless team) {
|
||||||
|
return (mNumber != null ? mNumber.equals(team.mNumber) : team.mNumber == null)
|
||||||
|
|| (mKey != null ? mKey.equals(team.mKey) : team.mKey == null)
|
||||||
|
|| (mTemplateKey != null ? mTemplateKey.equals(team.mTemplateKey) : team.mTemplateKey == null)
|
||||||
|
|| (mName != null ? mName.equals(team.mName) : team.mName == null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>#199 UselessParentheses false positive on equals operator</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Useless {
|
||||||
|
public boolean test(Useless team) {
|
||||||
|
return (mNumber != null ? mNumber : team.mNumber)
|
||||||
|
== (mKey != null ? mKey : team.mKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
@ -206,6 +206,8 @@ See also [bugfix #1556](https://sourceforge.net/p/pmd/bugs/1556/).
|
|||||||
* java-logging-java
|
* java-logging-java
|
||||||
* [#1541](https://sourceforge.net/p/pmd/bugs/1541/): \[java] InvalidSlf4jMessageFormat: False positive with placeholder and exception
|
* [#1541](https://sourceforge.net/p/pmd/bugs/1541/): \[java] InvalidSlf4jMessageFormat: False positive with placeholder and exception
|
||||||
* [#1551](https://sourceforge.net/p/pmd/bugs/1551/): \[java] InvalidSlf4jMessageFormat: fails with NPE
|
* [#1551](https://sourceforge.net/p/pmd/bugs/1551/): \[java] InvalidSlf4jMessageFormat: fails with NPE
|
||||||
|
* java-unnecessary
|
||||||
|
* [#199](https://github.com/pmd/pmd/issues/199): \[java] UselessParentheses: Parentheses in return statement are incorrectly reported as useless
|
||||||
* XML
|
* XML
|
||||||
* [#1518](https://sourceforge.net/p/pmd/bugs/1518/): \[xml] Error while processing xml file with ".webapp" in the file or directory name
|
* [#1518](https://sourceforge.net/p/pmd/bugs/1518/): \[xml] Error while processing xml file with ".webapp" in the file or directory name
|
||||||
* psql
|
* psql
|
||||||
|
Reference in New Issue
Block a user