Fixed bug in PMD and CPD where entire project was not being checked because only the highest level package was being examined for
java files. Now all descendent packages are being checked as well. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@825 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -26,9 +26,9 @@ debug.NoTracingClasses.7[0]=17 com.borland.sql.*1 1 -1
|
||||
debug.NoTracingClasses.8[0]=9 com.sun.*1 1 -1
|
||||
debug.NoTracingClasses.9[0]=6 java.*1 1 -1
|
||||
editor.search.file_filter_history.1[0]=*.java
|
||||
history.files.active[0]=src/net/sourceforge/pmd/jbuilder/CPDDialog.java
|
||||
history.files.active[0]=src/net/sourceforge/pmd/jbuilder/PMDOpenTool.java
|
||||
history.files.open.1[0]=src/net/sourceforge/pmd/jbuilder/CPDDialog.java,F;68,2295
|
||||
history.files.open.2[0]=src/net/sourceforge/pmd/jbuilder/PMDOpenTool.java,F;339,16263
|
||||
history.files.open.2[0]=src/net/sourceforge/pmd/jbuilder/PMDOpenTool.java,F;348,15146
|
||||
import.optimize.packageprefixgroupings.1[0]=java
|
||||
import.optimize.packageprefixgroupings.2[0]=<blank line>
|
||||
import.optimize.packageprefixgroupings.3[0]=javax
|
||||
|
Binary file not shown.
@ -302,6 +302,35 @@ public class PMDOpenTool {
|
||||
}
|
||||
}
|
||||
|
||||
private static void pmdCheckPackage(PackageNode packageNode, RuleSet rules) {
|
||||
Node[] fileNodes = packageNode.getDisplayChildren();
|
||||
for (int j=0; j<fileNodes.length; j++) {
|
||||
if (fileNodes[j] instanceof JavaFileNode) {
|
||||
Message fileNameMsg = new Message(fileNodes[j].getDisplayName());
|
||||
fileNameMsg.setFont(fileNameMsgFont);
|
||||
Browser.getActiveBrowser().getMessageView().addMessage(msgCat, fileNameMsg);
|
||||
JavaFileNode javaNode = (JavaFileNode)fileNodes[j];
|
||||
StringBuffer code = new StringBuffer();
|
||||
try {
|
||||
byte[] buffer = new byte[1024];
|
||||
InputStream is = javaNode.getInputStream();
|
||||
int charCount;
|
||||
while ((charCount = is.read(buffer)) != -1) {
|
||||
code.append(new String(buffer, 0, charCount));
|
||||
}
|
||||
checkCode(code.toString(), javaNode, rules);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (fileNodes[j] instanceof PackageNode) {
|
||||
pmdCheckPackage((PackageNode)fileNodes[j], rules); //recursive call
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void pmdCheckProject() {
|
||||
Node[] nodes = Browser.getActiveBrowser().getActiveProject().getDisplayChildren();
|
||||
Browser.getActiveBrowser().getMessageView().clearMessages(msgCat); //clear the message window
|
||||
@ -309,28 +338,23 @@ public class PMDOpenTool {
|
||||
for (int i=0; i<nodes.length; i++ ) {
|
||||
if (nodes[i] instanceof PackageNode) {
|
||||
PackageNode node = (PackageNode)nodes[i];
|
||||
Node[] fileNodes = node.getDisplayChildren();
|
||||
for (int j=0; j<fileNodes.length; j++) {
|
||||
if (fileNodes[j] instanceof JavaFileNode) {
|
||||
Message fileNameMsg = new Message(fileNodes[j].getDisplayName());
|
||||
fileNameMsg.setFont(fileNameMsgFont);
|
||||
Browser.getActiveBrowser().getMessageView().addMessage(msgCat, fileNameMsg);
|
||||
JavaFileNode javaNode = (JavaFileNode)fileNodes[j];
|
||||
StringBuffer code = new StringBuffer();
|
||||
try {
|
||||
byte[] buffer = new byte[1024];
|
||||
InputStream is = javaNode.getInputStream();
|
||||
int charCount;
|
||||
while ((charCount = is.read(buffer)) != -1) {
|
||||
code.append(new String(buffer, 0, charCount));
|
||||
}
|
||||
checkCode(code.toString(), javaNode, rules);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
pmdCheckPackage(node, rules);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void pmdCPDPackage(PackageNode packageNode, CPD cpd) {
|
||||
Node[] fileNodes = packageNode.getDisplayChildren();
|
||||
for (int j=0; j<fileNodes.length; j++) {
|
||||
if (fileNodes[j] instanceof JavaFileNode) {
|
||||
try {
|
||||
cpd.add(new File(fileNodes[j].getLongDisplayName()));
|
||||
}
|
||||
catch (Exception e){
|
||||
}
|
||||
}
|
||||
else if (fileNodes[j] instanceof PackageNode) {
|
||||
pmdCPDPackage((PackageNode)fileNodes[j], cpd); //recursive call
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -345,16 +369,7 @@ public class PMDOpenTool {
|
||||
for (int i=0; i<nodes.length; i++ ) {
|
||||
if (nodes[i] instanceof PackageNode) {
|
||||
PackageNode node = (PackageNode)nodes[i];
|
||||
Node[] fileNodes = node.getDisplayChildren();
|
||||
for (int j=0; j<fileNodes.length; j++) {
|
||||
if (fileNodes[j] instanceof JavaFileNode) {
|
||||
try {
|
||||
cpd.add(new File(fileNodes[j].getLongDisplayName()));
|
||||
}
|
||||
catch (Exception e){
|
||||
}
|
||||
}
|
||||
}
|
||||
pmdCPDPackage(node, cpd);
|
||||
}
|
||||
}
|
||||
cpd.go();
|
||||
|
Reference in New Issue
Block a user