Clover coverage report - PMD - 3.7 Coverage timestamp: Wed May 31 2006 09:25:59 EDT FRAMES NO FRAMES |

file stats: | LOC: | 31 |  | Methods: | 2
| NCLOC: | 22 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL
AvoidDeeplyNestedIfStmtsRule.java | 100% | 100% | 100% | 100% |

1 |  | /**
2 |  | * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 |  | */
4 |  | package net.sourceforge.pmd.rules;
5 |  |
6 |  | import net.sourceforge.pmd.AbstractRule;
7 |  | import net.sourceforge.pmd.ast.ASTCompilationUnit;
8 |  | import net.sourceforge.pmd.ast.ASTIfStatement;
9 |  |
10 |  | public class AvoidDeeplyNestedIfStmtsRule extends AbstractRule {
11 |  |
12 |  | private int depth;
13 |  |
14 | 2 | public Object visit(ASTCompilationUnit node, Object data) {
15 | 2 | depth = 0;
16 | 2 | return super.visit(node, data);
17 |  | }
18 |  |
19 | 6 | public Object visit(ASTIfStatement node, Object data) {
20 | 6 | if (!node.hasElse()) {
21 | 3 | depth++;
22 |  | }
23 | 6 | super.visit(node, data);
24 | 6 | if (depth == getIntProperty("problemDepth")) {
25 | 1 | addViolation(data, node);
26 |  | }
27 | 6 | depth--;
28 | 6 | return data;
29 |  | }
30 |  |
31 |  | }