Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 28 |  | Methods: | 2
| NCLOC: | 22 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
UnnecessaryReturn.java | 100% | 100% | 100% | 100% |

1 |  | package net.sourceforge.pmd.rules.basic;
2 |  |
3 |  | import net.sourceforge.pmd.AbstractRule;
4 |  | import net.sourceforge.pmd.ast.ASTBlock;
5 |  | import net.sourceforge.pmd.ast.ASTBlockStatement;
6 |  | import net.sourceforge.pmd.ast.ASTMethodDeclaration;
7 |  | import net.sourceforge.pmd.ast.ASTReturnStatement;
8 |  | import net.sourceforge.pmd.ast.ASTStatement;
9 |  |
10 |  | public class UnnecessaryReturn extends AbstractRule {
11 |  |
12 | 6 | public Object visit(ASTMethodDeclaration node, Object data) {
13 |  |
14 | 6 | if (node.getResultType().isVoid()) {
15 | 5 | super.visit(node, data);
16 |  | }
17 | 6 | return data;
18 |  | }
19 |  |
20 | 3 | public Object visit(ASTReturnStatement node, Object data) {
21 | 3 | if (node.jjtGetParent().getClass().equals(ASTStatement.class) && node.jjtGetParent().jjtGetParent().getClass().equals(ASTBlockStatement.class) && node.jjtGetParent().jjtGetParent().jjtGetParent().getClass().equals(ASTBlock.class)
22 |  | && node.jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getClass().equals(ASTMethodDeclaration.class)) {
23 | 1 | addViolation(data, node);
24 |  | }
25 | 3 | return data;
26 |  | }
27 |  |
28 |  | }