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

file stats: | LOC: | 26 |  | Methods: | 1
| NCLOC: | 19 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL
StringToStringRule.java | 83.3% | 100% | 100% | 92.9% |

1 |  | /**
2 |  | * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 |  | */
4 |  | package net.sourceforge.pmd.rules.strings;
5 |  |
6 |  | import net.sourceforge.pmd.AbstractRule;
7 |  | import net.sourceforge.pmd.ast.ASTVariableDeclaratorId;
8 |  | import net.sourceforge.pmd.symboltable.NameOccurrence;
9 |  |
10 |  | import java.util.Iterator;
11 |  |
12 |  | public class StringToStringRule extends AbstractRule {
13 |  |
14 | 7 | public Object visit(ASTVariableDeclaratorId node, Object data) {
15 | 7 | if (!node.getNameDeclaration().getTypeImage().equals("String")) {
16 | 2 | return data;
17 |  | }
18 | 5 | for (Iterator i = node.getUsages().iterator(); i.hasNext();) {
19 | 4 | NameOccurrence occ = (NameOccurrence) i.next();
20 | 4 | if (occ.getNameForWhichThisIsAQualifier() != null && occ.getNameForWhichThisIsAQualifier().getImage().indexOf("toString") != -1) {
21 | 4 | addViolation(data, occ.getLocation());
22 |  | }
23 |  | }
24 | 5 | return data;
25 |  | }
26 |  | }