QuickSummary.java


Package: org.hammurapi

Results
Date2007/07/27
Codebase4216
Reviews7696
DPMO1821
Sigma4.407

Metrics
NameNumberMinAvgMaxTotal
Class complexity184.0084.0084.0084.00
Code length560.005.1668.00289.00
File length1400.00400.00400.00400.00
Operation complexity551.002.1820.00120.00
Work order12.662.662.662.66

Violations
#LineColumnNameSeverityDescription
1231ER-0233Packages should begin with []
265144ER-0363Line is too long
311191ER-0363Line is too long
4113143ER-0363Line is too long
511481ER-0363Line is too long
612388ER-0363Line is too long
712491ER-0363Line is too long
812784ER-0363Line is too long
913188ER-0363Line is too long
1013296ER-0363Line is too long
1113581ER-0363Line is too long
1213684ER-0363Line is too long
1313984ER-0363Line is too long
1414385ER-0363Line is too long
15144101ER-0363Line is too long
1614787ER-0363Line is too long
1714890ER-0363Line is too long
1815196ER-0363Line is too long
1915588ER-0363Line is too long
20156100ER-0363Line is too long
21157136ER-0363Line is too long
22158101ER-0363Line is too long
23159113ER-0363Line is too long
24161108ER-0363Line is too long
2517582ER-0363Line is too long
2618484ER-0363Line is too long
27185106ER-0363Line is too long
2818880ER-0363Line is too long
29191133ER-0363Line is too long
3019292ER-0363Line is too long
31193100ER-0363Line is too long
32194101ER-0363Line is too long
3319592ER-0363Line is too long
34198112ER-0363Line is too long
3520984ER-0363Line is too long
3621082ER-0363Line is too long
37211118ER-0363Line is too long
38212113ER-0363Line is too long
39214130ER-0363Line is too long
40215125ER-0363Line is too long
4121686ER-0363Line is too long
42217105ER-0363Line is too long
43218116ER-0363Line is too long
4421980ER-0363Line is too long
45220107ER-0363Line is too long
4622198ER-0363Line is too long
4722288ER-0363Line is too long
48223142ER-0363Line is too long
4922481ER-0363Line is too long
5022794ER-0363Line is too long
5123082ER-0363Line is too long
5226088ER-0363Line is too long
5326285ER-0363Line is too long
5426586ER-0363Line is too long
5526780ER-0363Line is too long
56268102ER-0363Line is too long
5727180ER-0363Line is too long
5827292ER-0363Line is too long
5927580ER-0363Line is too long
6027692ER-0363Line is too long
6127980ER-0363Line is too long
62280120ER-0363Line is too long
6328382ER-0363Line is too long
6428495ER-0363Line is too long
6528798ER-0363Line is too long
66288106ER-0363Line is too long
67291112ER-0363Line is too long
68292106ER-0363Line is too long
6929593ER-0363Line is too long
7029981ER-0363Line is too long
7130088ER-0363Line is too long
72358186ER-0363Line is too long
73371214ER-0363Line is too long
7439786ER-0363Line is too long
75531ER-0492Unify logging strategy - define individual logger for class
76659ER-1093It is good practice to call in any case super() in a constructor. (see also: UnnecessaryConstructorRule )
77759ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
78799ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
79839ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
80899ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
81939ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
82979ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
831019ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
841079ER-0111Cyclomatic complexity (15) exceeds 12
851079ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
8612357ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
8712757ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
8813157ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
8913272ER-0792Avoid casting primitive data types to lower precision
9013557ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
9113957ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
9214072ER-0303Avoid hardwired string literals
9314357ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
9414757ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
9515157ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
9615557ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
971729ER-0111Cyclomatic complexity (20) exceeds 12
981729ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
9918041ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
10018441ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
10120241ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
10220641ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1032439ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1042479ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1052519ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
10625165ER-0481Use BigDecimal instead of Float or Double for monetary values
1072579ER-0111Cyclomatic complexity (13) exceeds 12
1082579ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
10926757ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
11026872ER-0792Avoid casting primitive data types to lower precision
11127157ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
11227164ER-0481Use BigDecimal instead of Float or Double for monetary values
11327557ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
11427564ER-0481Use BigDecimal instead of Float or Double for monetary values
11527957ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
11627964ER-0481Use BigDecimal instead of Float or Double for monetary values
11728357ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
11828364ER-0481Use BigDecimal instead of Float or Double for monetary values
11928757ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
12028773ER-0481Use BigDecimal instead of Float or Double for monetary values
12129196ER-0823Avoid using method parameter names that conflict with class member names
12229157ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
12329557ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
12429957ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
12530329ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
12630336ER-0481Use BigDecimal instead of Float or Double for monetary values
1273149ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1283189ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1293229ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1303269ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1313309ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1323349ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1333389ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1343429ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1353469ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1363509ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1373549ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
13835632ER-0303Avoid hardwired string literals
13935847ER-0792Avoid casting primitive data types to lower precision
14035854ER-0293Avoid hardwired numeric literals
141358143ER-0303Avoid hardwired string literals
142358183ER-0303Avoid hardwired string literals
1433629ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
14436317ER-0481Use BigDecimal instead of Float or Double for monetary values
14536532ER-0303Avoid hardwired string literals
14636732ER-0303Avoid hardwired string literals
14736932ER-0303Avoid hardwired string literals
14837153ER-0303Avoid hardwired string literals
149371134ER-0293Avoid hardwired numeric literals
150371171ER-0303Avoid hardwired string literals
151371211ER-0303Avoid hardwired string literals
1523759ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1533799ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
1543839ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
15538316ER-0481Use BigDecimal instead of Float or Double for monetary values
1563879ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
15738824ER-0792Avoid casting primitive data types to lower precision
1583919ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc
15939224ER-0792Avoid casting primitive data types to lower precision
1603959ER-1053Document all Interfaces and public methods. Use a Class header. Provide Javadoc

