Now it scans all files in all source directories with the unusedcode ruleset
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1739 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -9,6 +9,6 @@ set CLASSPATH=%CLASSPATH%;../test-data/
|
||||
set CLASSPATH=%CLASSPATH%;../
|
||||
set CLASSPATH=%CLASSPATH%;../lib/xercesImpl-2.0.2.jar
|
||||
set CLASSPATH=%CLASSPATH%;../lib/xmlParserAPIs-2.0.2.jar
|
||||
set CLASSPATH=%CLASSPATH%;c:\javacc2.1\bin\lib\JavaCC.zip
|
||||
set CLASSPATH=%CLASSPATH%;../lib/plugin.jar
|
||||
set CLASSPATH=%CLASSPATH%;c:\ant\lib\ant.jar
|
||||
set CLASSPATH=%CLASSPATH%;c:\ant\lib\junit.jar
|
||||
|
@ -9,21 +9,20 @@
|
||||
<PROPERTY Name="OpenFiles">
|
||||
<CLASS Type="TFiles">
|
||||
<PROPERTY Name="CurrentIndex">0</PROPERTY>
|
||||
<PROPERTY Name="LastFileName">C:\pmd\pmd-gel\etc\build.xml</PROPERTY>
|
||||
<CLASS Type="TFile">
|
||||
<PROPERTY Name="CaretLeft">1</PROPERTY>
|
||||
<PROPERTY Name="CaretTop">19</PROPERTY>
|
||||
<PROPERTY Name="CaretLeft">68</PROPERTY>
|
||||
<PROPERTY Name="CaretTop">43</PROPERTY>
|
||||
<PROPERTY Name="FileName">$(PROJECT)\src\net\sourceforge\pmd\gel\PMDPlugin.java</PROPERTY>
|
||||
<PROPERTY Name="WindowLeft">1</PROPERTY>
|
||||
<PROPERTY Name="WindowTop">9</PROPERTY>
|
||||
<PROPERTY Name="WindowTop">25</PROPERTY>
|
||||
</CLASS>
|
||||
<CLASS Type="TFile">
|
||||
<PROPERTY Name="ProjectID">{C34B000D-B5C9-415F-933A-552FB0590E44}</PROPERTY>
|
||||
<PROPERTY Name="CaretLeft">35</PROPERTY>
|
||||
<PROPERTY Name="CaretTop">32</PROPERTY>
|
||||
<PROPERTY Name="CaretLeft">36</PROPERTY>
|
||||
<PROPERTY Name="CaretTop">40</PROPERTY>
|
||||
<PROPERTY Name="FileName">$(PROJECT)\etc\build.xml</PROPERTY>
|
||||
<PROPERTY Name="WindowLeft">1</PROPERTY>
|
||||
<PROPERTY Name="WindowTop">20</PROPERTY>
|
||||
<PROPERTY Name="WindowTop">4</PROPERTY>
|
||||
</CLASS>
|
||||
<CLASS Type="TFile">
|
||||
<PROPERTY Name="ProjectID">{C34B000D-B5C9-415F-933A-552FB0590E44}</PROPERTY>
|
||||
@ -33,6 +32,30 @@
|
||||
<PROPERTY Name="WindowLeft">1</PROPERTY>
|
||||
<PROPERTY Name="WindowTop">1</PROPERTY>
|
||||
</CLASS>
|
||||
<CLASS Type="TFile">
|
||||
<PROPERTY Name="ProjectID">{C34B000D-B5C9-415F-933A-552FB0590E44}</PROPERTY>
|
||||
<PROPERTY Name="CaretLeft">18</PROPERTY>
|
||||
<PROPERTY Name="CaretTop">22</PROPERTY>
|
||||
<PROPERTY Name="FileName">C:\Gel\plugin\src\com\gexperts\gel\Editor.java</PROPERTY>
|
||||
<PROPERTY Name="WindowLeft">1</PROPERTY>
|
||||
<PROPERTY Name="WindowTop">4</PROPERTY>
|
||||
</CLASS>
|
||||
<CLASS Type="TFile">
|
||||
<PROPERTY Name="ProjectID">{C34B000D-B5C9-415F-933A-552FB0590E44}</PROPERTY>
|
||||
<PROPERTY Name="CaretLeft">1</PROPERTY>
|
||||
<PROPERTY Name="CaretTop">1</PROPERTY>
|
||||
<PROPERTY Name="FileName">C:\Gel\plugin\src\com\gexperts\gel\Gel.java</PROPERTY>
|
||||
<PROPERTY Name="WindowLeft">1</PROPERTY>
|
||||
<PROPERTY Name="WindowTop">4</PROPERTY>
|
||||
</CLASS>
|
||||
<CLASS Type="TFile">
|
||||
<PROPERTY Name="ProjectID">{C34B000D-B5C9-415F-933A-552FB0590E44}</PROPERTY>
|
||||
<PROPERTY Name="CaretLeft">25</PROPERTY>
|
||||
<PROPERTY Name="CaretTop">13</PROPERTY>
|
||||
<PROPERTY Name="FileName">C:\Gel\plugin\src\com\gexperts\gel\Project.java</PROPERTY>
|
||||
<PROPERTY Name="WindowLeft">1</PROPERTY>
|
||||
<PROPERTY Name="WindowTop">40</PROPERTY>
|
||||
</CLASS>
|
||||
</CLASS>
|
||||
</PROPERTY>
|
||||
<PROPERTY Name="ID">{C34B000D-B5C9-415F-933A-552FB0590E44}</PROPERTY>
|
||||
@ -93,4 +116,13 @@
|
||||
</CLASS>
|
||||
</PROPERTY>
|
||||
</CLASS>
|
||||
<CLASS Type="TFileNode">
|
||||
<PROPERTY Name="Name">Test.java</PROPERTY>
|
||||
<PROPERTY Name="FileName">$(PROJECT)\src\net\sourceforge\pmd\gel\Test.java</PROPERTY>
|
||||
<PROPERTY Name="Managed">0</PROPERTY>
|
||||
<PROPERTY Name="Marks">
|
||||
<CLASS Type="TMarks">
|
||||
</CLASS>
|
||||
</PROPERTY>
|
||||
</CLASS>
|
||||
</CLASS>
|
@ -5,6 +5,7 @@ import java.io.*;
|
||||
import javax.swing.*;
|
||||
import com.gexperts.gel.*;
|
||||
import net.sourceforge.pmd.*;
|
||||
import net.sourceforge.pmd.cpd.*;
|
||||
|
||||
public class PMDPlugin implements GelAction {
|
||||
|
||||
@ -16,24 +17,32 @@ public class PMDPlugin implements GelAction {
|
||||
|
||||
public void perform(Gel p0) {
|
||||
try {
|
||||
int x =2;
|
||||
PMD pmd = new PMD();
|
||||
RuleContext ctx = new RuleContext();
|
||||
RuleSetFactory rsf = new RuleSetFactory();
|
||||
RuleSet ruleSet = new RuleSet();
|
||||
ruleSet.addRuleSet(rsf.createRuleSet("rulesets/unusedcode.xml"));
|
||||
ruleSet.addRuleSet(rsf.createRuleSet("rulesets/basic.xml"));
|
||||
ctx.setReport(new Report());
|
||||
ctx.setSourceCodeFilename(p0.getEditor().getFileName());
|
||||
StringReader reader = new StringReader(p0.getEditor().getContents());
|
||||
pmd.processFile(reader, ruleSet, ctx);
|
||||
if (ctx.getReport().isEmpty()) {
|
||||
JOptionPane.showMessageDialog(null, "No problems found", "PMD", JOptionPane.INFORMATION_MESSAGE);
|
||||
} else {
|
||||
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
|
||||
RuleViolation rv = (RuleViolation)i.next();
|
||||
JOptionPane.showMessageDialog(null, (rv.getLine()-1) + ":" + rv.getDescription(), "PMD", JOptionPane.INFORMATION_MESSAGE);
|
||||
for (Iterator iter = p0.getProject().getSourcePaths().iterator(); iter.hasNext();) {
|
||||
String srcDir = (String)iter.next();
|
||||
FileFinder ff = new FileFinder();
|
||||
List files = ff.findFilesFrom(srcDir, new JavaFileOrDirectoryFilter(), true);
|
||||
for (Iterator fileIter = files.iterator(); fileIter.hasNext();) {
|
||||
File fileName = (File)fileIter.next();
|
||||
ctx.setSourceCodeFilename(fileName.getAbsolutePath());
|
||||
Reader reader = new FileReader(fileName);
|
||||
pmd.processFile(reader, ruleSet, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ctx.getReport().isEmpty()) {
|
||||
JOptionPane.showMessageDialog(null, "No problems found", "PMD", JOptionPane.INFORMATION_MESSAGE);
|
||||
} else {
|
||||
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
|
||||
RuleViolation rv = (RuleViolation)i.next();
|
||||
p0.showMessage("File: " + rv.getFilename() + "\r\nLine: " + (rv.getLine()-1) + "\r\nProblem: " + rv.getDescription());
|
||||
}
|
||||
}
|
||||
} catch (Exception rsne) {
|
||||
JOptionPane.showMessageDialog(null, "ERROR" + rsne.getMessage());
|
||||
rsne.printStackTrace();
|
||||
|
5
pmd-gel/src/net/sourceforge/pmd/gel/Test.java
Normal file
5
pmd-gel/src/net/sourceforge/pmd/gel/Test.java
Normal file
@ -0,0 +1,5 @@
|
||||
package net.sourceforge.pmd.gel;
|
||||
|
||||
public class Test {
|
||||
private int y;
|
||||
}
|
Reference in New Issue
Block a user