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

file stats: | LOC: | 25 |  | Methods: | 1
| NCLOC: | 15 |  | Classes: | 1

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

1 |  | package net.sourceforge.pmd.rules.strictexception;
2 |  |
3 |  | import net.sourceforge.pmd.AbstractRule;
4 |  | import net.sourceforge.pmd.ast.ASTCatchStatement;
5 |  | import net.sourceforge.pmd.ast.ASTClassOrInterfaceType;
6 |  | import net.sourceforge.pmd.ast.ASTType;
7 |  |
8 |  | /**
9 |  | * Finds <code>catch</code> statements
10 |  | * containing <code>throwable</code> as the type definition.
11 |  | * <p/>
12 |  | *
13 |  | * @author <a mailto:trondandersen@c2i.net>Trond Andersen</a>
14 |  | */
15 |  | public class AvoidCatchingThrowable extends AbstractRule {
16 |  |
17 | 2 | public Object visit(ASTCatchStatement node, Object data) {
18 | 2 | ASTType type = (ASTType) node.findChildrenOfType(ASTType.class).get(0);
19 | 2 | ASTClassOrInterfaceType name = (ASTClassOrInterfaceType) type.findChildrenOfType(ASTClassOrInterfaceType.class).get(0);
20 | 2 | if (name.getImage().equals("Throwable")) {
21 | 1 | addViolation(data, name);
22 |  | }
23 | 2 | return super.visit(node, data);
24 |  | }
25 |  | }