JavaDoc
QuickSummary

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.sql.SQLException;
26import java.sql.Timestamp;
27import java.text.MessageFormat;
28import java.util.ArrayList;
29import java.util.Collection;
30import java.util.Date;
31import java.util.Iterator;
32import java.util.List;
33import java.util.Map;
34import java.util.TreeMap;
35
36import org.hammurapi.results.AggregatedResults;
37import org.hammurapi.results.Annotation;
38import org.hammurapi.results.BasicResults;
39import org.hammurapi.results.CompositeResults;
40import org.hammurapi.results.InspectorSummary;
41import org.hammurapi.results.quick.MetricSummary;
42import org.hammurapi.results.quick.Summary;
43import org.hammurapi.results.quick.Warning;
44import org.hammurapi.results.simple.SimpleAggregatedResults;
45
46import com.pavelvlasov.review.SimpleSourceMarker;
47import com.pavelvlasov.review.SourceMarker;
48
49/**
50 * @author Pavel Vlasov
51 * @version $Revision: 1.6 $
52 */

53public class QuickSummary implements CompositeResults {
54
55 private Summary summary;
56 private QuickResultsCollector collector;
57 private InspectorSet inspectorSet;
58 private String title;
59
60 /**
61 * @param total
62 * @param collector
63 * @throws SQLException
64 */

65 public QuickSummary(String title, QuickResultsCollector collector, InspectorSet inspectorSet, Collection children) throws SQLException {
66 this.collector=collector;
67 this.inspectorSet=inspectorSet;
68 this.summary=collector.getEngine().getSummary();
69 this.children=children;
70 this.title=title;
71 }
72
73 private Collection children;
74
75 public Collection getChildren() {
76 return children;
77 }
78
79 public void add(AggregatedResults child) {
80 throw new UnsupportedOperationException();
81 }
82
83 public int size() {
84 return summary.getResultSize();
85 }
86
87 private Collection violations=new ArrayList();
88
89 public Collection getViolations() {
90 return violations;
91 }
92
93 public Collection getWaivedViolations() {
94 return violations;
95 }
96
97 public String getName() {
98 return title;
99 }
100
101 public Waiver addViolation(Violation violation) {
102 throw new UnsupportedOperationException();
103 }
104
105 private Map severitySummary;
106
107 public Map getSeveritySummary() {
108 if (severitySummary==null) {
109 severitySummary=new TreeMap();
110
111 Iterator it=collector.getEngine().getInspectorSummary().iterator();
112 while (it.hasNext()) {
113 final org.hammurapi.results.quick.InspectorSummary ps=(org.hammurapi.results.quick.InspectorSummary) it.next();
114 Integer severity = new Integer(ps.getSeverity());
115 Map imap=(Map) severitySummary.get(severity);
116 if (imap==null) {
117 imap=new TreeMap();
118 severitySummary.put(severity, imap);
119 }
120 imap.put(ps.getName(),
121 new InspectorSummary() {
122
123 public String getDescription() {
124 return ps.getDescription();
125 }
126
127 public List getLocations() {
128 return null;
129 }
130
131 public int getLocationsCount() {
132 return (int) ps.getViolations();
133 }
134
135 public String getName() {
136 return ps.getName();
137 }
138
139 public String getVersion() {
140 return "";
141 }
142
143 public Number getSeverity() {
144 return new Integer(ps.getSeverity());
145 }
146
147 public String getConfigInfo() {
148 return ps.getConfigInfo();
149 }
150
151 public int getBaseLineLocationsCount() {
152 return -1;
153 }
154
155 public int compareTo(Object o) {
156 if (o instanceof InspectorSummary) {
157 return ps.getName().compareTo(((InspectorSummary) o).getName());
158 } else if (o instanceof Comparable) {
159 return -((Comparable) o).compareTo(this);
160 } else {
161 return this.hashCode()-o.hashCode();
162 }
163 }
164 });
165 }
166 }
167 return severitySummary;
168 }
169
170 private Collection warnings;
171
172 public Collection getWarnings() {
173 if (warnings==null) {
174 warnings=new ArrayList();
175 Iterator it=collector.getEngine().getWarning().iterator();
176 while (it.hasNext()) {
177 final Warning warning=(Warning) it.next();
178 warnings.add(new Violation() {
179
180 public String getMessage() {
181 return warning.getMessage();
182 }
183
184 public InspectorDescriptor getDescriptor() {
185 return inspectorSet.getDescriptor(warning.getInspector());
186 }
187
188 private SimpleSourceMarker sourceMarker;
189
190 {
191 if (warning.getSource()!=null && warning.getLine()!=null && warning.getCol()!=null) {
192 sourceMarker=new SimpleSourceMarker(
193 warning.getCol().intValue(),
194 warning.getLine().intValue(),
195 warning.getSource(),
196 null);
197
198 sourceMarker.setSignature(warning.getSourceSignature());
199 }
200 }
201
202 public SourceMarker getSource() {
203 return sourceMarker;
204 }
205
206 public int compareTo(Object o) {
207 if (o==this) {
208 return 0;
209 } else if (o instanceof Violation) {
210 Violation v=(Violation) o;
211 int vline = v.getSource()==null ? 0 : v.getSource().getLine();
212 int line = getSource()==null ? 0 : getSource().getLine();
213 if (vline==line) {
214 int vcolumn = v.getSource()==null ? 0 : v.getSource().getColumn();
215 int column = getSource()==null ? 0 : getSource().getColumn();
216 if (vcolumn==column) {
217 if (warning.getMessage()==null) {
218 return v.getMessage()==null ? 0 : 1;
219 } else {
220 if (v.getMessage()==null) {
221 return -1;
222 } else {
223 return warning.getMessage().compareTo(v.getMessage());
224 }
225 }
226 } else {
227 return column-vcolumn;
228 }
229 } else {
230 return line-vline;
231 }
232 } else {
233 return 1;
234 }
235 }
236
237 });
238 }
239 }
240 return warnings;
241 }
242
243 public boolean hasWarnings() {
244 return summary.getHasWarnings();
245 }
246
247 public void addWarning(Violation warning) {
248 throw new UnsupportedOperationException();
249 }
250
251 public void addMetric(SourceMarker source, String name, double value) {
252 throw new UnsupportedOperationException();
253 }
254
255 private Map metrics;
256
257 public Map getMetrics() {
258 if (metrics==null) {
259 metrics=new TreeMap();
260 Iterator it=collector.getEngine().getMetricSummary().iterator();
261 while (it.hasNext()) {
262 final MetricSummary metric=(MetricSummary) it.next();
263 metrics.put(
264 metric.getName(),
265 new com.pavelvlasov.metrics.Metric() {
266
267 public int getNumber() {
268 return (int) metric.getMeasurements();
269 }
270
271 public double getMin() {
272 return metric.getMinValue();
273 }
274
275 public double getMax() {
276 return metric.getMaxValue();
277 }
278
279 public double getAvg() {
280 return metric.getMetricTotal()/metric.getMeasurements();
281 }
282
283 public double getTotal() {
284 return metric.getMetricTotal();
285 }
286
287 public void add(double value, long time) {
288 throw new UnsupportedOperationException();
289 }
290
291 public void add(com.pavelvlasov.metrics.Metric metric) {
292 throw new UnsupportedOperationException();
293 }
294
295 public Collection getMeasurements() {
296 return null;
297 }
298
299 public String getName() {
300 return metric.getName();
301 }
302
303 public double getDeviation() {
304 // TODO - Calcualte deviation
305
return 0;
306 }
307
308 });
309 }
310 }
311 return metrics;
312 }
313
314 public void aggregate(AggregatedResults agregee) {
315 throw new UnsupportedOperationException();
316 }
317
318 public void setReviewsNumber(long reviews) {
319 throw new UnsupportedOperationException();
320 }
321
322 public void setCodeBase(long codeBase) {
323 throw new UnsupportedOperationException();
324 }
325
326 public void addAnnotation(Annotation annotation) {
327 throw new UnsupportedOperationException();
328 }
329
330 public Collection getAnnotations() {
331 return violations;
332 }
333
334 public WaiverSet getWaiverSet() {
335 throw new UnsupportedOperationException();
336 }
337
338 public void commit() {
339 // No action is required
340
}
341
342 public boolean isNew() {
343 return summary.getMinState()==QuickResultsCollector.RESULT_NEW;
344 }
345
346 public BasicResults getBaseLine() {
347 return null;
348 }
349
350 public long getCodeBase() {
351 return summary.getCodebase();
352 }
353
354 public String getDPMO() {
355 if (summary.getReviews()==0) {
356 return "Not available, no reviews";
357 } else {
358 return String.valueOf((int) (1000000*summary.getViolationLevel()/summary.getReviews())) + (summary.getHasWarnings() ? " (not accurate because of warnings)" : "");
359 }
360 }
361
362 public String getSigma() {
363 double p=1.0-summary.getViolationLevel()/summary.getReviews();
364 if (summary.getReviews()==0) {
365 return "No results";
366 } else if (p<=0) {
367 return "Full incompliance";
368 } else if (p>=1) {
369 return "Full compliance";
370 } else {
371 return MessageFormat.format("{0,number,#.###}", new Object[] {new Double(SimpleAggregatedResults.normsinv(p)+1.5)}) + (summary.getHasWarnings() ? " (not accurate because of warnings)" : "");
372 }
373 }
374
375 public Number getMaxSeverity() {
376 return summary.getMaxSeverity();
377 }
378
379 public long getReviewsNumber() {
380 return summary.getReviews();
381 }
382
383 public double getViolationLevel() {
384 return summary.getViolationLevel();
385 }
386
387 public int getViolationsNumber() {
388 return (int) summary.getViolations();
389 }
390
391 public int getWaivedViolationsNumber() {
392 return (int) summary.getWaivedViolations();
393 }
394
395 public Date getDate() {
396 Timestamp resultDate = summary.getResultDate();
397 return resultDate==null ? new Date() : new Date(resultDate.getTime());
398 }
399}
400
401

Hammurapi 3 Copyright © 2004 Hammurapi Group. All Rights Reserved.