forked from phoedos/pmd
pmd: fixed bug #1012 False positive: Useless parentheses.
This commit is contained in:
parent
7989ae1863
commit
ac8e3314a3
@ -1,5 +1,6 @@
|
||||
???? ??, 2012 - 5.0.2:
|
||||
|
||||
Fixed bug 1012: False positive: Useless parentheses.
|
||||
Fixed bug 1026: PMD doesn't handle 'value =' in SuppressWarnings annotation
|
||||
Fixed bug 1037: Facing a showstopper issue in PMD Report Class (report listeners)
|
||||
Fixed bug 1043: node.getEndLine() always returns 0 (ECMAscript)
|
||||
|
@ -225,7 +225,8 @@ public class Test {
|
||||
//Expression/ConditionalAndExpression/PrimaryExpression/PrimaryPrefix/Expression[
|
||||
count(*)=1 and
|
||||
count(./CastExpression)=0 and
|
||||
count(./EqualityExpression/MultiplicativeExpression)=0]
|
||||
count(./EqualityExpression/MultiplicativeExpression)=0 and
|
||||
count(./ConditionalOrExpression)=0]
|
||||
|
|
||||
//Expression/ConditionalOrExpression/PrimaryExpression/PrimaryPrefix/Expression[
|
||||
count(*)=1 and
|
||||
@ -237,7 +238,10 @@ public class Test {
|
||||
count(./CastExpression)=0 and
|
||||
count(./EqualityExpression)=0]
|
||||
|
|
||||
//Expression/AdditiveExpression/PrimaryExpression/PrimaryPrefix/Expression[count(*)=1 and not(./CastExpression) and not(./ConditionalExpression)]
|
||||
//Expression/AdditiveExpression[not(./PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral = 'true'])]/PrimaryExpression/PrimaryPrefix/Expression[
|
||||
count(*)=1 and
|
||||
not(./CastExpression) and
|
||||
not(./ConditionalExpression)]
|
||||
|
|
||||
//Expression/EqualityExpression/PrimaryExpression/PrimaryPrefix/Expression[
|
||||
count(*)=1 and
|
||||
|
@ -20,7 +20,7 @@ public class UnnecessaryRulesTest extends SimpleAggregatorTst {
|
||||
addRule(RULESET, "UnusedNullCheckInEquals");
|
||||
addRule(RULESET, "UselessOverridingMethod");
|
||||
addRule(RULESET, "UselessOperationOnImmutable");
|
||||
addRule(RULESET, "UselessParentheses");
|
||||
addRule(RULESET, "UselessParentheses");
|
||||
}
|
||||
|
||||
public static junit.framework.Test suite() {
|
||||
|
@ -177,6 +177,22 @@ public class Test {
|
||||
int dayCount = 4;
|
||||
String description = dayCount + " " + (dayCount == 1 ? oneDay : moreDays);
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>#1012 False positive: Useless parentheses.</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Test {
|
||||
public void testMethod() {
|
||||
if((lookahead.type == Keyword.STRING || lookahead.type == Keyword.NUMBER) && lookahead.type != baseType)
|
||||
throw new IncompatibleAttributeTypeException(attribute);
|
||||
System.out.println( "number " + ( 1 + 2 ) );
|
||||
|
||||
if(lookahead.type != baseType && (lookahead.type == Keyword.STRING || lookahead.type == Keyword.NUMBER))
|
||||
throw new IncompatibleAttributeTypeException(attribute);
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Loading…
x
Reference in New Issue
Block a user