forked from phoedos/pmd
fixed bug
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@638 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -38,11 +38,11 @@
|
||||
|
||||
<target name="pmd">
|
||||
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"/>
|
||||
<pmd reportFile="c:\pmd.html" rulesetfiles="rulesets/basic.xml,rulesets/unusedcode.xml,rulesets/imports.xml,rulesets/design.xml" format="html">
|
||||
<fileset dir="c:\data\pmd\pmd\src">
|
||||
<pmd reportFile="c:\pmd.html" rulesetfiles="rulesets/unusedcode.xml" format="html">
|
||||
<fileset dir="c:\data\pmd\pmd\src\net\sourceforge\pmd">
|
||||
<!-- <fileset dir="c:\j2sdk1.4.0_01\src\com\sun\corba\se">-->
|
||||
<!--<fileset dir="c:\j2sdk1.4.0_01\src\">-->
|
||||
<include name="**/*.java"/>
|
||||
<include name="PMD.java"/>
|
||||
<exclude name="**/ast**/"/>
|
||||
</fileset>
|
||||
</pmd>
|
||||
|
@ -1,5 +1,6 @@
|
||||
???? 2002 - 0.9:
|
||||
Added rule customization via XML parameters
|
||||
Fixed bug 592060 - Unused private instance variables handles explicitly referenced statics correctly
|
||||
|
||||
July 30 2002 - 0.8:
|
||||
Added new rule: UnusedFormalParameterRule
|
||||
|
@ -2,4 +2,4 @@
|
||||
set MAIN=net.sourceforge.pmd.PMD
|
||||
set TEST_FILE=c:\\data\\pmd\\pmd\\test-data\\%1%.java
|
||||
|
||||
java %MAIN% %TEST_FILE% xml rulesets\newrules.xml
|
||||
java %MAIN% %TEST_FILE% xml rulesets\unusedcode.xml
|
||||
|
@ -86,4 +86,9 @@ public class UnusedPrivateInstanceVariableRuleTest extends RuleTst {
|
||||
Report report = process("UnusedPrivateInstanceVar12.java", rule);
|
||||
assertTrue(report.isEmpty());
|
||||
}
|
||||
|
||||
public void test13() throws Throwable {
|
||||
Report report = process("UnusedPrivateInstanceVar13.java", rule);
|
||||
assertTrue(report.isEmpty());
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ public class UnusedPrivateInstanceVariableRule extends AbstractRule {
|
||||
|
||||
public Object visit(ASTClassBody node, Object data) {
|
||||
depth++;
|
||||
|
||||
// first troll for declarations, but only in the top level class
|
||||
if (depth == 1) {
|
||||
trollingForDeclarations = true;
|
||||
@ -101,8 +100,10 @@ public class UnusedPrivateInstanceVariableRule extends AbstractRule {
|
||||
|
||||
private void recordPossibleUsage(SimpleNode node) {
|
||||
String img = (node.getImage().indexOf('.') == -1) ? node.getImage() : node.getImage().substring(0, node.getImage().indexOf('.'));
|
||||
String otherImg = (node.getImage().indexOf('.') == -1) ? node.getImage() : node.getImage().substring(node.getImage().indexOf('.')+1);
|
||||
Namespace group = (Namespace)nameSpaces.peek();
|
||||
group.peek().recordPossibleUsageOf(new Symbol(img, node.getBeginLine()));
|
||||
group.peek().recordPossibleUsageOf(new Symbol(otherImg, node.getBeginLine()));
|
||||
}
|
||||
|
||||
private void harvestUnused(RuleContext ctx, SymbolTable table) {
|
||||
|
6
pmd/test-data/UnusedPrivateInstanceVar13.java
Normal file
6
pmd/test-data/UnusedPrivateInstanceVar13.java
Normal file
@ -0,0 +1,6 @@
|
||||
public class UnusedPrivateInstanceVar13 {
|
||||
private static final int BAR = 2;
|
||||
public void buz() {
|
||||
int x = UnusedPrivateInstanceVar13.BAR;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user