Clover coverage report - PMD - 3.7 Coverage timestamp: Wed May 31 2006 09:25:59 EDT FRAMES NO FRAMES |
file stats: | LOC: | 44 |  | Methods: | 2
| NCLOC: | 35 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
SymbolTableTestRule.java | 0% | 0% | 0% | 0% |

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.Rule;
8 |  | import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
9 |  | import net.sourceforge.pmd.symboltable.MethodNameDeclaration;
10 |  |
11 |  | import java.util.HashSet;
12 |  | import java.util.Iterator;
13 |  | import java.util.Map;
14 |  | import java.util.Set;
15 |  |
16 |  | public class SymbolTableTestRule extends AbstractRule implements Rule {
17 |  |
18 | 0 | public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
19 | 0 | Map methods = node.getScope().getEnclosingClassScope().getMethodDeclarations();
20 | 0 | Set suffixes = new HashSet();
21 | 0 | for (Iterator i = methods.keySet().iterator(); i.hasNext();) {
22 | 0 | MethodNameDeclaration mnd = (MethodNameDeclaration) i.next();
23 | 0 | String suffix = findSuffix(mnd);
24 | 0 | if (suffix != null) {
25 | 0 | if (suffixes.contains(suffix)) {
26 | 0 | addViolation(data, mnd.getNode(), suffix);
27 |  | }
28 | 0 | suffixes.add(suffix);
29 |  | }
30 |  | }
31 | 0 | return data;
32 |  | }
33 |  |
34 | 0 | private String findSuffix(MethodNameDeclaration mnd) {
35 | 0 | String end = null;
36 | 0 | if (mnd.getImage().startsWith("is")) {
37 | 0 | end = mnd.getImage().substring(2);
38 | 0 | } else if (mnd.getImage().startsWith("get")) {
39 | 0 | end = mnd.getImage().substring(3);
40 |  | }
41 | 0 | return end;
42 |  | }
43 |  |
44 |  | }