01 /**
02 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03 */
04 package net.sourceforge.pmd.lang.java.rule.coupling;
05
06 import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
07 import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
08 import net.sourceforge.pmd.lang.java.rule.design.ExcessiveNodeCountRule;
09 import net.sourceforge.pmd.util.NumericConstants;
10
11 /**
12 * ExcessiveImports attempts to count all unique imports a class
13 * contains. This rule will count a "import com.something.*;" as a single
14 * import. This is a unqiue situation and I'd like to create an audit type
15 * rule that captures those.
16 *
17 * @author aglover
18 * @since Feb 21, 2003
19 */
20 public class ExcessiveImportsRule extends ExcessiveNodeCountRule {
21
22 public ExcessiveImportsRule() {
23 super(ASTCompilationUnit.class);
24 setProperty(MINIMUM_DESCRIPTOR, 30d);
25 }
26
27 /**
28 * Hook method to count imports. This is a user defined value.
29 *
30 * @param node
31 * @param data
32 * @return Object
33 */
34 public Object visit(ASTImportDeclaration node, Object data) {
35 return NumericConstants.ONE;
36 }
37 }
|