diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt
index ebf87787f4..4a9388e3b8 100644
--- a/pmd/etc/changelog.txt
+++ b/pmd/etc/changelog.txt
@@ -4,6 +4,7 @@ Fixed bug 840926 - AvoidReassigningParametersRule no longer reports a false posi
Fixed bug 760520 - RuleSetFactory is less strict about whitespace in ruleset.xml files.
Fixed bug 826805 - JumbledIncrementorRule no longer reports a false positive when a outer loop incrementor is used as an array index
Fixed bug 845343 - AvoidDuplicateLiterals now picks up cases when a duplicate literal appears in field declarations.
+Implemented RFE 845348 - UnnecessaryReturn yields more useful line numbers now
Added a ruleset DTD and a ruleset XML Schema.
TODO - fix it so tests and rules don't duplicate the xpath expressions
diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryReturnTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryReturnTest.java
index a610d2517c..9c85d66f8c 100644
--- a/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryReturnTest.java
+++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnnecessaryReturnTest.java
@@ -12,7 +12,7 @@ public class UnnecessaryReturnTest extends SimpleAggregatorTst{
public void setUp() {
rule = new XPathRule();
- rule.addProperty("xpath", "//ResultType[@Void='true' and parent::MethodDeclaration[Block/BlockStatement/Statement/ReturnStatement]]");
+ rule.addProperty("xpath", "//ReturnStatement[parent::Statement[parent::BlockStatement[parent::Block[parent::MethodDeclaration/ResultType[@Void='true']]]]");
}
public void testAll() {
@@ -20,8 +20,8 @@ public class UnnecessaryReturnTest extends SimpleAggregatorTst{
new TestDescriptor(TEST1, "bad", 1, rule),
new TestDescriptor(TEST2, "ok since method is not void", 0, rule),
new TestDescriptor(TEST3, "ok since return is in sub block", 0, rule),
- new TestDescriptor(TEST4, "interface methods work ok", 0, rule),
- new TestDescriptor(TEST5, "abstract methods work ok", 0, rule),
+ new TestDescriptor(TEST4, "interface methods don't have return statements", 0, rule),
+ new TestDescriptor(TEST5, "abstract methods don't have return statements", 0, rule),
});
}
@@ -56,5 +56,4 @@ public class UnnecessaryReturnTest extends SimpleAggregatorTst{
"public class Foo {" + PMD.EOL +
" abstract void bar();" + PMD.EOL +
"}";
-
}
diff --git a/pmd/rulesets/basic.xml b/pmd/rulesets/basic.xml
index 50e7105204..72943838d5 100644
--- a/pmd/rulesets/basic.xml
+++ b/pmd/rulesets/basic.xml
@@ -435,10 +435,14 @@ public class Bar {
diff --git a/pmd/xdocs/credits.xml b/pmd/xdocs/credits.xml
index ee0327a3cc..c73069c413 100644
--- a/pmd/xdocs/credits.xml
+++ b/pmd/xdocs/credits.xml
@@ -38,7 +38,7 @@
- - Andriy Rozeluk - AvoidDuplicateLiterals RFEs and bug reports, various other RFEs and thoughtful discussions as well
+ - Andriy Rozeluk - Suggestions for improving UnnecessaryReturn, AvoidDuplicateLiterals RFEs and bug reports, various other RFEs and thoughtful discussions as well
- Olivier Mengué - Diagnosed and patched XML report character encoding problems
- Hariolf Häfele - PMD-JDeveloper plugin bug reports
- Pieter Bloemendaal - AvoidReassigningParametersRule bug report