forked from phoedos/pmd
Fixed bug 1989814 - false +: ConsecutiveLiteralAppends
If the definitive type of an AdditiveExpression is known to be other than a String, don't complain. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6186 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
Fixes for exclude-pattern
|
Fixes for exclude-pattern
|
||||||
Updates to RuleChain to honor RuleSet exclude-pattern
|
Updates to RuleChain to honor RuleSet exclude-pattern
|
||||||
Fixed bug 1988829 - Violation reported without source file name (actually a fix to ConsecutiveLiteralAppends)
|
Fixed bug 1988829 - Violation reported without source file name (actually a fix to ConsecutiveLiteralAppends)
|
||||||
|
Fixed bug 1989814 - false +: ConsecutiveLiteralAppends
|
||||||
|
|
||||||
May 20, 2008 - 4.2.2:
|
May 20, 2008 - 4.2.2:
|
||||||
|
|
||||||
|
@ -796,6 +796,23 @@ public class Foo {
|
|||||||
sb.append('c');
|
sb.append('c');
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description><![CDATA[
|
||||||
|
44, Appending of not String additive expressions
|
||||||
|
]]></description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
public void foo(int i) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append("Hello");
|
||||||
|
sb.append(i + 1);
|
||||||
|
sb.append(1 + i);
|
||||||
|
sb.append("World");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
@ -179,7 +179,8 @@ public class ConsecutiveLiteralAppends extends AbstractRule {
|
|||||||
private int processAdditive(Object data, int concurrentCount,
|
private int processAdditive(Object data, int concurrentCount,
|
||||||
SimpleNode sn, SimpleNode rootNode) {
|
SimpleNode sn, SimpleNode rootNode) {
|
||||||
ASTAdditiveExpression additive = sn.getFirstChildOfType(ASTAdditiveExpression.class);
|
ASTAdditiveExpression additive = sn.getFirstChildOfType(ASTAdditiveExpression.class);
|
||||||
if (additive == null) {
|
// The additive expression must of be type String to count
|
||||||
|
if (additive == null || (additive.getType() != null && !TypeHelper.isA(additive, String.class))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int count = concurrentCount;
|
int count = concurrentCount;
|
||||||
|
Reference in New Issue
Block a user