part of refactoring to consolidate all the regexp checks.
1 <?xml version="1.0" encoding="ISO-8859-1"?>
7 <author>Checkstyle Development Team</author>
12 <section name="BooleanExpressionComplexity">
13 <subsection name="Description">
15 Restrict the number of number of <span
16 class="code">&&</span>, <span class="code">||</span>,
17 <span class="code">&</span>, <span class="code">|</span>
18 and <span class="code">^</span> in an expression.
22 Rationale: Too many conditions leads to code that is difficult
23 to read and hence debug and maintain.
27 Note that the operators <span class="code">&</span> and
28 <span class="code">|</span> are not only integer bitwise operators, they are also the
29 <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.22.2">
30 non-shortcut versions</a> of the boolean operators
31 <span class="code">&&</span> and <span class="code">||</span>.
35 <subsection name="Properties">
41 <th>default value</th>
46 the maximum allowed number of boolean operations in one
49 <td><a href="property_types.html#integer">integer</a></td>
50 <td><span class="default">3</span></td>
54 <td>tokens to check</td>
57 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LAND">LAND</a>,
58 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BAND">BAND</a>,
59 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LOR">LOR</a>,
60 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BOR">BOR</a>,
61 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BXOR">BXOR</a>
64 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LAND">LAND</a>,
65 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BAND">BAND</a>,
66 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LOR">LOR</a>,
67 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BOR">BOR</a>,
68 <a href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BXOR">BXOR</a>
74 <subsection name="Examples">
76 To configure the check:
79 <module name="BooleanExpressionComplexity"/>
83 To configure the check with 7 allowed operation in boolean
87 <module name="BooleanExpressionComplexity">
88 <property name="max" value="7"/>
93 To configure the check to ignore <span class="code">&</span> and
94 <span class="code">|</span>:
97 <module name="BooleanExpressionComplexity">
98 <property name="tokens" value="BXOR,LAND,LOR"/>
104 <subsection name="Package">
106 com.puppycrawl.tools.checkstyle.checks.metrics
110 <subsection name="Parent Module">
112 <a href="config.html#treewalker">TreeWalker</a>
117 <section name="ClassDataAbstractionCoupling">
118 <subsection name="Description">
120 This metric measures the number of instantiations of other
121 classes within the given class. This type of coupling is not
122 caused by inheritance or the object oriented
123 paradigm. Generally speaking, any abstract data type with
124 other abstract data types as members has data abstraction
125 coupling; therefore, if a class has a local variable that is
126 an instantiation (object) of another class, there is data
127 abstraction coupling. The higher the DAC, the more complex the
128 data structure (classes) of the system.
132 <subsection name="Properties">
138 <th>default value</th>
142 <td>the maximum threshold allowed</td>
143 <td><a href="property_types.html#integer">integer</a></td>
144 <td><span class="default">7</span></td>
149 <subsection name="Examples">
151 To configure the check:
154 <module name="ClassDataAbstractionCoupling"/>
158 To configure the check with a threshold of 5:
161 <module name="ClassDataAbstractionCoupling">
162 <property name="max" value="5"/>
167 <subsection name="Package">
169 com.puppycrawl.tools.checkstyle.checks.metrics
173 <subsection name="Parent Module">
175 <a href="config.html#treewalker">TreeWalker</a>
180 <section name="ClassFanOutComplexity">
181 <subsection name="Description">
183 The number of other classes a given class relies on. Also the
184 square of this has been shown to indicate the amount of
185 maintenence required in functional programs (on a file basis)
190 <subsection name="Properties">
196 <th>default value</th>
200 <td>the maximum threshold allowed</td>
201 <td><a href="property_types.html#integer">integer</a></td>
202 <td><span class="default">20</span></td>
207 <subsection name="Examples">
209 To configure the check:
212 <module name="ClassFanOutComplexity"/>
216 To configure the check with a threshold of 10:
219 <module name="ClassFanOutComplexity">
220 <property name="max" value="10"/>
225 <subsection name="Package">
227 com.puppycrawl.tools.checkstyle.checks.metrics
231 <subsection name="Parent Module">
233 <a href="config.html#treewalker">TreeWalker</a>
238 <section name="CyclomaticComplexity">
239 <subsection name="Description">
241 Checks cyclomatic complexity against a specified limit. The
242 complexity is measured by the number of <span
243 CLASS="code">if</span>, <span CLASS="code">while</span>, <span
244 CLASS="code">do</span>, <span CLASS="code">for</span>, <span
245 CLASS="code">?:</span>, <span CLASS="code">catch</span>, <span
246 CLASS="code">switch</span>, <span CLASS="code">case</span>
247 statements, and operators <span
248 CLASS="code">&&</span> and <span
249 CLASS="code">||</span> (plus one) in the body of a
250 constructor, method, static initializer, or instance
251 initializer. It is a measure of the minimum number of
252 possible paths through the source and therefore the number of
253 required tests. Generally 1-4 is considered good, 5-7 ok, 8-10
254 consider re-factoring, and 11+ re-factor now!
258 <subsection name="Properties">
264 <th>default value</th>
268 <td>the maximum threshold allowed</td>
269 <td><a href="property_types.html#integer">integer</a></td>
270 <td><span class="default">10</span></td>
275 <subsection name="Examples">
277 To configure the check:
280 <module name="CyclomaticComplexity"/>
284 To configure the check with a threshold of 7:
287 <module name="CyclomaticComplexity">
288 <property name="max" value="7"/>
293 <subsection name="Package">
295 com.puppycrawl.tools.checkstyle.checks.metrics
299 <subsection name="Parent Module">
301 <a href="config.html#treewalker">TreeWalker</a>
306 <section name="NPathComplexity">
307 <subsection name="Description">
309 The NPATH metric computes the number of possible execution
310 paths through a function. It takes into account the nesting of
311 conditional statements and multi-part boolean expressions
312 (e.g., A && B, C || D, etc.).
316 Rationale: Nejmeh says that his group had an informal NPATH
317 limit of 200 on individual routines; functions that exceeded
318 this value were candidates for further decomposition - or at
323 <subsection name="Properties">
329 <th>default value</th>
333 <td>the maximum threshold allowed</td>
334 <td><a href="property_types.html#integer">integer</a></td>
335 <td><span class="default">200</span></td>
340 <subsection name="Examples">
342 To configure the check:
345 <module name="NPathComplexity"/>
349 To configure the check with a threshold of 20:
352 <module name="NPathComplexity">
353 <property name="max" value="20"/>
358 <subsection name="Package">
360 com.puppycrawl.tools.checkstyle.checks.metrics
364 <subsection name="Parent Module">
366 <a href="config.html#treewalker">TreeWalker</a>
371 <section name="JavaNCSS">
372 <subsection name="Description">
374 Determines complexity of methods, classes and files by
375 counting the Non Commenting Source Statements (NCSS). This
376 check adheres to the <a
377 href="http://www.kclee.de/clemens/java/javancss/#specification">
378 specification</a> for the
379 <a href="http://www.kclee.de/clemens/java/javancss/">JavaNCSS-Tool</a>
380 written by <b>Chr. Clemens Lee</b>.<br/>
381 Rougly said the NCSS metric is calculated by
382 counting the source lines which are not comments, (nearly)
383 equivalent to counting the semicolons and opening curly
384 braces.<br/> The NCSS for a class is summarized from the NCSS
385 of all its methods, the NCSS of its nested classes and the
386 number of member variable declarations.<br/> The NCSS for a
387 file is summarized from the ncss of all its top level classes,
388 the number of imports and the package declaration.
392 Rationale: Too large methods and classes are hard to read and
393 costly to maintain. A large NCSS number often means that a
394 method or class has too many responsabilities and/or
395 functionalities which should be decomposed into smaller units.
399 <subsection name="Properties">
405 <th>default value</th>
408 <td>methodMaximum</td>
410 the maximum allowed number of non commenting lines in a
413 <td><a href="property_types.html#integer">integer</a></td>
414 <td><span class="default">50</span></td>
417 <td>classMaximum</td>
419 the maximum allowed number of non commenting lines in a
422 <td><a href="property_types.html#integer">integer</a></td>
423 <td><span class="default">1500</span></td>
428 the maximum allowed number of non commenting lines in a
429 file including all top level and nested classes.
431 <td><a href="property_types.html#integer">integer</a></td>
432 <td><span class="default">2000</span></td>
437 <subsection name="Examples">
439 To configure the check:
442 <module name="JavaNCSS"/>
446 To configure the check with 40 allowed non commenting lines
450 <module name="JavaNCSS">
451 <property name="methodMaximum" value="40"/>
456 <subsection name="Package">
458 com.puppycrawl.tools.checkstyle.checks.metrics
462 <subsection name="Parent Module">
464 <a href="config.html#treewalker">TreeWalker</a>