Fixed bug 997893 - false positive in UnusedPrivateField
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2834 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -4,6 +4,7 @@ Moved development environment to Ant 1.6.2. This is nice because using the new
|
||||
Applied patch in RFE 992576 - Enhancements to VariableNamingConventionsRule
|
||||
Fixed bug in SimplifyBooleanExpressions - now it catches more cases.
|
||||
Fixed bugs in AvoidDuplicateLiterals - now it ignores small duplicate literals, its message is more helpful, and it catches more cases.
|
||||
Fixed bug 997893 - false positive in UnusedPrivateField
|
||||
MethodWithSameNameAsEnclosingClass now reports a more helpful line number.
|
||||
|
||||
July 14, 2004 - 1.9:
|
||||
|
@ -38,7 +38,7 @@ public class UnusedPrivateFieldRuleTest extends SimpleAggregatorTst {
|
||||
new TestDescriptor(TEST17, "instantiate self and reference private field on other object", 0, rule),
|
||||
new TestDescriptor(TEST18, "don't count Serialization fields as being unused", 0, rule),
|
||||
new TestDescriptor(TEST19, "an assignment does not a usage make", 1, rule),
|
||||
// new TestDescriptor(TEST20, "private field of inner class used by outer class", 0, rule),
|
||||
new TestDescriptor(TEST20, "assignment to field member is a usage", 0, rule),
|
||||
});
|
||||
}
|
||||
private static final String TEST1 =
|
||||
@ -189,11 +189,9 @@ public class UnusedPrivateFieldRuleTest extends SimpleAggregatorTst {
|
||||
|
||||
private static final String TEST20 =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private class Buz {" + PMD.EOL +
|
||||
" private Biz x;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" private Foo x = new Foo();" + PMD.EOL +
|
||||
" void bar() {" + PMD.EOL +
|
||||
" foo(x);" + PMD.EOL +
|
||||
" x.y = 42;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
|
@ -32,7 +32,8 @@ public class UnusedPrivateFieldRule extends AbstractRule {
|
||||
|
||||
private boolean actuallyUsed(List usages) {
|
||||
for (Iterator j = usages.iterator(); j.hasNext();) {
|
||||
if (!((NameOccurrence)j.next()).isOnLeftHandSide()) {
|
||||
NameOccurrence nameOccurrence = (NameOccurrence)j.next();
|
||||
if (!nameOccurrence.isOnLeftHandSide()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public class NameOccurrence {
|
||||
|
||||
return primaryExpression.jjtGetNumChildren() > 1 &&
|
||||
primaryExpression.jjtGetChild(1) instanceof ASTAssignmentOperator &&
|
||||
!isPartOfQualifiedName() &&
|
||||
!((ASTAssignmentOperator)(primaryExpression.jjtGetChild(1))).isCompound();
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,12 @@
|
||||
</subsection>
|
||||
<subsection name="Contributors">
|
||||
<ul>
|
||||
<li>ereissner - several rule suggestions, bug reports for UnusedPrivateField/CloseConnectionRule/ConstructorCallsOverridableMethodRule, and bug report and documentation suggestions for UseSingletonRule</li>
|
||||
<li>Philippe Couton - bug report for ExceptionAsFlowControl, OverrideBothEqualsAndHashcodeRule bug report, UseSingletonRule improvements, JUnitStaticSuiteRule improvements</li>
|
||||
<li>Dave Brosius - a couple of nice patches to clean up some string handling inefficiencies, non-static class usages, and unclosed streams/readers - found with Findbugs, I daresay :-)</li>
|
||||
<li>Paul Rowe - suggestion for improving MethodWithSameNameAsEnclosingClass, bug reports for SimplifyBooleanExpressions and UnusedLocalVariable</li>
|
||||
<li>Enno Derksen - enhancements to VariableNamingConventionsRule</li>
|
||||
<li>Michael Haggerty - bug reports for FinalizeDoesNotCallSuperFinalize and UnusedModifier</li>
|
||||
<li>ereissner - bug report and documentation suggestions for UseSingletonRule</li>
|
||||
<li>Phil Shaw - documentation suggestions</li>
|
||||
<li>Todd Wright - XPath port of AtLeastOneConstructorRule, ConfusingTernaryExpression rule, reported missing ASTUnaryExpressionNotPlusMinus nodes</li>
|
||||
<li>Sreenivasa Viswanadha - reminded me to use BufferedInputStreams, grammar cleanup for Ctrl-Z problem</li>
|
||||
@ -70,7 +71,6 @@
|
||||
<li>Lokesh Gupta - improvements to the AST viewer</li>
|
||||
<li>Jesse Glick - improvements to VariableNamingConventionsRule, patch for UnusedModifierRule, bug fix for VariableNameDeclarations rule, an excellent discussion on the UnnecessaryConstructorRule</li>
|
||||
<li>Nicolas Liochon - CloneShouldCallSuperCloneRule implementation</li>
|
||||
<li>Philippe Couton - OverrideBothEqualsAndHashcodeRule bug report, UseSingletonRule improvements, JUnitStaticSuiteRule improvements</li>
|
||||
<li>Slava Pestov - Suggestions for jEdit plugin enhancements.</li>
|
||||
<li>Andriy Rozeluk - Suggestions for improving UnnecessaryReturn, AvoidDuplicateLiterals RFEs and bug reports, various other RFEs and thoughtful discussions as well</li>
|
||||
<li>Olivier Mengué - Diagnosed and patched XML report character encoding problems</li>
|
||||
|
Reference in New Issue
Block a user