Date | 2007/07/27 |
---|---|
Codebase | 12308 |
Reviews | 24209 |
DPMO | 555 |
Sigma | 4.761 |
Name | Number | Min | Avg | Max | Total |
---|---|---|---|---|---|
Class complexity | 2 | 11.00 | 75.50 | 140.00 | 151.00 |
Code length | 61 | 1.00 | 12.85 | 245.00 | 784.00 |
File length | 1 | 1208.00 | 1208.00 | 1208.00 | 1208.00 |
Operation complexity | 60 | 1.00 | 2.65 | 33.00 | 159.00 |
Work order | 1 | 4.20 | 4.20 | 4.20 | 4.20 |
# | Line | Column | Name | Severity | Description |
---|---|---|---|---|---|
1 | 23 | 1 | ER-023 | 3 | Packages should begin with [] |
2 | 23 | 1 | ER-033 | 2 | Source file is longer than {0} lines ({1}). |
3 | 163 | 123 | ER-036 | 3 | Line is too long |
4 | 164 | 80 | ER-036 | 3 | Line is too long |
5 | 165 | 87 | ER-036 | 3 | Line is too long |
6 | 167 | 84 | ER-036 | 3 | Line is too long |
7 | 170 | 99 | ER-036 | 3 | Line is too long |
8 | 421 | 112 | ER-036 | 3 | Line is too long |
9 | 427 | 111 | ER-036 | 3 | Line is too long |
10 | 470 | 127 | ER-036 | 3 | Line is too long |
11 | 474 | 85 | ER-036 | 3 | Line is too long |
12 | 478 | 86 | ER-036 | 3 | Line is too long |
13 | 479 | 82 | ER-036 | 3 | Line is too long |
14 | 482 | 96 | ER-036 | 3 | Line is too long |
15 | 484 | 88 | ER-036 | 3 | Line is too long |
16 | 486 | 101 | ER-036 | 3 | Line is too long |
17 | 489 | 96 | ER-036 | 3 | Line is too long |
18 | 492 | 98 | ER-036 | 3 | Line is too long |
19 | 494 | 82 | ER-036 | 3 | Line is too long |
20 | 495 | 107 | ER-036 | 3 | Line is too long |
21 | 498 | 87 | ER-036 | 3 | Line is too long |
22 | 500 | 108 | ER-036 | 3 | Line is too long |
23 | 504 | 90 | ER-036 | 3 | Line is too long |
24 | 505 | 107 | ER-036 | 3 | Line is too long |
25 | 508 | 89 | ER-036 | 3 | Line is too long |
26 | 512 | 83 | ER-036 | 3 | Line is too long |
27 | 513 | 97 | ER-036 | 3 | Line is too long |
28 | 516 | 113 | ER-036 | 3 | Line is too long |
29 | 517 | 65 | ER-036 | 3 | Line is too long |
30 | 521 | 83 | ER-036 | 3 | Line is too long |
31 | 522 | 65 | ER-036 | 3 | Line is too long |
32 | 526 | 92 | ER-036 | 3 | Line is too long |
33 | 529 | 110 | ER-036 | 3 | Line is too long |
34 | 530 | 136 | ER-036 | 3 | Line is too long |
35 | 534 | 91 | ER-036 | 3 | Line is too long |
36 | 535 | 82 | ER-036 | 3 | Line is too long |
37 | 538 | 120 | ER-036 | 3 | Line is too long |
38 | 555 | 92 | ER-036 | 3 | Line is too long |
39 | 558 | 86 | ER-036 | 3 | Line is too long |
40 | 561 | 102 | ER-036 | 3 | Line is too long |
41 | 569 | 88 | ER-036 | 3 | Line is too long |
42 | 571 | 129 | ER-036 | 3 | Line is too long |
43 | 572 | 125 | ER-036 | 3 | Line is too long |
44 | 573 | 175 | ER-036 | 3 | Line is too long |
45 | 576 | 147 | ER-036 | 3 | Line is too long |
46 | 580 | 93 | ER-036 | 3 | Line is too long |
47 | 581 | 99 | ER-036 | 3 | Line is too long |
48 | 591 | 80 | ER-036 | 3 | Line is too long |
49 | 592 | 81 | ER-036 | 3 | Line is too long |
50 | 593 | 135 | ER-036 | 3 | Line is too long |
51 | 594 | 95 | ER-036 | 3 | Line is too long |
52 | 596 | 127 | ER-036 | 3 | Line is too long |
53 | 610 | 106 | ER-036 | 3 | Line is too long |
54 | 627 | 91 | ER-036 | 3 | Line is too long |
55 | 630 | 107 | ER-036 | 3 | Line is too long |
56 | 635 | 104 | ER-036 | 3 | Line is too long |
57 | 638 | 116 | ER-036 | 3 | Line is too long |
58 | 640 | 127 | ER-036 | 3 | Line is too long |
59 | 659 | 94 | ER-036 | 3 | Line is too long |
60 | 663 | 98 | ER-036 | 3 | Line is too long |
61 | 667 | 102 | ER-036 | 3 | Line is too long |
62 | 675 | 99 | ER-036 | 3 | Line is too long |
63 | 679 | 88 | ER-036 | 3 | Line is too long |
64 | 768 | 103 | ER-036 | 3 | Line is too long |
65 | 818 | 84 | ER-036 | 3 | Line is too long |
66 | 838 | 107 | ER-036 | 3 | Line is too long |
67 | 907 | 96 | ER-036 | 3 | Line is too long |
68 | 985 | 86 | ER-036 | 3 | Line is too long |
69 | 986 | 85 | ER-036 | 3 | Line is too long |
70 | 993 | 88 | ER-036 | 3 | Line is too long |
71 | 997 | 85 | ER-036 | 3 | Line is too long |
72 | 1001 | 89 | ER-036 | 3 | Line is too long |
73 | 1070 | 97 | ER-036 | 3 | Line is too long |
74 | 1072 | 92 | ER-036 | 3 | Line is too long |
75 | 1073 | 143 | ER-036 | 3 | Line is too long |
76 | 1079 | 84 | ER-036 | 3 | Line is too long |
77 | 1109 | 9 | ER-036 | 3 | Line is too long |
78 | 1129 | 81 | ER-036 | 3 | Line is too long |
79 | 1131 | 91 | ER-036 | 3 | Line is too long |
80 | 87 | 1 | ER-011 | 1 | Cyclomatic complexity (140) exceeds 100 |
81 | 87 | 1 | ER-049 | 2 | Unify logging strategy - define individual logger for class |
82 | 89 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
83 | 92 | 37 | ER-104 | 2 | Use a Collection instead of arrays Object[] |
84 | 149 | 34 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
85 | 161 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
86 | 163 | 88 | ER-047 | 2 | Operation (method or constructor) declares subclasses of RuntimeException in throws clause |
87 | 163 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
88 | 165 | 81 | ER-030 | 3 | Avoid hardwired string literals |
89 | 167 | 50 | ER-030 | 3 | Avoid hardwired string literals |
90 | 170 | 83 | ER-030 | 3 | Avoid hardwired string literals |
91 | 177 | 9 | ER-041 | 2 | Method is too long |
92 | 179 | 26 | ER-030 | 3 | Avoid hardwired string literals |
93 | 181 | 30 | ER-030 | 3 | Avoid hardwired string literals |
94 | 183 | 21 | ER-030 | 3 | Avoid hardwired string literals |
95 | 188 | 26 | ER-030 | 3 | Avoid hardwired string literals |
96 | 189 | 30 | ER-030 | 3 | Avoid hardwired string literals |
97 | 192 | 17 | ER-030 | 3 | Avoid hardwired string literals |
98 | 197 | 26 | ER-030 | 3 | Avoid hardwired string literals |
99 | 198 | 30 | ER-030 | 3 | Avoid hardwired string literals |
100 | 201 | 17 | ER-030 | 3 | Avoid hardwired string literals |
101 | 206 | 26 | ER-030 | 3 | Avoid hardwired string literals |
102 | 207 | 30 | ER-030 | 3 | Avoid hardwired string literals |
103 | 210 | 17 | ER-030 | 3 | Avoid hardwired string literals |
104 | 215 | 26 | ER-030 | 3 | Avoid hardwired string literals |
105 | 216 | 30 | ER-030 | 3 | Avoid hardwired string literals |
106 | 219 | 17 | ER-030 | 3 | Avoid hardwired string literals |
107 | 224 | 26 | ER-030 | 3 | Avoid hardwired string literals |
108 | 225 | 30 | ER-030 | 3 | Avoid hardwired string literals |
109 | 228 | 17 | ER-030 | 3 | Avoid hardwired string literals |
110 | 233 | 26 | ER-030 | 3 | Avoid hardwired string literals |
111 | 234 | 30 | ER-030 | 3 | Avoid hardwired string literals |
112 | 237 | 17 | ER-030 | 3 | Avoid hardwired string literals |
113 | 242 | 22 | ER-030 | 3 | Avoid hardwired string literals |
114 | 244 | 26 | ER-030 | 3 | Avoid hardwired string literals |
115 | 246 | 17 | ER-030 | 3 | Avoid hardwired string literals |
116 | 250 | 26 | ER-030 | 3 | Avoid hardwired string literals |
117 | 252 | 30 | ER-030 | 3 | Avoid hardwired string literals |
118 | 254 | 21 | ER-030 | 3 | Avoid hardwired string literals |
119 | 259 | 26 | ER-030 | 3 | Avoid hardwired string literals |
120 | 261 | 17 | ER-030 | 3 | Avoid hardwired string literals |
121 | 264 | 9 | ER-113 | 2 | Unused private/local variables |
122 | 265 | 22 | ER-030 | 3 | Avoid hardwired string literals |
123 | 267 | 26 | ER-030 | 3 | Avoid hardwired string literals |
124 | 269 | 17 | ER-030 | 3 | Avoid hardwired string literals |
125 | 274 | 26 | ER-030 | 3 | Avoid hardwired string literals |
126 | 276 | 17 | ER-030 | 3 | Avoid hardwired string literals |
127 | 281 | 26 | ER-030 | 3 | Avoid hardwired string literals |
128 | 283 | 17 | ER-030 | 3 | Avoid hardwired string literals |
129 | 288 | 26 | ER-030 | 3 | Avoid hardwired string literals |
130 | 290 | 30 | ER-030 | 3 | Avoid hardwired string literals |
131 | 292 | 21 | ER-030 | 3 | Avoid hardwired string literals |
132 | 297 | 26 | ER-030 | 3 | Avoid hardwired string literals |
133 | 299 | 30 | ER-030 | 3 | Avoid hardwired string literals |
134 | 301 | 21 | ER-030 | 3 | Avoid hardwired string literals |
135 | 306 | 26 | ER-030 | 3 | Avoid hardwired string literals |
136 | 308 | 30 | ER-030 | 3 | Avoid hardwired string literals |
137 | 310 | 21 | ER-030 | 3 | Avoid hardwired string literals |
138 | 315 | 26 | ER-030 | 3 | Avoid hardwired string literals |
139 | 317 | 30 | ER-030 | 3 | Avoid hardwired string literals |
140 | 319 | 21 | ER-030 | 3 | Avoid hardwired string literals |
141 | 324 | 26 | ER-030 | 3 | Avoid hardwired string literals |
142 | 326 | 30 | ER-030 | 3 | Avoid hardwired string literals |
143 | 328 | 21 | ER-030 | 3 | Avoid hardwired string literals |
144 | 333 | 30 | ER-030 | 3 | Avoid hardwired string literals |
145 | 335 | 21 | ER-030 | 3 | Avoid hardwired string literals |
146 | 340 | 26 | ER-030 | 3 | Avoid hardwired string literals |
147 | 342 | 30 | ER-030 | 3 | Avoid hardwired string literals |
148 | 344 | 21 | ER-030 | 3 | Avoid hardwired string literals |
149 | 349 | 26 | ER-030 | 3 | Avoid hardwired string literals |
150 | 351 | 30 | ER-030 | 3 | Avoid hardwired string literals |
151 | 353 | 21 | ER-030 | 3 | Avoid hardwired string literals |
152 | 358 | 26 | ER-030 | 3 | Avoid hardwired string literals |
153 | 360 | 30 | ER-030 | 3 | Avoid hardwired string literals |
154 | 362 | 21 | ER-030 | 3 | Avoid hardwired string literals |
155 | 367 | 26 | ER-030 | 3 | Avoid hardwired string literals |
156 | 369 | 30 | ER-030 | 3 | Avoid hardwired string literals |
157 | 371 | 21 | ER-030 | 3 | Avoid hardwired string literals |
158 | 376 | 26 | ER-030 | 3 | Avoid hardwired string literals |
159 | 378 | 30 | ER-030 | 3 | Avoid hardwired string literals |
160 | 380 | 21 | ER-030 | 3 | Avoid hardwired string literals |
161 | 385 | 30 | ER-030 | 3 | Avoid hardwired string literals |
162 | 387 | 21 | ER-030 | 3 | Avoid hardwired string literals |
163 | 392 | 30 | ER-030 | 3 | Avoid hardwired string literals |
164 | 394 | 21 | ER-030 | 3 | Avoid hardwired string literals |
165 | 399 | 30 | ER-030 | 3 | Avoid hardwired string literals |
166 | 401 | 21 | ER-030 | 3 | Avoid hardwired string literals |
167 | 406 | 30 | ER-030 | 3 | Avoid hardwired string literals |
168 | 408 | 21 | ER-030 | 3 | Avoid hardwired string literals |
169 | 413 | 26 | ER-030 | 3 | Avoid hardwired string literals |
170 | 414 | 30 | ER-030 | 3 | Avoid hardwired string literals |
171 | 417 | 17 | ER-030 | 3 | Avoid hardwired string literals |
172 | 421 | 61 | ER-030 | 3 | Avoid hardwired string literals |
173 | 421 | 108 | ER-030 | 3 | Avoid hardwired string literals |
174 | 425 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
175 | 427 | 33 | ER-030 | 3 | Avoid hardwired string literals |
176 | 435 | 34 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
177 | 443 | 43 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
178 | 448 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
179 | 449 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
180 | 456 | 46 | ER-030 | 3 | Avoid hardwired string literals |
181 | 461 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
182 | 470 | 9 | ER-011 | 1 | Cyclomatic complexity (13) exceeds 12 |
183 | 472 | 31 | ER-049 | 2 | Unify logging strategy - define individual logger for class |
184 | 477 | 33 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
185 | 478 | 76 | ER-030 | 3 | Avoid hardwired string literals |
186 | 485 | 64 | ER-030 | 3 | Avoid hardwired string literals |
187 | 488 | 64 | ER-030 | 3 | Avoid hardwired string literals |
188 | 491 | 64 | ER-030 | 3 | Avoid hardwired string literals |
189 | 494 | 64 | ER-030 | 3 | Avoid hardwired string literals |
190 | 497 | 64 | ER-030 | 3 | Avoid hardwired string literals |
191 | 504 | 57 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
192 | 508 | 57 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
193 | 512 | 57 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
194 | 513 | 72 | ER-030 | 3 | Avoid hardwired string literals |
195 | 516 | 78 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
196 | 516 | 57 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
197 | 521 | 57 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
198 | 534 | 57 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
199 | 549 | 9 | ER-011 | 1 | Cyclomatic complexity (17) exceeds 12 |
200 | 549 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
201 | 554 | 58 | ER-030 | 3 | Avoid hardwired string literals |
202 | 555 | 61 | ER-030 | 3 | Avoid hardwired string literals |
203 | 556 | 59 | ER-030 | 3 | Avoid hardwired string literals |
204 | 557 | 33 | ER-030 | 3 | Avoid hardwired string literals |
205 | 561 | 60 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
206 | 561 | 57 | ER-030 | 3 | Avoid hardwired string literals |
207 | 570 | 71 | ER-030 | 3 | Avoid hardwired string literals |
208 | 571 | 104 | ER-028 | 3 | Avoid hardwired character literals |
209 | 573 | 82 | ER-030 | 3 | Avoid hardwired string literals |
210 | 576 | 101 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
211 | 576 | 85 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
212 | 576 | 53 | ER-030 | 3 | Avoid hardwired string literals |
213 | 576 | 86 | ER-030 | 3 | Avoid hardwired string literals |
214 | 578 | 69 | ER-029 | 3 | Avoid hardwired numeric literals |
215 | 591 | 67 | ER-030 | 3 | Avoid hardwired string literals |
216 | 596 | 66 | ER-030 | 3 | Avoid hardwired string literals |
217 | 598 | 27 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
218 | 600 | 27 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
219 | 602 | 27 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
220 | 604 | 27 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
221 | 606 | 27 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
222 | 610 | 50 | ER-030 | 3 | Avoid hardwired string literals |
223 | 627 | 74 | ER-030 | 3 | Avoid hardwired string literals |
224 | 633 | 61 | ER-030 | 3 | Avoid hardwired string literals |
225 | 638 | 74 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
226 | 638 | 45 | ER-030 | 3 | Avoid hardwired string literals |
227 | 638 | 75 | ER-030 | 3 | Avoid hardwired string literals |
228 | 640 | 108 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
229 | 640 | 66 | ER-030 | 3 | Avoid hardwired string literals |
230 | 640 | 109 | ER-030 | 3 | Avoid hardwired string literals |
231 | 643 | 19 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
232 | 644 | 46 | ER-030 | 3 | Avoid hardwired string literals |
233 | 654 | 41 | ER-030 | 3 | Avoid hardwired string literals |
234 | 655 | 54 | ER-030 | 3 | Avoid hardwired string literals |
235 | 658 | 41 | ER-030 | 3 | Avoid hardwired string literals |
236 | 659 | 75 | ER-030 | 3 | Avoid hardwired string literals |
237 | 662 | 41 | ER-030 | 3 | Avoid hardwired string literals |
238 | 663 | 78 | ER-030 | 3 | Avoid hardwired string literals |
239 | 666 | 41 | ER-030 | 3 | Avoid hardwired string literals |
240 | 667 | 79 | ER-030 | 3 | Avoid hardwired string literals |
241 | 670 | 41 | ER-030 | 3 | Avoid hardwired string literals |
242 | 671 | 34 | ER-030 | 3 | Avoid hardwired string literals |
243 | 671 | 67 | ER-030 | 3 | Avoid hardwired string literals |
244 | 674 | 41 | ER-030 | 3 | Avoid hardwired string literals |
245 | 675 | 44 | ER-030 | 3 | Avoid hardwired string literals |
246 | 675 | 77 | ER-030 | 3 | Avoid hardwired string literals |
247 | 678 | 41 | ER-030 | 3 | Avoid hardwired string literals |
248 | 679 | 66 | ER-030 | 3 | Avoid hardwired string literals |
249 | 683 | 41 | ER-030 | 3 | Avoid hardwired string literals |
250 | 684 | 59 | ER-030 | 3 | Avoid hardwired string literals |
251 | 688 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
252 | 711 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
253 | 712 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
254 | 725 | 34 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
255 | 725 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
256 | 749 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
257 | 764 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
258 | 800 | 32 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
259 | 810 | 64 | ER-047 | 2 | Operation (method or constructor) declares subclasses of RuntimeException in throws clause |
260 | 810 | 38 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
261 | 818 | 69 | ER-047 | 2 | Operation (method or constructor) declares subclasses of RuntimeException in throws clause |
262 | 818 | 39 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
263 | 818 | 39 | ER-048 | 1 | Use BigDecimal instead of Float or Double for monetary values |
264 | 822 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
265 | 838 | 92 | ER-047 | 2 | Operation (method or constructor) declares subclasses of RuntimeException in throws clause |
266 | 848 | 45 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
267 | 852 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
268 | 858 | 39 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
269 | 868 | 42 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
270 | 876 | 30 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
271 | 880 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
272 | 880 | 34 | ER-030 | 3 | Avoid hardwired string literals |
273 | 888 | 9 | ER-011 | 1 | Cyclomatic complexity (33) exceeds 12 |
274 | 888 | 9 | ER-041 | 2 | Method is too long |
275 | 889 | 23 | ER-102 | 2 | String Arrays are deprecated and are ONLY allowed for final variables |
276 | 889 | 23 | ER-104 | 2 | Use a Collection instead of arrays Object[] |
277 | 891 | 35 | ER-111 | 1 | LOG4J is mandatory for all logging in ERC. System.out.println will be lost in a system console of our web/app server. |
278 | 891 | 36 | ER-030 | 3 | Avoid hardwired string literals |
279 | 895 | 33 | ER-028 | 3 | Avoid hardwired character literals |
280 | 900 | 36 | ER-028 | 3 | Avoid hardwired character literals |
281 | 902 | 45 | ER-030 | 3 | Avoid hardwired string literals |
282 | 906 | 48 | ER-028 | 3 | Avoid hardwired character literals |
283 | 907 | 35 | ER-111 | 1 | LOG4J is mandatory for all logging in ERC. System.out.println will be lost in a system console of our web/app server. |
284 | 907 | 36 | ER-030 | 3 | Avoid hardwired string literals |
285 | 911 | 28 | ER-028 | 3 | Avoid hardwired character literals |
286 | 912 | 58 | ER-028 | 3 | Avoid hardwired character literals |
287 | 924 | 23 | ER-102 | 2 | String Arrays are deprecated and are ONLY allowed for final variables |
288 | 924 | 23 | ER-104 | 2 | Use a Collection instead of arrays Object[] |
289 | 924 | 54 | ER-028 | 3 | Avoid hardwired character literals |
290 | 929 | 45 | ER-028 | 3 | Avoid hardwired character literals |
291 | 934 | 45 | ER-028 | 3 | Avoid hardwired character literals |
292 | 939 | 45 | ER-028 | 3 | Avoid hardwired character literals |
293 | 946 | 45 | ER-028 | 3 | Avoid hardwired character literals |
294 | 953 | 54 | ER-028 | 3 | Avoid hardwired character literals |
295 | 955 | 55 | ER-028 | 3 | Avoid hardwired character literals |
296 | 957 | 36 | ER-028 | 3 | Avoid hardwired character literals |
297 | 958 | 58 | ER-028 | 3 | Avoid hardwired character literals |
298 | 961 | 36 | ER-028 | 3 | Avoid hardwired character literals |
299 | 962 | 67 | ER-028 | 3 | Avoid hardwired character literals |
300 | 965 | 36 | ER-028 | 3 | Avoid hardwired character literals |
301 | 966 | 54 | ER-028 | 3 | Avoid hardwired character literals |
302 | 975 | 36 | ER-028 | 3 | Avoid hardwired character literals |
303 | 979 | 36 | ER-028 | 3 | Avoid hardwired character literals |
304 | 988 | 36 | ER-028 | 3 | Avoid hardwired character literals |
305 | 989 | 69 | ER-028 | 3 | Avoid hardwired character literals |
306 | 992 | 36 | ER-028 | 3 | Avoid hardwired character literals |
307 | 993 | 82 | ER-028 | 3 | Avoid hardwired character literals |
308 | 996 | 36 | ER-028 | 3 | Avoid hardwired character literals |
309 | 997 | 79 | ER-028 | 3 | Avoid hardwired character literals |
310 | 1000 | 36 | ER-028 | 3 | Avoid hardwired character literals |
311 | 1001 | 83 | ER-028 | 3 | Avoid hardwired character literals |
312 | 1004 | 28 | ER-028 | 3 | Avoid hardwired character literals |
313 | 1008 | 28 | ER-028 | 3 | Avoid hardwired character literals |
314 | 1012 | 36 | ER-028 | 3 | Avoid hardwired character literals |
315 | 1013 | 66 | ER-028 | 3 | Avoid hardwired character literals |
316 | 1016 | 45 | ER-028 | 3 | Avoid hardwired character literals |
317 | 1021 | 45 | ER-028 | 3 | Avoid hardwired character literals |
318 | 1026 | 45 | ER-028 | 3 | Avoid hardwired character literals |
319 | 1033 | 45 | ER-028 | 3 | Avoid hardwired character literals |
320 | 1038 | 45 | ER-028 | 3 | Avoid hardwired character literals |
321 | 1043 | 36 | ER-028 | 3 | Avoid hardwired character literals |
322 | 1044 | 65 | ER-028 | 3 | Avoid hardwired character literals |
323 | 1048 | 36 | ER-028 | 3 | Avoid hardwired character literals |
324 | 1049 | 59 | ER-028 | 3 | Avoid hardwired character literals |
325 | 1058 | 36 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
326 | 1070 | 82 | ER-047 | 2 | Operation (method or constructor) declares subclasses of RuntimeException in throws clause |
327 | 1070 | 33 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
328 | 1073 | 111 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
329 | 1073 | 90 | ER-030 | 3 | Avoid hardwired string literals |
330 | 1079 | 50 | ER-030 | 3 | Avoid hardwired string literals |
331 | 1085 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
332 | 1087 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
333 | 1088 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
334 | 1096 | 43 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
335 | 1105 | 30 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
336 | 1124 | 17 | ER-080 | 1 | Avoid "for", "do", "while", "if" and "if ... else" statements with empty bodies |
337 | 1124 | 21 | ER-030 | 3 | Avoid hardwired string literals |
338 | 1124 | 49 | ER-096 | 3 | Empty statements |
339 | 1126 | 28 | ER-030 | 3 | Avoid hardwired string literals |
340 | 1128 | 28 | ER-030 | 3 | Avoid hardwired string literals |
341 | 1131 | 50 | ER-030 | 3 | Avoid hardwired string literals |
342 | 1137 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
343 | 1145 | 40 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
344 | 1149 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
345 | 1150 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
346 | 1157 | 42 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
347 | 1168 | 33 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
348 | 1172 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
349 | 1176 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
350 | 1180 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
351 | 1180 | 31 | ER-029 | 3 | Avoid hardwired numeric literals |
352 | 1187 | 32 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
353 | 1191 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
354 | 1200 | 33 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
355 | 1204 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
1/*
2 * Hammurapi
3 * Automated Java code review system.
4 * Copyright (C) 2004 Hammurapi Group
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * URL: http://www.hammurapi.org
21 * e-Mail: support@hammurapi.biz
22 */
23package org.hammurapi;
24
25import java.io.File;
26import java.io.FileNotFoundException;
27import java.io.FileOutputStream;
28import java.io.IOException;
29import java.io.InputStream;
30import java.io.PrintStream;
31import java.text.ParseException;
32import java.text.SimpleDateFormat;
33import java.util.ArrayList;
34import java.util.Collection;
35import java.util.Date;
36import java.util.Enumeration;
37import java.util.HashSet;
38import java.util.Iterator;
39import java.util.LinkedList;
40import java.util.List;
41import java.util.zip.ZipEntry;
42import java.util.zip.ZipException;
43import java.util.zip.ZipFile;
44
45import javax.xml.parsers.DocumentBuilderFactory;
46import javax.xml.parsers.FactoryConfigurationError;
47import javax.xml.parsers.ParserConfigurationException;
48import javax.xml.transform.TransformerException;
49
50import org.apache.commons.cli.CommandLine;
51import org.apache.commons.cli.HelpFormatter;
52import org.apache.commons.cli.Option;
53import org.apache.commons.cli.OptionBuilder;
54import org.apache.commons.cli.Options;
55import org.apache.tools.ant.BuildException;
56import org.apache.tools.ant.BuildLogger;
57import org.apache.tools.ant.DefaultLogger;
58import org.apache.tools.ant.DemuxOutputStream;
59import org.apache.tools.ant.Project;
60import org.apache.tools.ant.Task;
61import org.apache.tools.ant.types.FileSet;
62import org.apache.tools.ant.types.Path;
63import org.apache.xpath.CachedXPathAPI;
64import org.hammurapi.render.dom.DetailedResultsRenderer;
65import org.hammurapi.results.persistent.jdbc.BaselineSetupViolationFilter;
66import org.hammurapi.results.persistent.jdbc.BaselineViolationFilter;
67import org.w3c.dom.Document;
68import org.w3c.dom.Element;
69import org.w3c.dom.traversal.NodeIterator;
70import org.xml.sax.SAXException;
71
72import com.pavelvlasov.ant.ObjectEntry;
73import com.pavelvlasov.ant.XmlSourceEntry;
74import com.pavelvlasov.jsel.RevisionMapper;
75import com.pavelvlasov.render.RenderRequest;
76import com.pavelvlasov.render.RenderingException;
77import com.pavelvlasov.render.dom.AbstractRenderer;
78import com.pavelvlasov.review.Signed;
79import com.pavelvlasov.util.ClassResourceLoader;
80import com.pavelvlasov.xml.dom.AbstractDomObject;
81
82/**
83 * @author Pavel Vlasov
84 *
85 * @version $Revision: 1.9 $
86 */
87public class TaskBase extends Task {
88
89 protected void deleteFile(File file) {
90 if (file!=null) {
91 if (file.isDirectory()) {
92 File[] children=file.listFiles();
93 if (children!=null) {
94 for (int i=0; i<children.length; i++) {
95 deleteFile(children[i]);
96 }
97 }
98 }
99
100 if (file.isFile() || file.isDirectory()) {
101 file.delete();
102 }
103 }
104 }
105
106 /**
107 * @return Returns the reviewAcceptorEntries.
108 */
109 protected List getReviewAcceptorEntries() {
110 return reviewAcceptorEntries;
111 }
112
113 /**
114 * @return Returns the severityThreshold.
115 */
116 protected Integer getSeverityThreshold() {
117 return severityThreshold;
118 }
119
120 /**
121 * @return Returns the dpmoThreshold.
122 */
123 protected Double getSigmaThreshold() {
124 return sigmaThreshold;
125 }
126
127 /**
128 * @return Returns the dpmoThreshold.
129 */
130 protected Integer getDpmoThreshold() {
131 return dpmoThreshold;
132 }
133
134 /**
135 * @return Returns the failOnWarnings.
136 */
137 protected boolean isFailOnWarnings() {
138 return failOnWarnings;
139 }
140
141 private File unpackDir;
142
143 /**
144 * If this attribute is set then HAR archive will be unpacked
145 * in the given directory instead of a temporary one.
146 * @ant.non-required
147 * @param unpackDir
148 */
149 public void setUnpackDir(File unpackDir) {
150 this.unpackDir=unpackDir;
151 }
152
153 /**
154 * @return Returns the debugType.
155 * @ant.ignore
156 */
157 public String getDebugType() {
158 return debugType;
159 }
160
161 protected Collection srcFiles = new LinkedList();
162
163 protected static void loadEmbeddedInspectors(InspectorSet inspectorSet) throws BuildException, HammurapiException {
164 ClassResourceLoader crl=new ClassResourceLoader(TaskBase.class);
165 InputStream inspectorStream=crl.getResourceAsStream(null, null, "xml");
166 if (inspectorStream==null) {
167 throw new BuildException("Cannot load embedded inspectors");
168 }
169
170 DomInspectorSource source=new DomInspectorSource(inspectorStream, "Hammurapi.jar");
171 source.loadInspectors(inspectorSet);
172 }
173
174 /**
175 * @param options
176 */
177 protected static void populateOptions(Options options) {
178 Option waiverStubsOption=OptionBuilder
179 .withArgName("waiverStubs")
180 .hasArg()
181 .withDescription("Where to output waiver stubs")
182 .isRequired(false)
183 .create("w");
184
185 options.addOption(waiverStubsOption);
186
187 Option databaseOption=OptionBuilder
188 .withDescription("Database name")
189 .withArgName("local database")
190 .hasArg()
191 .isRequired(false)
192 .create("D");
193
194 options.addOption(databaseOption);
195
196 Option includeInspectorOption=OptionBuilder
197 .withDescription("Enable inspector")
198 .withArgName("inspector name")
199 .hasArg()
200 .isRequired(false)
201 .create("I");
202
203 options.addOption(includeInspectorOption);
204
205 Option configFileOption=OptionBuilder
206 .withDescription("Config file")
207 .withArgName("file")
208 .hasArg()
209 .isRequired(false)
210 .create("m");
211
212 options.addOption(configFileOption);
213
214 Option configUrlOption=OptionBuilder
215 .withDescription("Config url")
216 .withArgName("url")
217 .hasArg()
218 .isRequired(false)
219 .create("q");
220
221 options.addOption(configUrlOption);
222
223 Option unpackDirOption=OptionBuilder
224 .withDescription("Unpack directory")
225 .withArgName("directory")
226 .hasArg()
227 .isRequired(false)
228 .create("r");
229
230 options.addOption(unpackDirOption);
231
232 Option excludeInspectorOption=OptionBuilder
233 .withDescription("Disable inspector")
234 .withArgName("inspector name")
235 .hasArg()
236 .isRequired(false)
237 .create("X");
238
239 options.addOption(excludeInspectorOption);
240
241 Option archiveFileOption=OptionBuilder
242 .withArgName("archive")
243 .hasArg()
244 .withDescription("Hammurapi archive")
245 .isRequired(false)
246 .create("A");
247
248 options.addOption(archiveFileOption);
249 Option waiversFileOption=OptionBuilder
250 .withArgName("waivers file")
251 .hasArg()
252 .withDescription("Waivers File")
253 .isRequired(false)
254 .create("W");
255
256 options.addOption(waiversFileOption);
257
258 Option forceOption=OptionBuilder
259 .withDescription("Force reviews of unchanged files")
260 .isRequired(false)
261 .create("f");
262
263 //Anu 20050701 : Baselining.Moved from HammurapiTask.java
264 Option baseliningOption=OptionBuilder
265 .withArgName("off|on|set")
266 .hasArg()
267 .withDescription("Baselining mode")
268 .isRequired(false)
269 .create("B");
270
271 options.addOption(forceOption);
272
273 Option forceOnWarningsOption=OptionBuilder
274 .withDescription("Do not force reviews of files with warnings")
275 .isRequired(false)
276 .create("k");
277
278 options.addOption(forceOnWarningsOption);
279
280 Option doNotEvictOption=OptionBuilder
281 .withDescription("Evict bad inspectors")
282 .isRequired(false)
283 .create("E");
284
285 options.addOption(doNotEvictOption);
286
287 Option waiversUrlOption=OptionBuilder
288 .withArgName("waivers url")
289 .hasArg()
290 .withDescription("Waivers URL")
291 .isRequired(false)
292 .create("U");
293
294 options.addOption(waiversUrlOption);
295
296 Option classPathOption=OptionBuilder
297 .withArgName("classpath")
298 .hasArg()
299 .withDescription("ClassPath")
300 .isRequired(false)
301 .create("c");
302
303 options.addOption(classPathOption);
304
305 Option sigmaThresholdOption=OptionBuilder
306 .withArgName("sigmaThreshold")
307 .hasArg()
308 .withDescription("Sigma threshold")
309 .isRequired(false)
310 .create("s");
311
312 options.addOption(sigmaThresholdOption);
313
314 Option dpmoThresholdOption=OptionBuilder
315 .withArgName("dpmoThreshold")
316 .hasArg()
317 .withDescription("DPMO Threshold")
318 .isRequired(false)
319 .create("d");
320
321 options.addOption(dpmoThresholdOption);
322
323 Option severityThresholdOption=OptionBuilder
324 .withArgName("severityThreshold")
325 .hasArg()
326 .withDescription("Severity threshold")
327 .isRequired(false)
328 .create("S");
329
330 options.addOption(severityThresholdOption);
331
332 Option noEmbeddedInspectorsOption=OptionBuilder
333 .withDescription("Do not load embedded inspectors")
334 .isRequired(false)
335 .create("e");
336
337 options.addOption(noEmbeddedInspectorsOption);
338
339 Option inspectorsFileOption=OptionBuilder
340 .withArgName("inspectorsFile")
341 .hasArg()
342 .withDescription("Inspectors file")
343 .isRequired(false)
344 .create("i");
345
346 options.addOption(inspectorsFileOption);
347
348 Option inspectorsURLOption=OptionBuilder
349 .withArgName("inspectorsURL")
350 .hasArg()
351 .withDescription("Inspectors URL")
352 .isRequired(false)
353 .create("u");
354
355 options.addOption(inspectorsURLOption);
356
357 Option titleOption=OptionBuilder
358 .withArgName("title")
359 .hasArg()
360 .withDescription("Report title")
361 .isRequired(false)
362 .create("T");
363
364 options.addOption(titleOption);
365
366 Option debugTypeOption=OptionBuilder
367 .withArgName("debug type")
368 .hasArg()
369 .withDescription("Jsel type to debug")
370 .isRequired(false)
371 .create("t");
372
373 options.addOption(debugTypeOption);
374
375 Option listenerOption=OptionBuilder
376 .withArgName("class name")
377 .hasArg()
378 .withDescription("Review listener")
379 .isRequired(false)
380 .create("l");
381
382 options.addOption(listenerOption);
383
384 Option debugOption=OptionBuilder
385 .withDescription("Debug")
386 .isRequired(false)
387 .create("g");
388
389 options.addOption(debugOption);
390
391 Option verboseOption=OptionBuilder
392 .withDescription("Verbose")
393 .isRequired(false)
394 .create("v");
395
396 options.addOption(verboseOption);
397
398 Option xmlOption=OptionBuilder
399 .withDescription("Output XML")
400 .isRequired(false)
401 .create("x");
402
403 options.addOption(xmlOption);
404
405 Option suppressOutputOption=OptionBuilder
406 .withDescription("Suppress output")
407 .isRequired(false)
408 .create("o");
409
410 options.addOption(suppressOutputOption);
411
412 Option descriptionOption=OptionBuilder
413 .withDescription("Review description")
414 .withArgName("description")
415 .hasArg()
416 .isRequired(false)
417 .create("y");
418
419 options.addOption(descriptionOption);
420
421 Option helpOption=OptionBuilder.withDescription("Print this message").isRequired(false).create("h");
422 options.addOption(helpOption);
423 }
424
425 protected static void printHelpAndExit(Options options) {
426 HelpFormatter formatter=new HelpFormatter();
427 formatter.printHelp("Usage: hammurapi [options] <output dir> <source files/dirs>", options, false);
428 System.exit(1);
429 }
430
431 /**
432 * Class name to debug
433 * @ant.non-required
434 */
435 public void setDebugType(String debugType) {
436 this.debugType=debugType;
437 }
438
439 /**
440 * Load embedded inspectors. Defaults to true.
441 * @ant.non-required
442 */
443 public void setEmbeddedInspectors(boolean embeddedInspectors) {
444 this.embeddedInspectors=embeddedInspectors;
445 }
446
447 private String debugType;
448 protected boolean embeddedInspectors = true;
449 protected List srcFileSets = new LinkedList();
450
451 /**
452 * Source files fileset.
453 * @ant.non-required
454 */
455 public FileSet createSrc() {
456 FileSet ret=new HammurapiFileSet("**/*.java");
457 srcFileSets.add(ret);
458 return ret;
459 }
460
461 protected void setHadExceptions() {
462 hadExceptions=true;
463 }
464
465 /**
466 * @param collection
467 * @throws FileNotFoundException
468 * @throws RenderingException
469 */
470 protected void writeWaiverStubs(final Collection rejectedViolations) throws RenderingException, FileNotFoundException {
471 if (waiverStubs!=null) {
472 class WaiverStubsRenderer extends AbstractRenderer {
473 WaiverStubsRenderer() {
474 super(new RenderRequest(rejectedViolations));
475 }
476
477 public Element render(Document document) {
478 Element ret=document.createElement("waivers");
479 Iterator it=rejectedViolations.iterator();
480 final Date now=new Date();
481 while (it.hasNext()) {
482 final Violation violation=(Violation) it.next();
483
484 StringBuffer comment=new StringBuffer();
485 comment.append("Source: ");
486 comment.append(violation.getSource().getSourceURL());
487
488 comment.append("\nLine: ");
489 comment.append(violation.getSource().getLine());
490
491 comment.append("\nCol: ");
492 comment.append(violation.getSource().getColumn());
493
494 comment.append("\nDescription: ");
495 comment.append(violation.getDescriptor().getDescription());
496
497 comment.append("\nMesssage: ");
498 comment.append(violation.getMessage());
499
500 ret.appendChild(document.createComment(comment.toString()));
501
502 Waiver waiver=new Waiver() {
503
504 public String getInspectorName() {
505 return violation.getDescriptor().getName();
506 }
507
508 public Date getExpirationDate() {
509 return now;
510 }
511
512 public String getReason() {
513 return "*** Put reason here ***";
514 }
515
516 public boolean waive(Violation violation, boolean peek) {
517 // This 'waiver' will never waive anything, it is used only for rendering
518 return false;
519 }
520
521 public boolean isActive() {
522 // This 'waiver' will never waive anything, it is used only for rendering
523 return false;
524 }
525
526 Collection signatures=new HashSet();
527
528 {
529 if (violation.getSource() instanceof Signed) {
530 signatures.add(((Signed) violation.getSource()).getSignature());
531 }
532 }
533
534 public Collection getSignatures() {
535 return signatures;
536 }
537 };
538 ret.appendChild(DetailedResultsRenderer.renderWaiver(waiver, document));
539 }
540 return ret;
541 }
542 }
543 WaiverStubsRenderer renderer=new WaiverStubsRenderer();
544 renderer.setEmbeddedStyle(false);
545 renderer.render(new FileOutputStream(waiverStubs));
546 }
547 }
548
549 protected File processArchive() {
550 if (archive==null) {
551 return null;
552 }
553
554 String tmpDirProperty=System.getProperty("java.io.tmpdir");
555 File tmpDir=tmpDirProperty==null ? new File(".") : new File(tmpDirProperty);
556 SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
557 String prefix = "har_"+sdf.format(new Date());
558 File workDir = unpackDir==null ? new File(tmpDir, prefix) : unpackDir;
559
560 for (int i=0; unpackDir==null && workDir.exists(); i++) {
561 workDir=new File(tmpDir, prefix+"_"+Integer.toString(i, Character.MAX_RADIX));
562 }
563
564 if (workDir.exists() || workDir.mkdir()) {
565 try {
566 ZipFile zipFile=new ZipFile(archive);
567 Enumeration entries = zipFile.entries();
568 while (entries.hasMoreElements()) {
569 ZipEntry entry=(ZipEntry) entries.nextElement();
570 if (!entry.getName().endsWith("/")) {
571 File outFile=new File(workDir, entry.getName().replace('/', File.separatorChar));
572 if (!outFile.getParentFile().exists() && !outFile.getParentFile().mkdirs()) {
573 throw new BuildException("Directory does not exist and cannot be created: "+outFile.getParentFile().getAbsolutePath());
574 }
575
576 log("Archive entry "+entry.getName()+" unpacked to "+outFile.getAbsolutePath(), Project.MSG_DEBUG);
577
578 byte[] buf=new byte[4096];
579 int l;
580 InputStream in=zipFile.getInputStream(entry);
581 FileOutputStream fos=new FileOutputStream(outFile);
582 while ((l=in.read(buf))!=-1) {
583 fos.write(buf, 0, l);
584 }
585 in.close();
586 fos.close();
587 }
588 }
589 zipFile.close();
590
591 File configFile=new File(workDir, "config.xml");
592 if (configFile.exists() && configFile.isFile()) {
593 Document configDoc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(configFile);
594 processConfig(workDir, configDoc.getDocumentElement());
595 } else {
596 throw new BuildException("Archive configuration file does not exist or is not a file");
597 }
598 } catch (ZipException e) {
599 throw new BuildException(e.toString(), e);
600 } catch (IOException e) {
601 throw new BuildException(e.toString(), e);
602 } catch (SAXException e) {
603 throw new BuildException(e.toString(), e);
604 } catch (ParserConfigurationException e) {
605 throw new BuildException(e.toString(), e);
606 } catch (FactoryConfigurationError e) {
607 throw new BuildException(e.toString(), e);
608 }
609 } else {
610 throw new BuildException("Could not create directory "+workDir.getAbsolutePath());
611 }
612 return unpackDir==null ? workDir : null;
613 }
614
615 /**
616 * @param workDir
617 * @param configDoc
618 * @throws ParseException
619 * @throws TransformerException
620 */
621 private void processConfig(File workDir, Element config) {
622 if (config!=null) {
623 try {
624 setAttributes(config);
625
626 CachedXPathAPI cxpa=new CachedXPathAPI();
627 NodeIterator nit=cxpa.selectNodeIterator(config, "sources/source");
628 Element element;
629 while ((element=(Element) nit.nextNode())!=null) {
630 srcFiles.add(new File(workDir, AbstractDomObject.getElementText(element)));
631 }
632
633 nit=cxpa.selectNodeIterator(config, "classpath/path");
634 while ((element=(Element) nit.nextNode())!=null) {
635 File cpe = new File(workDir, AbstractDomObject.getElementText(element));
636 if (cpe.exists()) {
637 createClasspath().setLocation(cpe);
638 log("File "+cpe.getAbsolutePath()+" added to classpath", Project.MSG_DEBUG);
639 } else {
640 throw new BuildException("Classpath element "+cpe.getAbsolutePath()+" does not exist");
641 }
642 }
643 } catch (TransformerException e) {
644 throw new BuildException("Cannot load config", e);
645 }
646 }
647 }
648
649 /**
650 * @param config
651 * @throws ParseException
652 */
653 protected void setAttributes(Element config) {
654 if (config.hasAttribute("title")) {
655 setTitle(config.getAttribute("title"));
656 }
657
658 if (config.hasAttribute("dpmo-threshold")) {
659 setDpmoThreshold(Integer.parseInt(config.getAttribute("dpmo-threshold")));
660 }
661
662 if (config.hasAttribute("sigma-threshold")) {
663 setSigmaThreshold(Double.parseDouble(config.getAttribute("sigma-threshold")));
664 }
665
666 if (config.hasAttribute("severity-threshold")) {
667 setSeverityThreshold(Integer.parseInt(config.getAttribute("severity-threshold")));
668 }
669
670 if (config.hasAttribute("force")) {
671 setForce("yes".equals(config.getAttribute("force")));
672 }
673
674 if (config.hasAttribute("force-on-warnings")) {
675 setForceOnWarnings("yes".equals(config.getAttribute("force-on-warnings")));
676 }
677
678 if (config.hasAttribute("review-description")) {
679 setReviewDescription(config.getAttribute("review-description"));
680 }
681
682 //Anu : 20050701 for baselining
683 if (config.hasAttribute("baselining")) {
684 setBaselining(config.getAttribute("baselining"));
685 }
686 }
687
688 protected boolean suppressLogo;
689
690 /**
691 * Defines output
692 * @ant.non-required
693 */
694 public Output createOutput() {
695 Output output=new Output(this);
696 outputs.add(output);
697 return output;
698 }
699
700 /**
701 * Defines history output, which stores review summary
702 * into database.
703 * @ant.non-required
704 */
705 public HistoryOutput createHistoryOutput() {
706 HistoryOutput historyOutput=new HistoryOutput();
707 outputs.add(historyOutput);
708 return historyOutput;
709 }
710
711 protected List outputs = new LinkedList();
712 protected boolean hadExceptions;
713
714 /**
715 * Maybe creates a nested classpath element.
716 * @ant :non-required
717 */
718 public Path createClasspath() {
719 if (classPath == null) {
720 classPath = new Path(project);
721 }
722 return classPath.createPath();
723 }
724
725 public void setClassPath(Path classPath) {
726 if (this.classPath == null) {
727 this.classPath = classPath;
728 } else {
729 this.classPath.append(classPath);
730 }
731 }
732
733 /**
734 * Classpath for loading classes.
735 * @ant :non-required
736 */
737 protected Path classPath;
738
739 /**
740 * Defines inspector
741 * @ant.non-required
742 */
743 public InspectorEntry createInspector() {
744 InspectorEntry inspectorEntry=new InspectorEntry();
745 inspectors.add(inspectorEntry);
746 return inspectorEntry;
747 }
748
749 protected List inspectors = new LinkedList();
750
751 /**
752 * Defines waivers source
753 * @ant.non-required
754 */
755 public WaiverSourceEntry createWaivers() {
756 WaiverSourceEntry ret=new WaiverSourceEntry();
757 ret.setProject(getProject());
758 waivers.add(ret);
759 return ret;
760 }
761
762 private Collection configs=new ArrayList();
763
764 protected void processConfigs(File baseDir) {
765 Iterator it=configs.iterator();
766 while (it.hasNext()) {
767 XmlSourceEntry xse=(XmlSourceEntry) it.next();
768 processConfig(xse.getFile()==null ? baseDir : xse.getFile(), xse.getDocumentElement());
769 }
770 }
771
772 /**
773 * Configuration source.
774 * Task can be configured from multiple sources.
775 * @ant.non-required
776 */
777 public XmlSourceEntry createConfig() {
778 XmlSourceEntry ret=new XmlSourceEntry();
779 configs.add(ret);
780 ret.setProject(getProject());
781 return ret;
782 }
783
784 /**
785 * Defines inspector source
786 * @ant.non-required
787 */
788 public InspectorSourceEntry createInspectors() {
789 InspectorSourceEntry ret=new InspectorSourceEntry();
790 inspectors.add(ret);
791 ret.setProject(getProject());
792 return ret;
793 }
794
795 /**
796 * Hammurapi archive to process.
797 * @ant.non-required
798 * @param archive
799 */
800 public void setArchive(File archive) {
801 this.archive=archive;
802 }
803
804 private File archive;
805
806 /**
807 * Fail build if project DPMO is above the threshold.
808 * @ant.non-required
809 */
810 public void setDpmoThreshold(int dpmoThreshold) throws BuildException {
811 this.dpmoThreshold=new Integer(dpmoThreshold);
812 }
813
814 /**
815 * Fail build if project Sigma is below the threshold.
816 * @ant.non-required
817 */
818 public void setSigmaThreshold(double sigmaThreshold) throws BuildException {
819 this.sigmaThreshold=new Double(sigmaThreshold);
820 }
821
822 protected Collection waivers = new LinkedList();
823 private Integer dpmoThreshold;
824 private Double sigmaThreshold;
825
826 /**
827 * Review listener
828 * @ant.non-required
829 */
830 public void addConfiguredListener(ListenerEntry listener) {
831 listenerEntries.add(listener);
832 }
833
834 /**
835 * Review acceptor.
836 * @ant.non-required
837 */
838 public void addConfiguredReviewAcceptor(ReviewAcceptorEntry reviewAcceptor) throws BuildException {
839 reviewAcceptorEntries.add(reviewAcceptor);
840 }
841
842 private List reviewAcceptorEntries = new LinkedList();
843
844 /**
845 * Fail build as soon as there is an exception. Default is false.
846 * @ant.non-required
847 */
848 public void setFailOnFirstException(boolean failOnFirstException) {
849 this.failOnFirstException=failOnFirstException;
850 }
851
852 protected boolean failOnFirstException = false;
853
854 /**
855 * Fail build if there have been warnings. Default is true.
856 * @ant.non-required
857 */
858 public void setFailOnWarnings(boolean failOnWarnings) {
859 this.failOnWarnings=failOnWarnings;
860 }
861
862 private boolean failOnWarnings = true;
863
864 /**
865 * Fail build on violations with severity levels lower or equal to the threshold.
866 * @ant.non-required
867 */
868 public void setSeverityThreshold(int severityThreshold) {
869 this.severityThreshold=new Integer(severityThreshold);
870 }
871
872 /**
873 * @ant.non-required
874 * @param title
875 */
876 public void setTitle(String title) {
877 this.title=title;
878 }
879
880 protected String title = "Summary "+new Date();
881
882 /**
883 * @param options
884 * @param line
885 * @param task
886 * @param project
887 */
888 protected void configure(Options options, CommandLine line) {
889 String[] largs=line.getArgs();
890 if (largs.length==0) {
891 System.out.println("Output dir has to be provided");
892 printHelpAndExit(options);
893 }
894
895 if (!line.hasOption('o')) {
896 new File(largs[0]).mkdirs();
897 Output output=createOutput();
898 output.setDir(largs[0]);
899
900 if (line.hasOption('x')) {
901 output.setEmbeddedStyle(false);
902 output.setExtension(".xml");
903 }
904 }
905
906 if (largs.length==1 && !line.hasOption('A')) {
907 System.out.println("At least one source directory or archive must be provided");
908 printHelpAndExit(options);
909 }
910
911 if (line.hasOption('y')) {
912 setReviewDescription(line.getOptionValue('y'));
913 }
914
915 for (int i=1; i<largs.length; i++) {
916 File file = new File(largs[i]);
917 if (file.isFile()) {
918 srcFiles.add(file);
919 } else if (file.isDirectory()) {
920 createSrc().setDir(file);
921 }
922 }
923
924 String[] values=line.getOptionValues('c');
925 for (int i=0; values!=null && i<values.length; i++) {
926 createClasspath().append(new Path(project, values[i]));
927 }
928
929 values=line.getOptionValues('m');
930 for (int i=0; values!=null && i<values.length; i++) {
931 createConfig().setFile(new File(values[i]));
932 }
933
934 values=line.getOptionValues('q');
935 for (int i=0; values!=null && i<values.length; i++) {
936 createConfig().setURL(values[i]);
937 }
938
939 values=line.getOptionValues('I');
940 for (int i=0; values!=null && i<values.length; i++) {
941 InspectorEntry ie = createInspector();
942 ie.setName(values[i]);
943 ie.setEnabled(true);
944 }
945
946 values=line.getOptionValues('X');
947 for (int i=0; values!=null && i<values.length; i++) {
948 InspectorEntry ie = createInspector();
949 ie.setName(values[i]);
950 ie.setEnabled(false);
951 }
952
953 setEvictBadInspectors(line.hasOption('E'));
954
955 setEmbeddedInspectors(!line.hasOption('e'));
956
957 if (line.hasOption('t')) {
958 setDebugType(line.getOptionValue('t'));
959 }
960
961 if (line.hasOption('r')) {
962 setUnpackDir(new File(line.getOptionValue('r')));
963 }
964
965 if (line.hasOption('T')) {
966 setTitle(line.getOptionValue('T'));
967 }
968
969 BuildLogger logger = new DefaultLogger();
970 logger.setMessageOutputLevel(Project.MSG_INFO);
971 logger.setOutputPrintStream(System.out);
972 logger.setErrorPrintStream(System.err);
973 logger.setEmacsMode(false);
974
975 if (line.hasOption('v')) {
976 logger.setMessageOutputLevel(Project.MSG_VERBOSE);
977 }
978
979 if (line.hasOption('g')) {
980 logger.setMessageOutputLevel(Project.MSG_DEBUG);
981 }
982
983 project.addBuildListener(logger);
984
985 System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
986 System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
987
988 if (line.hasOption('w')) {
989 setWaiverStubs(new File(line.getOptionValue('w')));
990 }
991
992 if (line.hasOption('s')) {
993 setSigmaThreshold(Double.parseDouble(line.getOptionValue('s')));
994 }
995
996 if (line.hasOption('d')) {
997 setDpmoThreshold(Integer.parseInt(line.getOptionValue('d')));
998 }
999
1000 if (line.hasOption('S')) {
1001 setSeverityThreshold(Integer.parseInt(line.getOptionValue('S')));
1002 }
1003
1004 if (line.hasOption('f')) {
1005 setForce(true);
1006 }
1007
1008 if (line.hasOption('k')) {
1009 setForceOnWarnings(false);
1010 }
1011
1012 if (line.hasOption('D')) {
1013 setDatabase(new File(line.getOptionValue('D')));
1014 }
1015
1016 values=line.getOptionValues('i');
1017 for (int i=0; values!=null && i<values.length; i++) {
1018 createInspectors().setFile(new File(values[i]));
1019 }
1020
1021 values=line.getOptionValues('u');
1022 for (int i=0; values!=null && i<values.length; i++) {
1023 createInspectors().setURL(values[i]);
1024 }
1025
1026 values=line.getOptionValues('l');
1027 for (int i=0; values!=null && i<values.length; i++) {
1028 ListenerEntry listenerEntry = new ListenerEntry();
1029 listenerEntry.setClassName(values[i]);
1030 addConfiguredListener(listenerEntry);
1031 }
1032
1033 values=line.getOptionValues('W');
1034 for (int i=0; values!=null && i<values.length; i++) {
1035 createWaivers().setFile(new File(values[i]));
1036 }
1037
1038 values=line.getOptionValues('U');
1039 for (int i=0; values!=null && i<values.length; i++) {
1040 createWaivers().setURL(values[i]);
1041 }
1042
1043 if (line.hasOption('A')) {
1044 setArchive(new File(line.getOptionValue('A')));
1045 }
1046
1047 //Anu 20050701 : baselining
1048 if (line.hasOption('B')) {
1049 setBaselining(line.getOptionValue('B'));
1050 }
1051 }
1052
1053 /**
1054 * File to output waiver stubs for rejected waiver requests to. Selected waiver stubs can then be copied to waiver source. Simplifies waiver creation
1055 * @ant.non-required
1056 * @param waiverStubs
1057 */
1058 public void setWaiverStubs(File waiverStubs) {
1059 this.waiverStubs=waiverStubs;
1060 }
1061
1062 /**
1063 * Revision mapper. Must implement com.pavelvlasov.jsel.RevisionMapper interface.
1064 * @ant.non-required
1065 * @return
1066 */
1067 public ObjectEntry createRevisionMapper() {
1068 if (revisionMapper==null) {
1069 revisionMapper = new ObjectEntry() {
1070 protected void validateClass(Class clazz) throws BuildException {
1071 super.validateClass(clazz);
1072 if (!RevisionMapper.class.isAssignableFrom(clazz)) {
1073 throw new BuildException(clazz.getName()+" doesn't implement "+RevisionMapper.class.getName());
1074 }
1075 }
1076 };
1077 return revisionMapper;
1078 } else {
1079 throw new BuildException("Revision mapper already defined");
1080 }
1081 }
1082
1083 private File waiverStubs;
1084 private Integer severityThreshold;
1085 protected List listenerEntries = new LinkedList();
1086 ObjectEntry revisionMapper;
1087 protected boolean force = false;
1088 protected boolean evictBadInspectors = false;
1089
1090 /**
1091 * Remove inspector from inspector set if it throws an exception
1092 * during review
1093 * @param evictBadInspectors
1094 * @ant.non-required
1095 */
1096 public void setEvictBadInspectors(boolean evictBadInspectors) {
1097 this.evictBadInspectors=evictBadInspectors;
1098 }
1099
1100 /**
1101 * Force review even if the file is not changed
1102 * @param force
1103 * @ant.non-required
1104 */
1105 public void setForce(boolean force) {
1106 this.force=force;
1107 }
1108
1109 //Anu 20050701 : setBaselining method moved from HammurapiTask to TaskBase
1110 /**
1111 * Sets baselining mode. Possible values:
1112 * off (default) - no baselining, on - do not report
1113 * violations stored in the baseline table, set - all violations
1114 * from current scan are saved to the baseline table.
1115 * The idea is to filter out all violations in
1116 * preexisting code and report only new violations.
1117 * Not all violations can be filtered out, only thouse
1118 * with signatures. Significant code modifications can surface some
1119 * baselined violation.
1120 * @ant.non-required
1121 * @param baselineMode
1122 */
1123 public void setBaselining(String baselineMode) {
1124 if ("off".equals(baselineMode)) {
1125 // Nothing.
1126 } else if ("on".equals(baselineMode)) {
1127 violationFilters.add(new BaselineViolationFilter());
1128 } else if ("set".equalsIgnoreCase(baselineMode)) {
1129 violationFilters.add(new BaselineSetupViolationFilter());
1130 } else {
1131 throw new BuildException("Invalid baselining mode: "+baselineMode);
1132 }
1133
1134 }
1135
1136
1137 protected boolean forceOnWarnings = true;
1138
1139 /**
1140 * Force review of files with warnings, even if the file is not changed.
1141 * Default is true
1142 * @param
1143 * @ant.non-required
1144 */
1145 public void setForceOnWarnings(boolean forceOnWarnings) {
1146 this.forceOnWarnings=forceOnWarnings;
1147 }
1148
1149 protected File database;
1150 protected String reviewDescription;
1151
1152 /**
1153 * Description of review, e.g. release number. Appears in history annotation.
1154 * @ant.non-required
1155 * @param baseLine
1156 */
1157 public void setReviewDescription(String reviewDescription) {
1158 this.reviewDescription=reviewDescription;
1159 }
1160
1161 /**
1162 * If this parameter is set then Hypersonic standalone database
1163 * will be used instead of temporary database. You must set
1164 * database name if you want to run incremental reviews.
1165 * @ant.non-required
1166 * @param database
1167 */
1168 public void setDatabase(File database) {
1169 this.database=database;
1170 }
1171
1172 protected boolean isForceOnWarnings() {
1173 return forceOnWarnings;
1174 }
1175
1176 protected boolean isForce() {
1177 return force;
1178 }
1179
1180 protected int tabSize=8;
1181
1182 /**
1183 * Tab size in source files. Defaults to 8.
1184 * @param tabSize The tabSize to set.
1185 * @ant.non-required
1186 */
1187 public void setTabSize(int tabSize) {
1188 this.tabSize = tabSize;
1189 }
1190
1191 protected Collection violationFilters = new ArrayList();
1192
1193 private String encoding;
1194
1195 /**
1196 * Files encoding
1197 * @param encoding
1198 * @ant.non-required
1199 */
1200 public void setEncoding(String encoding) {
1201 this.encoding = encoding;
1202 }
1203
1204 protected String getEncoding() {
1205 return encoding;
1206 }
1207}
1208
1209