[95a960]: docs / config_metrics.html Maximize Restore History

Download this file

config_metrics.html    437 lines (385 with data), 13.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Metrics Checks</title>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
</head>
<body>
<!-- The header -->
<table border="0" width="100%" summary="header layout">
<tr>
<td><h1>Metrics Checks</h1></td>
<td align="right"><img src="logo.png" alt="Checkstyle Logo"/></td>
</tr>
</table>
<!-- content -->
<table border="0" width="100%" cellpadding="5" summary="body layout">
<tr>
<!--Left menu-->
<td class="menu" valign="top">
<ul>
<li><a href="#BooleanExpressionComplexity">BooleanExpressionComplexity</a></li>
<li><a href="#ClassDataAbstractionCoupling">ClassDataAbstractionCoupling</a></li>
<li><a href="#ClassFanOutComplexity">ClassFanOutComplexity</a></li>
<li><a href="#CyclomaticComplexity">CyclomaticComplexity</a></li>
<li><a href="#JavaNCSS">JavaNCSS</a></li>
<li><a href="#NPathComplexity">NPathComplexity</a></li>
</ul>
</td>
<!--Content-->
<td class="content" valign="top" align="left">
<!-- --><a name="BooleanExpressionComplexity"></a>
<h2>BooleanExpressionComplexity</h2>
<h4>Description</h4>
<p class="body">
Restrict the number of number of <span class="code">&&</span>,
<span class="code">||</span> and <span class="code">^</span> in
an expression.
</p>
<p>
Rationale:
Too many conditions leads to code that is difficult to
read and hence debug and maintain.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum allowed number of boolean operations in one
experession.</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">3</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;BooleanExpressionComplexity&quot;/&gt;
</pre>
<p class="body">
To configure the check with 7 allowed operation in boolean expression:
</p>
<pre class="body">
&lt;module name=&quot;BooleanExpressionComplexity&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;7&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="ClassDataAbstractionCoupling"></a> <h2>ClassDataAbstractionCoupling</h2>
<h4>Description</h4>
<p class="body">
This metric measures the number of instantiations of
other classes within the given class. This type of
coupling is not caused by inheritance or the object
oriented paradigm. Generally speaking, any abstract
data type with other abstract data types as members has
data abstraction coupling; therefore, if a class has a
local variable that is an instantiation (object) of
another class, there is data abstraction coupling. The
higher the DAC, the more complex the data structure
(classes) of the system.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum threshold allowed</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">7</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;ClassDataAbstractionCoupling&quot;/&gt;
</pre>
<p class="body">
To configure the check with a threshold of 5:
</p>
<pre class="body">
&lt;module name=&quot;ClassDataAbstractionCoupling&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;5&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="ClassFanOutComplexity"></a> <h2>ClassFanOutComplexity</h2>
<h4>Description</h4>
<p class="body">
The number of other classes a given class relies on. Also
the square of this has been shown to indicate the
amount of maintenence required in functional programs
(on a file basis) at least.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum threshold allowed</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">20</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;ClassFanOutComplexity&quot;/&gt;
</pre>
<p class="body">
To configure the check with a threshold of 10:
</p>
<pre class="body">
&lt;module name=&quot;ClassFanOutComplexity&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;10&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="CyclomaticComplexity"></a> <h2>CyclomaticComplexity</h2>
<h4>Description</h4>
<p class="body">
Checks cyclomatic complexity against a specified limit. The complexity is
measured by the number of
<span CLASS="code">if</span>,
<span CLASS="code">while</span>,
<span CLASS="code">do</span>,
<span CLASS="code">for</span>,
<span CLASS="code">?:</span>,
<span CLASS="code">catch</span>,
<span CLASS="code">switch</span>,
<span CLASS="code">case</span> statements, and operators
<span CLASS="code">&&</span> and <span CLASS="code">||</span> (plus one) in the body of a
constructor, method, static initializer, or instance initializer.
It is a measure of the minimum number of possible paths through the
source and therefore the number of required tests. Generally 1-4 is
considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now!
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum threshold allowed</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">10</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;CyclomaticComplexity&quot;/&gt;
</pre>
<p class="body">
To configure the check with a threshold of 7:
</p>
<pre class="body">
&lt;module name=&quot;CyclomaticComplexity&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;7&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="NPathComplexity"></a> <h2>NPathComplexity</h2>
<h4>Description</h4>
<p class="body">
The NPATH metric computes the number of possible
execution paths through a function. It takes into
account the nesting of conditional statements and
multi-part boolean expressions (e.g., A && B, C || D,
etc.).
</p>
<p>
Rationale:
Nejmeh says that his group had an informal NPATH limit
of 200 on individual routines; functions that exceeded
this value were candidates for further decomposition -
or at least a closer look.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>max</td>
<td>the maximum threshold allowed</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">200</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;NPathComplexity&quot;/&gt;
</pre>
<p class="body">
To configure the check with a threshold of 20:
</p>
<pre class="body">
&lt;module name=&quot;NPathComplexity&quot;&gt;
&lt;property name=&quot;max&quot; value=&quot;20&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
<!-- --><a name="JavaNCSS"></a>
<h2>JavaNCSS</h2>
<h4>Description</h4>
<p class="body">
Determines complexity of methods, classes and files by counting
the Non Commenting Source Statements (NCSS).
This check adheres to the <a
href="http://www.kclee.com/clemens/java/javancss/">
specification</a> for the JavaNCSS-Tool written by
<b>Chr. Clemens Lee</b> which sadly seems to have been pulled
off the web.<br/>
Rougly said the NCSS metric is calculated by counting the source
lines which are not comments, (nearly) equivalent to counting
the semicolons and opening curly braces.<br/>
The NCSS for a class is summarized from the NCSS of all its methods,
the NCSS of its nested classes and the number of member variable
declarations.<br/>
The NCSS for a file is summarized from the ncss of all its top level
classes, the number of imports and the package declaration.
</p>
<p>
Rationale:
Too large methods and classes are hard to read and costly to
maintain. A large NCSS number often means that a method or
class has too many responsabilities and/or functionalities
which should be decomposed into smaller units.
</p>
<h4>Properties</h4>
<table width="100%" border="1" cellpadding="5" class="body">
<tr class="header">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
</tr>
<tr>
<td>methodMaximum</td>
<td>the maximum allowed number of non commenting lines in
a method.</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">50</span></td>
</tr>
<tr>
<td>classMaximum</td>
<td>the maximum allowed number of non commenting lines in
a class.</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">1500</span></td>
</tr>
<tr>
<td>fileMaximum</td>
<td>the maximum allowed number of non commenting lines in
a file including all top level and nested classes.</td>
<td><a href="property_types.html#integer">integer</a></td>
<td><span class="default">2000</span></td>
</tr>
</table>
<h4>Examples</h4>
<p class="body">
To configure the check:
</p>
<pre class="body">
&lt;module name=&quot;JavaNCSS&quot;/&gt;
</pre>
<p class="body">
To configure the check with 40 allowed non commenting lines
for a method:
</p>
<pre class="body">
&lt;module name=&quot;JavaNCSS&quot;&gt;
&lt;property name=&quot;methodMaximum&quot; value=&quot;40&quot;/&gt;
&lt;/module&gt;
</pre>
<h4>Package</h4>
<p class="body">
com.puppycrawl.tools.checkstyle.checks.metrics
</p>
<h4>Parent Module</h4>
<p class="body">
<a href="config.html#treewalker">TreeWalker</a>
</p>
</td>
</tr>
</table>
<hr />
<div><a href="index.html">Back to the Checkstyle Home Page</a></div>
<p class="copyright">
Copyright &copy; 2002-2004 Oliver Burn. All rights Reserved.
</p>
</body>
</html>