Clover Coverage Report - Checkstyle
Coverage timestamp: Fri May 9 2008 10:48:13 EST
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
90   312   34   5
8   189   0.38   9
18     1.89  
2    
 
  AbstractClassCouplingCheck       Line # 39 97.6% 0.9756098
22.01 72 22 22 0.31
  AbstractClassCouplingCheck.Context       Line # 204 97.1% 0.9705882
12 18 12 12 0.67
 
  (3)
 
1    ////////////////////////////////////////////////////////////////////////////////
2    // checkstyle: Checks Java source code for adherence to a set of rules.
3    // Copyright (C) 2001-2005 Oliver Burn
4    //
5    // This library is free software; you can redistribute it and/or
6    // modify it under the terms of the GNU Lesser General Public
7    // License as published by the Free Software Foundation; either
8    // version 2.1 of the License, or (at your option) any later version.
9    //
10    // This library is distributed in the hope that it will be useful,
11    // but WITHOUT ANY WARRANTY; without even the implied warranty of
12    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    // Lesser General Public License for more details.
14    //
15    // You should have received a copy of the GNU Lesser General Public
16    // License along with this library; if not, write to the Free Software
17    // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18    ////////////////////////////////////////////////////////////////////////////////
19    package com.puppycrawl.tools.checkstyle.checks.metrics;
20   
21    import com.puppycrawl.tools.checkstyle.api.Check;
22    import com.puppycrawl.tools.checkstyle.api.DetailAST;
23    import com.puppycrawl.tools.checkstyle.api.FullIdent;
24    import com.puppycrawl.tools.checkstyle.api.TokenTypes;
25   
26    import com.puppycrawl.tools.checkstyle.checks.CheckUtils;
27   
28    import java.util.HashSet;
29    import java.util.LinkedHashSet;
30    import java.util.Set;
31    import java.util.Stack;
32   
33    /**
34    * Base class for coupling calculation.
35    *
36    * @author <a href="mailto:simon@redhillconsulting.com.au">Simon Harris</a>
37    * @author o_sukhodolsky
38    */
 
39    public abstract class AbstractClassCouplingCheck extends Check
40    {
41    /** Class names to ignore. */
42    private final Set mIgnoredClassNames = new HashSet();
43    /** Allowed complexity. */
44    private int mMax;
45    /** package of the file we check. */
46    private String mPackageName;
47   
48    /** Stack of contexts. */
49    private final Stack mContextStack = new Stack();
50    /** Current context. */
51    private Context mContext;
52   
53    /**
54    * Creates new instance of the check.
55    * @param aDefaultMax default value for allowed complexity.
56    */
 
57  3 toggle protected AbstractClassCouplingCheck(int aDefaultMax)
58    {
59  3 setMax(aDefaultMax);
60   
61  3 mIgnoredClassNames.add("boolean");
62  3 mIgnoredClassNames.add("byte");
63  3 mIgnoredClassNames.add("char");
64  3 mIgnoredClassNames.add("double");
65  3 mIgnoredClassNames.add("float");
66  3 mIgnoredClassNames.add("int");
67  3 mIgnoredClassNames.add("long");
68  3 mIgnoredClassNames.add("short");
69  3 mIgnoredClassNames.add("void");
70  3 mIgnoredClassNames.add("Boolean");
71  3 mIgnoredClassNames.add("Byte");
72  3 mIgnoredClassNames.add("Character");
73  3 mIgnoredClassNames.add("Double");
74  3 mIgnoredClassNames.add("Float");
75  3 mIgnoredClassNames.add("Integer");
76  3 mIgnoredClassNames.add("Long");
77  3 mIgnoredClassNames.add("Object");
78  3 mIgnoredClassNames.add("Short");
79  3 mIgnoredClassNames.add("String");
80  3 mIgnoredClassNames.add("StringBuffer");
81  3 mIgnoredClassNames.add("Void");
82  3 mIgnoredClassNames.add("ArrayIndexOutOfBoundsException");
83  3 mIgnoredClassNames.add("Exception");
84  3 mIgnoredClassNames.add("RuntimeException");
85  3 mIgnoredClassNames.add("IllegalArgumentException");
86  3 mIgnoredClassNames.add("IllegalStateException");
87  3 mIgnoredClassNames.add("IndexOutOfBoundsException");
88  3 mIgnoredClassNames.add("NullPointerException");
89  3 mIgnoredClassNames.add("Throwable");
90  3 mIgnoredClassNames.add("SecurityException");
91  3 mIgnoredClassNames.add("UnsupportedOperationException");
92    }
93   
94    /** {@inheritDoc} */
 
95  3 toggle public final int[] getDefaultTokens()
96    {
97  3 return getRequiredTokens();
98    }
99   
100    /** @return allowed complexity. */
 
101  6 toggle public final int getMax()
102    {
103  6 return mMax;
104    }
105   
106    /**
107    * Sets maximul allowed complexity.
108    * @param aMax allowed complexity.
109    */
 
110  6 toggle public final void setMax(int aMax)
111    {
112  6 mMax = aMax;
113    }
114   
115    /** {@inheritDoc} */
 
116  3 toggle public final void beginTree(DetailAST aAST)
117    {
118  3 mPackageName = "";
119    }
120   
121    /** @return message key we use for log violations. */
122    protected abstract String getLogMessageId();
123