diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt
index f7c550a968..84d79ca04f 100644
--- a/pmd/etc/changelog.txt
+++ b/pmd/etc/changelog.txt
@@ -3,7 +3,8 @@ Moved development environment to Maven 1.0.
Moved development environment to Ant 1.6.2. This is nice because using the new JUnit task attribute "forkmode='perBatch'" cuts test runtime from 90 seconds to 7 seconds. Sweet.
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 rule violation message is more helpful, and it catches more cases.
+Fixed bugs in AvoidDuplicateLiterals - now it ignores small duplicate literals, its rule violation message is more helpful, and it catches more cases.
+MethodWithSameNameAsEnclosingClass now reports a more helpful line number.
July 14, 2004 - 1.9:
New rules: CloneMethodMustImplementCloneable, CloneThrowsCloneNotSupportedException, EqualsNull, ConfusingTernary
diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/MethodWithSameNameAsEnclosingClassRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/MethodWithSameNameAsEnclosingClassRuleTest.java
index af36feb669..00f6bda388 100644
--- a/pmd/regress/test/net/sourceforge/pmd/rules/MethodWithSameNameAsEnclosingClassRuleTest.java
+++ b/pmd/regress/test/net/sourceforge/pmd/rules/MethodWithSameNameAsEnclosingClassRuleTest.java
@@ -18,6 +18,7 @@ public class MethodWithSameNameAsEnclosingClassRuleTest extends SimpleAggregator
runTests(new TestDescriptor[] {
new TestDescriptor(TEST1, "bad", 1, rule),
new TestDescriptor(TEST2, "ok", 0, rule),
+ new TestDescriptor(TEST3, "doesn't crash on interfaces", 0, rule),
});
}
@@ -30,4 +31,9 @@ public class MethodWithSameNameAsEnclosingClassRuleTest extends SimpleAggregator
"public class Foo {" + PMD.EOL +
" public Foo() {}" + PMD.EOL +
"}";
+
+ private static final String TEST3 =
+ "public interface Foo {" + PMD.EOL +
+ " void voo();" + PMD.EOL +
+ "}";
}
diff --git a/pmd/rulesets/naming.xml b/pmd/rulesets/naming.xml
index f891f69c44..e25669e8b7 100644
--- a/pmd/rulesets/naming.xml
+++ b/pmd/rulesets/naming.xml
@@ -219,8 +219,12 @@ public abstract class Foo { // should be AbstractFoo
+//MethodDeclaration
+ [parent::ClassBodyDeclaration
+ [parent::ClassBody
+ [parent::UnmodifiedClassDeclaration/@Image = //MethodDeclarator/@Image
+ ]]]
+ ]]>
diff --git a/pmd/rulesets/scratchpad.xml b/pmd/rulesets/scratchpad.xml
index 0dc57291ba..9d63277595 100644
--- a/pmd/rulesets/scratchpad.xml
+++ b/pmd/rulesets/scratchpad.xml
@@ -5,30 +5,38 @@
These are new rules that are still in progress
-
-
-Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
-
- 3
-
-
-
-
+
+
+ Non-constructor methods should not have the same name as the enclosing class.
+
+
+
+
+
+
+
+ 3
+
+
-
-
+ ]]>
+
+
+