Fixed bug 1465574 - UnusedPrivateMethod no longer reports false positives when a private method is called from a method with a parameter of the same name.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4326 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2006-04-07 01:01:16 +00:00
parent af005b308e
commit 14f22ca0de
4 changed files with 13 additions and 2 deletions

View File

@ -1,4 +1,5 @@
????, 2006 - 3.7:
Fixed bug 1465574 - UnusedPrivateMethod no longer reports false positives when a private method is called from a method with a parameter of the same name.
Fixed major bug in CPD; it was not picking up files other than .java or .jsp.
Added RuleViolation.getBeginColumn()/getEndColumn()
Added an IRuleViolation interface and modified various code classes (include Renderer implementations and Report) to use it.

View File

@ -34,7 +34,8 @@ public class UnusedPrivateMethodRuleTest extends SimpleAggregatorTst {
new TestDescriptor(TEST12, "private method with same name but diff arg count than public method", 0, rule),
new TestDescriptor(TEST13, "static private called from initializer", 0, rule),
new TestDescriptor(TEST14, "static private invoked in static context - i.e., Foo.hi()", 0, rule),
// FIXME new TestDescriptor(TEST15, "two methods, one private, one public, same name, same arg count, diff types", 0, rule),
new TestDescriptor(TEST15, "private method with same name as param", 0, rule),
// FIXME new TestDescriptor(TEST16, "two methods, one private, one public, same name, same arg count, diff types", 0, rule),
});
}
@ -159,6 +160,14 @@ public class UnusedPrivateMethodRuleTest extends SimpleAggregatorTst {
"}";
private static final String TEST15 =
"public class Foo {" + PMD.EOL +
" void bar(boolean buz) { " + PMD.EOL +
" buz();" + PMD.EOL +
" }" + PMD.EOL +
" private void buz() {}" + PMD.EOL +
"}";
private static final String TEST16 =
"public class Foo {" + PMD.EOL +
" public void baz() {" + PMD.EOL +
" foo(\"hi\");" + PMD.EOL +

View File

@ -52,7 +52,7 @@ public class MethodScope extends AbstractScope {
}
public NameDeclaration findVariableHere(NameOccurrence occurrence) {
if (occurrence.isThisOrSuper()) {
if (occurrence.isThisOrSuper() || occurrence.isMethodOrConstructorInvocation()) {
return null;
}
ImageFinderFunction finder = new ImageFinderFunction(occurrence.getImage());

View File

@ -48,6 +48,7 @@
</subsection>
<subsection name="Contributors">
<ul>
<li>Dawid Weiss - Reported bug in UnusedPrivateMethod</li>
<li>Shao Lo - Reported bug in CPD</li>
<li>D'Arcy Smith - Reported missing RuleViolation methods</li>
<li>Xavier Le Vourch - Suggestions on cleaning up casts in grammar, SimplifyBooleanAssertion, patch to fix problem with TestClassWithoutTestCases, patch to fix rule name bugs in migration rulesets</li>