-
Notifications
You must be signed in to change notification settings - Fork 0
/
JavancssAntTask.html
321 lines (300 loc) · 13.9 KB
/
JavancssAntTask.html
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
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>JavaNCSS Ant Task User Manual</title>
</head>
<body>
<h2><a name="javancss">JavaNCSS Ant Task</a></h2>
<h3>Description</h3>
<p>Checks some basic code metrics and generates a report.
<p>This task wraps the JavaNCSS library for determining code metrics. The
library determines several code metrics such as class counts, non-commented
source statements (NCSS), cyclomatic complexity numbers (CCN), and javadoc
statements. These counts are subtotaled per function, class, and package.
<p>This task can generate a report (in plain text or XML format) and allows
you to place minimum and maximum thresholds on each metric. All metrics
are included for completeness, however some will be more useful than others.
<p>Note on use: Several empirical studies have shown that more complexity
leads to more defects. The metrics calculated by this task can be used to
focus review and indicate opportunities for refactoring. Such a proactive
approach to development will increase quality through design improvements,
easier testing, and reduction of defects.
<p>The ant verbose option will cause information on each object checked to
be displayed. The default package is indicated by a "." in messages.
<p>The set of files to be adjusted can be refined with the
<i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
<i>excludesfile</i> and <i>defaultexcludes</i>
attributes. Patterns provided through the <i>includes</i> or
<i>includesfile</i> attributes specify files to be
included. Patterns provided through the <i>exclude</i> or
<i>excludesfile</i> attribute specify files to be
excluded. Additionally, default exclusions can be specified with
the <i>defaultexcludes</i> attribute. See the section on directory based
tasks for details of file inclusion/exclusion patterns and their usage.
<p>This task forms an implicit FileSet
and supports all attributes of <code><fileset></code>
(<code>dir</code> becomes <code>srcdir</code>) as well as the nested
<code><include></code>, <code><exclude></code> and
<code><patternset></code> elements.</p>
<p>This Ant task for JavaNCSS has been written by <i><a href="mailto:[email protected]">Steve Jernigan</a></i> with support from
<i><a href="mailto:[email protected]">Phillip Wells</a></i> and
is located at SourceForge: <a href="http://sourceforge.net/projects/javancss2ant/">http://sourceforge.net/projects/javancss2ant/</a>.<br>
The home page of JavaNCSS is located at: <a href="http://www.kclee.de/clemens/java/javancss/">http://www.kclee.de/clemens/java/javancss/</a>.
<h3>Parameters</h3>
<p>There are three kinds of parameter: those related to report generation,
those related to threshold checking and those common to both.
<p><b>Common parameters</b></p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">srcdir</td>
<td valign="top">The location of the Java source files to be
analysed.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">includes</td>
<td valign="top">comma separated list of patterns of files that must
be included. All files are included when omitted.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">includesfile</td>
<td valign="top">the name of a file. Each line of this file is
taken to be an include pattern</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">excludes</td>
<td valign="top">comma separated list of patterns of files that must
be excluded. No files (except default excludes) are excluded when
omitted.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">excludesfile</td>
<td valign="top">the name of a file. Each line of this file is
taken to be an exclude pattern</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">defaultexcludes</td>
<td valign="top">indicates whether default excludes should be used
or not ("yes"/"no"). Default excludes are used
when omitted.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">abortOnFail</td>
<td valign="top">If true, the build will be terminated if a threshold
is exceeded. If false, only a warning message is printed. Default is
false.</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<p><b>Report generation parameters</b></p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">generateReport</td>
<td valign="top">Whether a report should be generated. Default is
false. When set to true, the report will be created in the location
specified by 'outputfile', or to the standard output if this parameter
is not set.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">outputfile</td>
<td valign="top">The fully-specified path of the report to be created
by this task. If omitted and 'generateReport' is set to 'true' the
report will be sent to the standard output.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">format</td>
<td valign="top">The format of the report. Allowable values are
'plain' and 'xml'. 'plain' is the default.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">packageMetrics</td>
<td valign="top">Whether metrics data for each package should be
included in the report . Default is true.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">classMetrics</td>
<td valign="top">Whether metrics data for each class/interface should
be included in the report . Default is true.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">functionMetrics</td>
<td valign="top">Whether metrics data for each function should be
included in the report . Default is true.</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<p><b>Threshold checking parameters</b></p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">classPerPkgMax</td>
<td valign="top">Set the maximum threshold for the classs per package
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">classPerPkgMin</td>
<td valign="top">Set the minimum threshold for the classes per package
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">ncssPerPkgMax</td>
<td valign="top">Set the maximum threshold for the NCSS per package
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">ncssPerPkgMin</td>
<td valign="top">Set the minimum threshold for the NCSS per package
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">funcPerPkgMax</td>
<td valign="top">Set the maximum threshold for the functions per
package metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">funcPerPkgMin</td>
<td valign="top">Set the minimum threshold for the functions per
package metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">classPerClassMax</td>
<td valign="top">Set the maximum threshold for the inner classes per
class metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">classPerClassMin</td>
<td valign="top">Set the minimum threshold for the inner classes per
class metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">funcPerClassMax</td>
<td valign="top">Set the maximum threshold for the functions per
class metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">funcPerClassMin</td>
<td valign="top">Set the minimum threshold for the functions per
class metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">ncssPerClassMax</td>
<td valign="top">Set the maximum threshold for the NCSS per class
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">ncssPerClassMin</td>
<td valign="top">Set the minimum threshold for the NCSS per class
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">jvdcPerClassMax</td>
<td valign="top">Set the maximum threshold for the javadoc statements
per class metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">jvdcPerClassMin</td>
<td valign="top">Set the minimum threshold for the javadoc statements
per class metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">jvdcPerFuncMax</td>
<td valign="top">Set the maximum threshold for the javadoc statements
per function metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">jvdcPerFuncMin</td>
<td valign="top">Set the minimum threshold for the javadoc statements
per function metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">ccnPerFuncMax</td>
<td valign="top">Set the maximum threshold for the CCN per function
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">ccnPerFuncMin</td>
<td valign="top">Set the minimum threshold for the CNN per function
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">ncssPerFuncMax</td>
<td valign="top">Set the maximum threshold for the NCSS per function
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">ncssPerFuncMin</td>
<td valign="top">Set the minimum threshold for the NCSS per function
metric. This is an integer option.</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<h3>Examples</h3>
<pre> <taskdef name="javancss"
classname="javancss.JavancssAntTask"
classpath="${CLASSPATH}"/>
<javancss srcdir="${build.src}"
abortOnFail="false" ccnPerFuncMax="10"
includes="**/*.java"/>
</pre>
<p>Checks for functions with a greater than 10 CCN from
the java source files and prints a warning message for each
instance. Even if a function exceeds the threshold, the
build is allowed to continue.
</p>
<pre> <taskdef name="javancss"
classname="javancss.JavancssAntTask"
classpath="${CLASSPATH}"/>
<javancss srcdir="${build.src}"
generateReport="true"
outputfile="${test.results.root}/javancss_metrics.xml"
format="xml"/>
</pre>
<p>Creates an XML-format report called javancss_metrics.xml in the directory
specified by <code>${test.results.root}</code> on all source files in the
directory specified by <code>${build.src}</code>. No thresholds are checked.
</p>
<hr><p align="center">Copyright © 2001-2002 Steve Jernigan <[email protected]>, distributed under the GNU General Public License (GPL).</p></body>
</html>