Date | 2007/07/27 |
---|---|
Codebase | 2224 |
Reviews | 4109 |
DPMO | 472 |
Sigma | 4.807 |
Name | Number | Min | Avg | Max | Total |
---|---|---|---|---|---|
Class complexity | 1 | 30.00 | 30.00 | 30.00 | 30.00 |
Code length | 15 | 1.00 | 13.00 | 77.00 | 195.00 |
File length | 1 | 213.00 | 213.00 | 213.00 | 213.00 |
Operation complexity | 15 | 1.00 | 3.33 | 18.00 | 50.00 |
Work order | 1 | 19.71 | 19.71 | 19.71 | 19.71 |
# | Line | Column | Name | Severity | Description |
---|---|---|---|---|---|
1 | 23 | 1 | ER-023 | 3 | Packages should begin with [] |
2 | 58 | 141 | ER-036 | 3 | Line is too long |
3 | 68 | 90 | ER-036 | 3 | Line is too long |
4 | 71 | 92 | ER-036 | 3 | Line is too long |
5 | 73 | 81 | ER-036 | 3 | Line is too long |
6 | 74 | 107 | ER-036 | 3 | Line is too long |
7 | 77 | 167 | ER-036 | 3 | Line is too long |
8 | 85 | 87 | ER-036 | 3 | Line is too long |
9 | 91 | 81 | ER-036 | 3 | Line is too long |
10 | 94 | 105 | ER-036 | 3 | Line is too long |
11 | 95 | 87 | ER-036 | 3 | Line is too long |
12 | 101 | 90 | ER-036 | 3 | Line is too long |
13 | 105 | 95 | ER-036 | 3 | Line is too long |
14 | 106 | 87 | ER-036 | 3 | Line is too long |
15 | 112 | 90 | ER-036 | 3 | Line is too long |
16 | 121 | 97 | ER-036 | 3 | Line is too long |
17 | 137 | 130 | ER-036 | 3 | Line is too long |
18 | 138 | 92 | ER-036 | 3 | Line is too long |
19 | 139 | 105 | ER-036 | 3 | Line is too long |
20 | 140 | 80 | ER-036 | 3 | Line is too long |
21 | 144 | 91 | ER-036 | 3 | Line is too long |
22 | 151 | 100 | ER-036 | 3 | Line is too long |
23 | 152 | 81 | ER-036 | 3 | Line is too long |
24 | 153 | 83 | ER-036 | 3 | Line is too long |
25 | 157 | 106 | ER-036 | 3 | Line is too long |
26 | 160 | 89 | ER-036 | 3 | Line is too long |
27 | 161 | 80 | ER-036 | 3 | Line is too long |
28 | 162 | 95 | ER-036 | 3 | Line is too long |
29 | 170 | 92 | ER-036 | 3 | Line is too long |
30 | 178 | 92 | ER-036 | 3 | Line is too long |
31 | 183 | 81 | ER-036 | 3 | Line is too long |
32 | 185 | 81 | ER-036 | 3 | Line is too long |
33 | 187 | 101 | ER-036 | 3 | Line is too long |
34 | 191 | 81 | ER-036 | 3 | Line is too long |
35 | 192 | 100 | ER-036 | 3 | Line is too long |
36 | 195 | 96 | ER-036 | 3 | Line is too long |
37 | 47 | 1 | ER-049 | 2 | Unify logging strategy - define individual logger for class |
38 | 64 | 41 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
39 | 62 | 25 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
40 | 68 | 42 | ER-030 | 3 | Avoid hardwired string literals |
41 | 73 | 66 | ER-030 | 3 | Avoid hardwired string literals |
42 | 77 | 145 | ER-030 | 3 | Avoid hardwired string literals |
43 | 91 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
44 | 121 | 9 | ER-011 | 1 | Cyclomatic complexity (18) exceeds 12 |
45 | 121 | 66 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
46 | 121 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
47 | 138 | 59 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
48 | 151 | 33 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
49 | 152 | 45 | ER-030 | 3 | Avoid hardwired string literals |
50 | 153 | 45 | ER-030 | 3 | Avoid hardwired string literals |
51 | 154 | 45 | ER-030 | 3 | Avoid hardwired string literals |
52 | 157 | 33 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
53 | 159 | 53 | ER-030 | 3 | Avoid hardwired string literals |
54 | 160 | 53 | ER-030 | 3 | Avoid hardwired string literals |
55 | 161 | 53 | ER-030 | 3 | Avoid hardwired string literals |
56 | 162 | 53 | ER-030 | 3 | Avoid hardwired string literals |
57 | 163 | 53 | ER-030 | 3 | Avoid hardwired string literals |
58 | 167 | 33 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
59 | 169 | 53 | ER-030 | 3 | Avoid hardwired string literals |
60 | 170 | 53 | ER-030 | 3 | Avoid hardwired string literals |
61 | 171 | 53 | ER-030 | 3 | Avoid hardwired string literals |
62 | 175 | 33 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
63 | 177 | 53 | ER-030 | 3 | Avoid hardwired string literals |
64 | 178 | 53 | ER-030 | 3 | Avoid hardwired string literals |
65 | 179 | 53 | ER-030 | 3 | Avoid hardwired string literals |
66 | 183 | 33 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
67 | 184 | 45 | ER-030 | 3 | Avoid hardwired string literals |
68 | 185 | 45 | ER-030 | 3 | Avoid hardwired string literals |
69 | 187 | 53 | ER-030 | 3 | Avoid hardwired string literals |
70 | 191 | 33 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
71 | 192 | 45 | ER-030 | 3 | Avoid hardwired string literals |
72 | 195 | 33 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
73 | 196 | 45 | ER-030 | 3 | Avoid hardwired string literals |
74 | 197 | 45 | ER-030 | 3 | Avoid hardwired string literals |
75 | 198 | 45 | ER-030 | 3 | Avoid hardwired string literals |
76 | 204 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
77 | 208 | 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.lang.reflect.Method;
26import java.sql.SQLException;
27import java.util.Collection;
28
29import org.apache.tools.ant.BuildException;
30import org.apache.tools.ant.Project;
31import org.hammurapi.results.AggregatedResults;
32import org.hammurapi.results.ResultsFactory;
33
34import com.pavelvlasov.jsel.CompilationUnit;
35import com.pavelvlasov.review.SourceMarker;
36import com.pavelvlasov.util.DispatchingVisitor;
37import com.pavelvlasov.util.OrderedTarget;
38import com.pavelvlasov.util.VisitorExceptionSink;
39import com.pavelvlasov.util.VisitorStack;
40import com.pavelvlasov.util.VisitorStackSource;
41
42/**
43 * Pool of review threads. Delegates review work to threads.
44 * @author Pavel Vlasov
45 * @version $Revision: 1.3 $
46 */
47public class QuickReviewEngine implements VisitorStackSource {
48 private DispatchingVisitor visitor;
49 private QuickResultsCollector collector;
50 private QuickHammurapiTask task;
51
52 /**
53 * @param task
54 * @param rules
55 * @param poolSize If > 1 then multithreaded processing will be used.
56 * @throws SQLException
57 */
58 public QuickReviewEngine(Collection inspectors, final QuickHammurapiTask task, QuickResultsCollector collector) throws SQLException {
59 super();
60 VisitorExceptionSink esink=new VisitorExceptionSink() {
61
62 public void consume(
63 final DispatchingVisitor dispatcher,
64 final Object visitor,
65 final Method method,
66 final Object visitee,
67 final Exception e) {
68 task.log("WARN: Exception in "+visitee, Project.MSG_WARN);
69 e.printStackTrace();
70
71 AggregatedResults results=ResultsFactory.getThreadResults();
72 if (task.failOnFirstException) {
73 throw new BuildException("Cause: "+e, e);
74 } else if (results==null || e instanceof HammurapiNonConsumableException) {
75 task.setHadExceptions();
76 } else {
77 results.addWarning(new SimpleViolation(visitee instanceof SourceMarker ? (SourceMarker) visitee : null, "Exception "+e, null));
78 }
79
80 if (task.evictBadInspectors) {
81 dispatcher.remove(visitor);
82 }
83 }
84 };
85 visitor = new DispatchingVisitor(inspectors, esink, getListener(task));
86 this.collector=collector;
87 collector.getEngine().init();
88 this.task=task;
89 }
90
91 public void review(CompilationUnit compilationUnit) throws SQLException {
92 if (!task.force) {
93 if (task.forceOnWarnings) {
94 Integer id = collector.getEngine().getResultByNameSizeChecksumNoWarnings(
95 compilationUnit.getPackage().getName(),
96 compilationUnit.getName(),
97 compilationUnit.getSize(),
98 compilationUnit.getCheckSum());
99
100 if (id!=null) {
101 collector.getEngine().setUntouched(id.intValue());
102 return;
103 }
104 } else {
105 Integer id = collector.getEngine().getResultByNameSizeChecksum(
106 compilationUnit.getPackage().getName(),
107 compilationUnit.getName(),
108 compilationUnit.getSize(),
109 compilationUnit.getCheckSum());
110
111 if (id!=null) {
112 collector.getEngine().setUntouched(id.intValue());
113 return;
114 }
115 }
116 }
117
118 compilationUnit.accept(visitor);
119 }
120
121 protected static DispatchingVisitor.Listener getListener(final QuickHammurapiTask task) {
122 if (task.getDebugType()==null) {
123 return null;
124 } else {
125 return new DispatchingVisitor.Listener() {
126 private boolean isEnabled=true;
127 private Class type;
128
129 private void log(String message) {
130 task.log(message, Project.MSG_INFO);
131 }
132
133 boolean isListeningFor(Object o) {
134 if (isEnabled) {
135 if (type==null) {
136 try {
137 type=o.getClass().getClassLoader().loadClass(task.getDebugType());
138 } catch (ClassNotFoundException e) {
139 task.log(e.toString(), Project.MSG_WARN);
140 isEnabled=false;
141 return false;
142 }
143 }
144 return type.isAssignableFrom(o.getClass());
145
146 } else {
147 return false;
148 }
149 }
150
151 public void onInvocationRegistration(Object target, Method method) {
152 log("\tDispatch invocaton registration");
153 log("\t\tTarget type: "+target.getClass());
154 log("\t\tTarget method: "+method);
155 }
156
157 public void onInvocation(Object target, Method method, Object visitable) {
158 if (isListeningFor(visitable)) {
159 log("Dispatch invocation");
160 log("\tTarget type: "+target.getClass());
161 log("\tTarget method: "+method);
162 log("\tVisitable type: "+visitable.getClass());
163 log("\tVisitable: "+visitable);
164 }
165 }
166
167 public void onVisit(Object target) {
168 if (isListeningFor(target)) {
169 log("Dispatch visit");
170 log("\tVisitable type: "+target.getClass());
171 log("\tVisitable: "+target);
172 }
173 }
174
175 public void onLeave(Object target) {
176 if (isListeningFor(target)) {
177 log("Dispatch leave");
178 log("\tVisitable type: "+target.getClass());
179 log("\tVisitable: "+target);
180 }
181 }
182
183 public void onTargetRegistration(Object target) {
184 log("Dispatch type registration");
185 log("\tTarget type: "+target.getClass());
186 if (target instanceof OrderedTarget) {
187 log("\tOrder: "+((OrderedTarget) target).getOrder());
188 }
189 }
190
191 public void noInvocationsWarning(Object target) {
192 log("WARNING: No invocations for type: "+target.getClass());
193 }
194
195 public void onFilterRegistration(Method filter, Method target) {
196 log("\tFilter registration");
197 log("\t\tFilter method: "+filter);
198 log("\t\tTarget method: "+target);
199 }
200 };
201 }
202 }
203
204 public VisitorStack getVisitorStack() {
205 return visitor.getVisitorStack();
206 }
207
208 public DispatchingVisitor getVisitor() {
209 return visitor;
210 }
211
212}
213
214