Merge branch 'pmd/5.3.x' into master
This commit is contained in:
@ -90,7 +90,9 @@ public class ConsecutiveLiteralAppendsRule extends AbstractJavaRule {
|
|||||||
threshold = getProperty(THRESHOLD_DESCRIPTOR);
|
threshold = getProperty(THRESHOLD_DESCRIPTOR);
|
||||||
|
|
||||||
int concurrentCount = checkConstructor(node, data);
|
int concurrentCount = checkConstructor(node, data);
|
||||||
|
if (hasInitializer(node)) {
|
||||||
concurrentCount += checkInitializerExpressions(node);
|
concurrentCount += checkInitializerExpressions(node);
|
||||||
|
}
|
||||||
Node lastBlock = getFirstParentBlock(node);
|
Node lastBlock = getFirstParentBlock(node);
|
||||||
Node currentBlock = lastBlock;
|
Node currentBlock = lastBlock;
|
||||||
Map<VariableNameDeclaration, List<NameOccurrence>> decls = node.getScope().getDeclarations(
|
Map<VariableNameDeclaration, List<NameOccurrence>> decls = node.getScope().getDeclarations(
|
||||||
@ -219,6 +221,10 @@ public class ConsecutiveLiteralAppendsRule extends AbstractJavaRule {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasInitializer(ASTVariableDeclaratorId node) {
|
||||||
|
return node.jjtGetParent().hasDescendantOfType(ASTVariableInitializer.class);
|
||||||
|
}
|
||||||
|
|
||||||
private int processAdditive(Object data, int concurrentCount, Node sn, Node rootNode) {
|
private int processAdditive(Object data, int concurrentCount, Node sn, Node rootNode) {
|
||||||
ASTAdditiveExpression additive = sn.getFirstDescendantOfType(ASTAdditiveExpression.class);
|
ASTAdditiveExpression additive = sn.getFirstDescendantOfType(ASTAdditiveExpression.class);
|
||||||
// The additive expression must of be type String to count
|
// The additive expression must of be type String to count
|
||||||
|
@ -1262,6 +1262,26 @@ public class StringBufferTest {
|
|||||||
stringBuffer2.append("string ");
|
stringBuffer2.append("string ");
|
||||||
Log.i(TAG, stringBuffer2.toString());
|
Log.i(TAG, stringBuffer2.toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description>#1384 NullPointerException in ConsecutiveLiteralAppendsRule - 1</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class ConsecutiveLiteralAppendsRuleTest {
|
||||||
|
private StringBuilder cdata;
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description>#1384 NullPointerException in ConsecutiveLiteralAppendsRule - 2</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class ConsecutiveLiteralAppendsRuleTest {
|
||||||
|
public void appendChar(final StringBuilder s) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
|
|
||||||
* [#1370](https://sourceforge.net/p/pmd/bugs/1370/): ConsecutiveAppendsShouldReuse not detected properly on StringBuffer
|
* [#1370](https://sourceforge.net/p/pmd/bugs/1370/): ConsecutiveAppendsShouldReuse not detected properly on StringBuffer
|
||||||
* [#1371](https://sourceforge.net/p/pmd/bugs/1371/): InsufficientStringBufferDeclaration not detected properly on StringBuffer
|
* [#1371](https://sourceforge.net/p/pmd/bugs/1371/): InsufficientStringBufferDeclaration not detected properly on StringBuffer
|
||||||
|
* [#1384](https://sourceforge.net/p/pmd/bugs/1384/): NullPointerException in ConsecutiveLiteralAppendsRule
|
||||||
* [#1402](https://sourceforge.net/p/pmd/bugs/1402/): Windows-Only: File exclusions are not case insensitive
|
* [#1402](https://sourceforge.net/p/pmd/bugs/1402/): Windows-Only: File exclusions are not case insensitive
|
||||||
|
|
||||||
**API Changes:**
|
**API Changes:**
|
||||||
|
Reference in New Issue
Block a user