forked from phoedos/pmd
Implemented [ 845348 ] UnnecessaryReturn could display line numbers of return stmts
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2409 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -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
|
||||
|
||||
|
@ -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 +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -435,10 +435,14 @@ public class Bar {
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ResultType[
|
||||
parent::MethodDeclaration[Block/BlockStatement/Statement/ReturnStatement] and
|
||||
@Void='true'
|
||||
//ReturnStatement
|
||||
[parent::Statement
|
||||
[parent::BlockStatement
|
||||
[parent::Block
|
||||
[parent::MethodDeclaration/ResultType[@Void='true']
|
||||
]
|
||||
]
|
||||
]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
|
@ -38,7 +38,7 @@
|
||||
</subsection>
|
||||
<subsection name="Contributors">
|
||||
<ul>
|
||||
<li>Andriy Rozeluk - AvoidDuplicateLiterals RFEs and bug reports, various other RFEs and thoughtful discussions as well</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>
|
||||
<li>Hariolf Häfele - PMD-JDeveloper plugin bug reports</li>
|
||||
<li>Pieter Bloemendaal - AvoidReassigningParametersRule bug report</li>
|
||||
|
Reference in New Issue
Block a user