From 6b69174e24ddff3ca41e409a8176af905eb3713d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 17 Jan 2015 22:42:58 +0100 Subject: [PATCH] #1296 PMD UnusedPrivateMethod invalid detection of 'private void method(int,boolean,Integer...)' --- .../sourceforge/pmd/lang/java/symboltable/ClassScope.java | 3 +++ .../lang/java/rule/unusedcode/xml/UnusedPrivateMethod.xml | 5 +++++ src/site/markdown/overview/changelog.md | 1 + 3 files changed, 9 insertions(+) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ClassScope.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ClassScope.java index 96c4930c5c..95ffbade47 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ClassScope.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ClassScope.java @@ -10,6 +10,7 @@ import java.util.Map; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAllocationExpression; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; +import net.sourceforge.pmd.lang.java.ast.ASTBooleanLiteral; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBodyDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType; @@ -323,6 +324,8 @@ public class ClassScope extends AbstractJavaScope { type = new SimpleTypedNameDeclaration("int", literal.getType()); } else if (literal.isLongLiteral()) { type = new SimpleTypedNameDeclaration("long", literal.getType()); + } else if (literal.jjtGetNumChildren() == 1 && literal.jjtGetChild(0) instanceof ASTBooleanLiteral) { + type = new SimpleTypedNameDeclaration("boolean", Boolean.TYPE); } } else if (child instanceof ASTAllocationExpression && child.jjtGetChild(0) instanceof ASTClassOrInterfaceType) { ASTClassOrInterfaceType classInterface = (ASTClassOrInterfaceType)child.jjtGetChild(0); diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/unusedcode/xml/UnusedPrivateMethod.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/unusedcode/xml/UnusedPrivateMethod.xml index 55ccc4f460..d90a123518 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/unusedcode/xml/UnusedPrivateMethod.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/unusedcode/xml/UnusedPrivateMethod.xml @@ -1401,6 +1401,11 @@ public class UnusedPrivateMethod { deleteAllAssetsWithExceptions(galleryId, false, exceptionList); } + public void deleteAllAssetsWithExceptions(int galleryId, Integer... exceptionList) throws MediaServiceException + { + deleteAllAssetsWithExceptions(galleryId, true, exceptionList); + } + private void deleteAllAssetsWithExceptions(int galleryId, boolean purge, Integer... exceptionList) throws MediaServiceException { } diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md index b58328472f..cdaacd7e74 100644 --- a/src/site/markdown/overview/changelog.md +++ b/src/site/markdown/overview/changelog.md @@ -10,5 +10,6 @@ **Bugfixes:** +* [#1296](https://sourceforge.net/p/pmd/bugs/1296/): PMD UnusedPrivateMethod invalid detection of 'private void method(int,boolean,Integer...)' * [#1298](https://sourceforge.net/p/pmd/bugs/1298/): Member variable int type with value 0xff000000 causes processing error * [#1299](https://sourceforge.net/p/pmd/bugs/1299/): MethodReturnsInternalArray false positive