Date | 2007/07/27 |
---|---|
Codebase | 1878 |
Reviews | 3373 |
DPMO | 563 |
Sigma | 4.757 |
Name | Number | Min | Avg | Max | Total |
---|---|---|---|---|---|
Class complexity | 1 | 27.00 | 27.00 | 27.00 | 27.00 |
Code length | 15 | 1.00 | 10.93 | 78.00 | 164.00 |
File length | 1 | 172.00 | 172.00 | 172.00 | 172.00 |
Operation complexity | 15 | 1.00 | 3.20 | 18.00 | 48.00 |
Work order | 1 | 23.71 | 23.71 | 23.71 | 23.71 |
# | Line | Column | Name | Severity | Description |
---|---|---|---|---|---|
1 | 23 | 1 | ER-023 | 3 | Packages should begin with [] |
2 | 49 | 84 | ER-036 | 3 | Line is too long |
3 | 52 | 136 | ER-036 | 3 | Line is too long |
4 | 53 | 90 | ER-036 | 3 | Line is too long |
5 | 56 | 92 | ER-036 | 3 | Line is too long |
6 | 58 | 81 | ER-036 | 3 | Line is too long |
7 | 59 | 107 | ER-036 | 3 | Line is too long |
8 | 62 | 167 | ER-036 | 3 | Line is too long |
9 | 68 | 121 | ER-036 | 3 | Line is too long |
10 | 69 | 215 | ER-036 | 3 | Line is too long |
11 | 74 | 87 | ER-036 | 3 | Line is too long |
12 | 81 | 92 | ER-036 | 3 | Line is too long |
13 | 98 | 122 | ER-036 | 3 | Line is too long |
14 | 99 | 84 | ER-036 | 3 | Line is too long |
15 | 100 | 97 | ER-036 | 3 | Line is too long |
16 | 105 | 83 | ER-036 | 3 | Line is too long |
17 | 112 | 92 | ER-036 | 3 | Line is too long |
18 | 118 | 98 | ER-036 | 3 | Line is too long |
19 | 121 | 81 | ER-036 | 3 | Line is too long |
20 | 123 | 87 | ER-036 | 3 | Line is too long |
21 | 131 | 84 | ER-036 | 3 | Line is too long |
22 | 139 | 84 | ER-036 | 3 | Line is too long |
23 | 148 | 93 | ER-036 | 3 | Line is too long |
24 | 153 | 92 | ER-036 | 3 | Line is too long |
25 | 156 | 88 | ER-036 | 3 | Line is too long |
26 | 46 | 1 | ER-049 | 2 | Unify logging strategy - define individual logger for class |
27 | 49 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
28 | 49 | 9 | ER-109 | 3 | It is good practice to call in any case super() in a constructor. (see also: UnnecessaryConstructorRule ) |
29 | 52 | 76 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
30 | 52 | 25 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
31 | 53 | 42 | ER-030 | 3 | Avoid hardwired string literals |
32 | 58 | 66 | ER-030 | 3 | Avoid hardwired string literals |
33 | 62 | 145 | ER-030 | 3 | Avoid hardwired string literals |
34 | 69 | 182 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
35 | 69 | 180 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
36 | 69 | 170 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
37 | 69 | 153 | ER-030 | 3 | Avoid hardwired string literals |
38 | 69 | 171 | ER-030 | 3 | Avoid hardwired string literals |
39 | 69 | 183 | ER-030 | 3 | Avoid hardwired string literals |
40 | 77 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
41 | 81 | 9 | ER-011 | 1 | Cyclomatic complexity (18) exceeds 12 |
42 | 81 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
43 | 99 | 51 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
44 | 112 | 25 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
45 | 113 | 37 | ER-030 | 3 | Avoid hardwired string literals |
46 | 114 | 37 | ER-030 | 3 | Avoid hardwired string literals |
47 | 115 | 37 | ER-030 | 3 | Avoid hardwired string literals |
48 | 118 | 25 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
49 | 120 | 45 | ER-030 | 3 | Avoid hardwired string literals |
50 | 121 | 45 | ER-030 | 3 | Avoid hardwired string literals |
51 | 122 | 45 | ER-030 | 3 | Avoid hardwired string literals |
52 | 123 | 45 | ER-030 | 3 | Avoid hardwired string literals |
53 | 124 | 45 | ER-030 | 3 | Avoid hardwired string literals |
54 | 128 | 25 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
55 | 130 | 45 | ER-030 | 3 | Avoid hardwired string literals |
56 | 131 | 45 | ER-030 | 3 | Avoid hardwired string literals |
57 | 132 | 45 | ER-030 | 3 | Avoid hardwired string literals |
58 | 136 | 25 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
59 | 138 | 45 | ER-030 | 3 | Avoid hardwired string literals |
60 | 139 | 45 | ER-030 | 3 | Avoid hardwired string literals |
61 | 140 | 45 | ER-030 | 3 | Avoid hardwired string literals |
62 | 144 | 25 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
63 | 145 | 37 | ER-030 | 3 | Avoid hardwired string literals |
64 | 146 | 37 | ER-030 | 3 | Avoid hardwired string literals |
65 | 148 | 45 | ER-030 | 3 | Avoid hardwired string literals |
66 | 152 | 25 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
67 | 153 | 37 | ER-030 | 3 | Avoid hardwired string literals |
68 | 156 | 25 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
69 | 157 | 37 | ER-030 | 3 | Avoid hardwired string literals |
70 | 158 | 37 | ER-030 | 3 | Avoid hardwired string literals |
71 | 159 | 37 | ER-030 | 3 | Avoid hardwired string literals |
72 | 164 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
73 | 168 | 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.util.Collection;
27
28import org.apache.tools.ant.BuildException;
29import org.apache.tools.ant.Project;
30import org.hammurapi.results.AggregatedResults;
31import org.hammurapi.results.ResultsFactory;
32
33import com.pavelvlasov.jsel.Repository;
34import com.pavelvlasov.review.SourceMarker;
35import com.pavelvlasov.util.DispatchingVisitor;
36import com.pavelvlasov.util.OrderedTarget;
37import com.pavelvlasov.util.VisitorExceptionSink;
38import com.pavelvlasov.util.VisitorStack;
39import com.pavelvlasov.util.VisitorStackSource;
40
41/**
42 * Pool of review threads. Delegates review work to threads.
43 * @author Pavel Vlasov
44 * @version $Revision: 1.8 $
45 */
46public class SimpleReviewEngine implements VisitorStackSource {
47 private DispatchingVisitor visitor;
48
49 public SimpleReviewEngine(Collection inspectors, final HammurapiTask task) {
50 VisitorExceptionSink esink=new VisitorExceptionSink() {
51
52 public void consume(DispatchingVisitor dispatcher, Object visitor, Method method, Object visitee, Exception e) {
53 task.log("WARN: Exception in "+visitee, Project.MSG_WARN);
54 e.printStackTrace();
55
56 AggregatedResults results=ResultsFactory.getThreadResults();
57 if (task.failOnFirstException) {
58 throw new BuildException("Cause: "+e, e);
59 } else if (results==null || e instanceof HammurapiNonConsumableException) {
60 task.setHadExceptions();
61 } else {
62 results.addWarning(new SimpleViolation(visitee instanceof SourceMarker ? (SourceMarker) visitee : null, "Exception "+e, null));
63 }
64
65 if (task.evictBadInspectors) {
66 dispatcher.remove(visitor);
67 if (visitor instanceof Inspector) {
68 String name=((Inspector) visitor).getContext().getDescriptor().getName();
69 results.addWarning(new SimpleViolation(visitee instanceof SourceMarker ? (SourceMarker) visitee : null, "Inspector "+name+" threw "+e+" and has been disabled", null));
70 }
71 }
72 }
73 };
74 visitor = new DispatchingVisitor(inspectors, esink, getListener(task));
75 }
76
77 public void review(Repository repository) {
78 repository.accept(visitor);
79 }
80
81 protected static DispatchingVisitor.Listener getListener(final HammurapiTask task) {
82 if (task.getDebugType()==null) {
83 return null;
84 }
85
86 return new DispatchingVisitor.Listener() {
87 private boolean isEnabled=true;
88 private Class type;
89
90 private void log(String message) {
91 task.log(message, Project.MSG_INFO);
92 }
93
94 boolean isListeningFor(Object o) {
95 if (isEnabled) {
96 if (type==null) {
97 try {
98 type=o.getClass().getClassLoader().loadClass(task.getDebugType());
99 } catch (ClassNotFoundException e) {
100 task.log(e.toString(), Project.MSG_WARN);
101 isEnabled=false;
102 return false;
103 }
104 }
105 return type.isAssignableFrom(o.getClass());
106
107 }
108
109 return false;
110 }
111
112 public void onInvocationRegistration(Object target, Method method) {
113 log("\tDispatch invocaton registration");
114 log("\t\tTarget type: "+target.getClass());
115 log("\t\tTarget method: "+method);
116 }
117
118 public void onInvocation(Object target, Method method, Object visitable) {
119 if (isListeningFor(visitable)) {
120 log("Dispatch invocation");
121 log("\tTarget type: "+target.getClass());
122 log("\tTarget method: "+method);
123 log("\tVisitable type: "+visitable.getClass());
124 log("\tVisitable: "+visitable);
125 }
126 }
127
128 public void onVisit(Object target) {
129 if (isListeningFor(target)) {
130 log("Dispatch visit");
131 log("\tVisitable type: "+target.getClass());
132 log("\tVisitable: "+target);
133 }
134 }
135
136 public void onLeave(Object target) {
137 if (isListeningFor(target)) {
138 log("Dispatch leave");
139 log("\tVisitable type: "+target.getClass());
140 log("\tVisitable: "+target);
141 }
142 }
143
144 public void onTargetRegistration(Object target) {
145 log("Dispatch type registration");
146 log("\tTarget type: "+target.getClass());
147 if (target instanceof OrderedTarget) {
148 log("\tOrder: "+((OrderedTarget) target).getOrder());
149 }
150 }
151
152 public void noInvocationsWarning(Object target) {
153 log("WARNING: No invocations for type: "+target.getClass());
154 }
155
156 public void onFilterRegistration(Method filter, Method target) {
157 log("\tFilter registration");
158 log("\t\tFilter method: "+filter);
159 log("\t\tTarget method: "+target);
160 }
161 };
162 }
163
164 public VisitorStack getVisitorStack() {
165 return visitor.getVisitorStack();
166 }
167
168 public DispatchingVisitor getVisitor() {
169 return visitor;
170 }
171}
172
173