A patch from Xavier Le Vourch to fix a missed hit in ProperCloneImplementation

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4607 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2006-10-10 03:55:58 +00:00
parent 65e1f026c1
commit 85e1b75ad2
5 changed files with 21 additions and 11 deletions

View File

@ -22,6 +22,7 @@ public class ProperCloneImplementationTest extends SimpleAggregatorTst {
new TestDescriptor(TEST1, "ok, calls super.clone", 0, rule),
new TestDescriptor(TEST2, "bad, Foo.clone() calls new Foo();", 1, rule),
new TestDescriptor(TEST3, "clone([whatever]) is fine", 0, rule),
new TestDescriptor(TEST4, "bad, Foo.clone() calls new Foo();", 1, rule),
});
}
@ -45,4 +46,13 @@ public class ProperCloneImplementationTest extends SimpleAggregatorTst {
" Foo f = new Foo();" + PMD.EOL +
" }" + PMD.EOL +
"}";
private static final String TEST4 =
"public class Bar {" + PMD.EOL +
" class Foo {" + PMD.EOL +
" void clone() {" + PMD.EOL +
" Foo f = new Foo();" + PMD.EOL +
" }" + PMD.EOL +
" }" + PMD.EOL +
"}";
}

View File

@ -26,7 +26,7 @@ Object clone() should be implemented with super.clone()
[count(../Block//*[
(self::AllocationExpression) and
(./ClassOrInterfaceType/@Image = ancestor::
ClassOrInterfaceDeclaration[position()=last()]/@Image)
ClassOrInterfaceDeclaration[1]/@Image)
])> 0
]
]]>

View File

@ -1,6 +1,7 @@
/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParser.java */
package net.sourceforge.pmd.ast;
import java.util.Map;
import java.util.*;
import net.sourceforge.pmd.PMD;
public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants, JavaParserConstants {/*@bgen(jjtree)*/
protected JJTJavaParserState jjtree = new JJTJavaParserState();
private boolean isJDK13;
@ -11,6 +12,7 @@ public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants, Java
}
public void setJDK15() {
System.out.println("JDK 1.5 was SET");
this.isJDK15 = true;
}
@ -6108,11 +6110,6 @@ jjtn000.setModifiers(modifiers);
finally { jj_save(49, xla); }
}
final private boolean jj_3R_294() {
if (jj_scan_token(GT)) return true;
return false;
}
final private boolean jj_3R_293() {
if (jj_scan_token(LT)) return true;
return false;
@ -9034,6 +9031,11 @@ jjtn000.setModifiers(modifiers);
return false;
}
final private boolean jj_3R_294() {
if (jj_scan_token(GT)) return true;
return false;
}
public JavaParserTokenManager token_source;
public Token token, jj_nt;
private Token jj_scanpos, jj_lastpos;

View File

@ -1,10 +1,8 @@
/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserTokenManager.java */
package net.sourceforge.pmd.ast;
import java.util.*;
import net.sourceforge.pmd.PMD;
import java.util.HashMap;
import java.util.Map;
public class JavaParserTokenManager implements JavaParserConstants
{
private Map excludeMap = new HashMap();

View File

@ -51,7 +51,7 @@
</subsection>
<subsection name="Contributors">
<ul>
<li>Xavier Le Vourch - Fix to AvoidRethrowingException, fixed bug in EqualsNull, wrote UselessStringValueOf, wrote UnnecessaryWrapperObjectCreation, patch to fix AvoidRethrowingException, patch to fix MissingStaticMethodInNonInstantiatableClass, patch to fix speling in CouplingBetweenObjects message, patch to improve CloneMethodMustImplementCloneable, suggestions on cleaning up casts in grammar, SimplifyBooleanAssertion, patch to fix problem with TestClassWithoutTestCases, patch to fix rule name bugs in migration rulesets, fix to SingularField</li>
<li>Xavier Le Vourch - Fix for ProperCloneImplementation, fix to AvoidRethrowingException, fixed bug in EqualsNull, wrote UselessStringValueOf, wrote UnnecessaryWrapperObjectCreation, patch to fix AvoidRethrowingException, patch to fix MissingStaticMethodInNonInstantiatableClass, patch to fix speling in CouplingBetweenObjects message, patch to improve CloneMethodMustImplementCloneable, suggestions on cleaning up casts in grammar, SimplifyBooleanAssertion, patch to fix problem with TestClassWithoutTestCases, patch to fix rule name bugs in migration rulesets, fix to SingularField</li>
<li>Brent Fisher - SummaryHTML report improvements</li>
<li>Jason Bennett - Patches to improve CyclomaticComplexity rule</li>
<li>George Thomas - Wrote AvoidRethrowingException rule</li>