Merge branch 'bug-1476'
This commit is contained in:
@ -117,8 +117,17 @@ public abstract class AbstractSunSecureRule extends AbstractJavaRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the image of the first ASTName node found by
|
* Gets the image of the ASTName node found by
|
||||||
* {@link Node#getFirstDescendantOfType(Class)}
|
* {@link Node#getFirstDescendantOfType(Class)}
|
||||||
|
* if it is the greatgrandchild of the given node.
|
||||||
|
*
|
||||||
|
* E.g.
|
||||||
|
* <pre>
|
||||||
|
* n = Expression || StatementExpression
|
||||||
|
* PrimaryExpression
|
||||||
|
* PrimaryPrefix
|
||||||
|
* Name
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param n
|
* @param n
|
||||||
* the node to search
|
* the node to search
|
||||||
@ -126,7 +135,7 @@ public abstract class AbstractSunSecureRule extends AbstractJavaRule {
|
|||||||
*/
|
*/
|
||||||
protected String getFirstNameImage(Node n) {
|
protected String getFirstNameImage(Node n) {
|
||||||
ASTName name = n.getFirstDescendantOfType(ASTName.class);
|
ASTName name = n.getFirstDescendantOfType(ASTName.class);
|
||||||
if (name != null) {
|
if (name != null && name.getNthParent(3) == n) {
|
||||||
return name.getImage();
|
return name.getImage();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -98,12 +98,12 @@ public class ArrayIsStoredDirectlyRule extends AbstractSunSecureRule {
|
|||||||
if (se == null || !(se.jjtGetChild(0) instanceof ASTPrimaryExpression)) {
|
if (se == null || !(se.jjtGetChild(0) instanceof ASTPrimaryExpression)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ASTPrimaryExpression pe = (ASTPrimaryExpression) se.jjtGetChild(0);
|
String assignedVar = getExpressionVarName(se);
|
||||||
String assignedVar = getExpressionVarName(pe);
|
|
||||||
if (assignedVar == null) {
|
if (assignedVar == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASTPrimaryExpression pe = (ASTPrimaryExpression) se.jjtGetChild(0);
|
||||||
Node n = pe.getFirstParentOfType(ASTMethodDeclaration.class);
|
Node n = pe.getFirstParentOfType(ASTMethodDeclaration.class);
|
||||||
if (n == null) {
|
if (n == null) {
|
||||||
n = pe.getFirstParentOfType(ASTConstructorDeclaration.class);
|
n = pe.getFirstParentOfType(ASTConstructorDeclaration.class);
|
||||||
|
@ -150,6 +150,31 @@ public class TestClass {
|
|||||||
this.obj = Arrays.copyOf(obj, obj.length);
|
this.obj = Arrays.copyOf(obj, obj.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>#1476 False positive of ArrayIsStoredDirectly</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class NotificationPacket {
|
||||||
|
public NotificationPacket(byte id, byte[] rawTypeData)
|
||||||
|
{
|
||||||
|
super(id);
|
||||||
|
if (rawTypeData == null)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("No type data is specified");
|
||||||
|
}
|
||||||
|
if (rawTypeData.length == 0)
|
||||||
|
{
|
||||||
|
this.message = EMPTY_MESSAGE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.message = new String(rawTypeData, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
@ -102,6 +102,8 @@ you'll need a java8 runtime environment.
|
|||||||
* [#1443](https://sourceforge.net/p/pmd/bugs/1443/): RedundantFieldInitializer: False positive for small floats
|
* [#1443](https://sourceforge.net/p/pmd/bugs/1443/): RedundantFieldInitializer: False positive for small floats
|
||||||
* java-optimizations/UseStringBufferForStringAppends:
|
* java-optimizations/UseStringBufferForStringAppends:
|
||||||
* [#1340](https://sourceforge.net/p/pmd/bugs/1340/): UseStringBufferForStringAppends False Positive with ternary operator
|
* [#1340](https://sourceforge.net/p/pmd/bugs/1340/): UseStringBufferForStringAppends False Positive with ternary operator
|
||||||
|
* java-sunsecure/ArrayIsStoredDirectly:
|
||||||
|
* [#1476](https://sourceforge.net/p/pmd/bugs/1476/): False positive of ArrayIsStoredDirectly
|
||||||
* java-unnecessary/UnnecessaryFinalModifier:
|
* java-unnecessary/UnnecessaryFinalModifier:
|
||||||
* [#1464](https://sourceforge.net/p/pmd/bugs/1464/): UnnecessaryFinalModifier false positive on a @SafeVarargs method
|
* [#1464](https://sourceforge.net/p/pmd/bugs/1464/): UnnecessaryFinalModifier false positive on a @SafeVarargs method
|
||||||
* java-unnecessary/UselessQualifiedThis
|
* java-unnecessary/UselessQualifiedThis
|
||||||
|
Reference in New Issue
Block a user