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

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

Source file | Conditionals | Statements | Methods | TOTAL
ImportFromSamePackageRule.java | 75% | 83.3% | 100% | 81.8% |

1 |  | /**
2 |  | * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 |  | */
4 |  | package net.sourceforge.pmd.rules.imports;
5 |  |
6 |  | import net.sourceforge.pmd.AbstractRule;
7 |  | import net.sourceforge.pmd.ast.ASTImportDeclaration;
8 |  |
9 |  | public class ImportFromSamePackageRule extends AbstractRule {
10 |  |
11 | 7 | public Object visit(ASTImportDeclaration importDecl, Object data) {
12 | 7 | String packageName = importDecl.getScope().getEnclosingSourceFileScope().getPackageName();
13 |  |
14 | 7 | if (packageName != null && packageName.equals(importDecl.getPackageName())) {
15 | 3 | addViolation(data, importDecl);
16 |  | }
17 |  |
18 |  | // special case
19 | 7 | if (packageName == null && importDecl.getPackageName().equals("")) {
20 | 0 | addViolation(data, importDecl);
21 |  | }
22 | 7 | return data;
23 |  | }
24 |  | }