SimpleViolation.java
Package: org.hammurapi
Results
Date | 2007/07/27 |
Codebase | 1262 |
Reviews | 2269 |
DPMO | 158 |
Sigma | 5.101 |
Metrics
Name | Number | Min | Avg | Max | Total |
Class complexity | 1 | 25.00 | 25.00 | 25.00 | 25.00 |
Code length | 7 | 1.00 | 7.85 | 27.00 | 55.00 |
File length | 1 | 136.00 | 136.00 | 136.00 | 136.00 |
Operation complexity | 7 | 1.00 | 3.57 | 12.00 | 25.00 |
Work order | 1 | 62.12 | 62.12 | 62.12 | 62.12 |
Violations
# | Line | Column | Name | Severity | Description |
1 | 23 | 1 | ER-023 | 3 | Packages should begin with [] |
2 | 52 | 101 | ER-036 | 3 | Line is too long |
3 | 78 | 120 | ER-036 | 3 | Line is too long |
4 | 93 | 86 | ER-036 | 3 | Line is too long |
5 | 94 | 81 | ER-036 | 3 | Line is too long |
6 | 96 | 98 | ER-036 | 3 | Line is too long |
7 | 97 | 93 | ER-036 | 3 | Line is too long |
8 | 100 | 84 | ER-036 | 3 | Line is too long |
9 | 107 | 81 | ER-036 | 3 | Line is too long |
10 | 124 | 93 | ER-036 | 3 | Line is too long |
11 | 125 | 33 | ER-036 | 3 | Line is too long |
12 | 126 | 109 | ER-036 | 3 | Line is too long |
13 | 36 | 1 | ER-049 | 2 | Unify logging strategy - define individual logger for class |
14 | 38 | 17 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
15 | 46 | 9 | ER-113 | 2 | Unused private/local variables |
16 | 52 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
17 | 88 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
18 | 119 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
-
JavaDoc
-
SimpleViolation
1
23package org.hammurapi;
24
25import java.io.Serializable;
26import java.util.HashMap;
27import java.util.Map;
28
29import com.pavelvlasov.review.SourceMarker;
30import com.pavelvlasov.review.SourceMarkerComparator;
31
32
36public class SimpleViolation implements Violation, Serializable {
37 private static ThreadLocal inspectorMap=new ThreadLocal() {
38 protected Object initialValue() {
39 return new HashMap();
40 }
41 };
42
43
46 private static final long serialVersionUID = -6111796217286959070L;
47 private SourceMarker source;
48 private String message;
49
50 private String inspectorName;
51
52 public SimpleViolation(SourceMarker source, String message, InspectorDescriptor descriptor) {
53 super();
54 this.source=source;
55
56 if (descriptor!=null) {
57 Map iMap = (Map) inspectorMap.get();
58 if (iMap!=null) {
59 iMap.put(descriptor.getName(), descriptor);
60 }
61 inspectorName=descriptor.getName();
62 }
63
64 this.message=message;
65 }
66
67
70 public String getMessage() {
71 return message;
72 }
73
74
77 public InspectorDescriptor getDescriptor() {
78 return inspectorName==null ? null : (InspectorDescriptor) ((Map) inspectorMap.get()).get(inspectorName);
79 }
80
81
84 public SourceMarker getSource() {
85 return source;
86 }
87
88 public int compareTo(Object o) {
89 if (o==this) {
90 return 0;
91 } else if (o instanceof Violation) {
92 Violation v=(Violation) o;
93 int vline = v.getSource()==null ? 0 : v.getSource().getLine();
94 int line = getSource()==null ? 0 : getSource().getLine();
95 if (vline==line) {
96 int vcolumn = v.getSource()==null ? 0 : v.getSource().getColumn();
97 int column = getSource()==null ? 0 : getSource().getColumn();
98 if (vcolumn==column) {
99 if (message==null) {
100 return v.getMessage()==null ? 0 : 1;
101 }
102
103 if (v.getMessage()==null) {
104 return -1;
105 }
106
107 return message.compareTo(v.getMessage());
108 }
109
110 return column-vcolumn;
111 }
112
113 return line-vline;
114 } else {
115 return 1;
116 }
117 }
118
119 public boolean equals(Object obj) {
120 if (obj==this) {
121 return true;
122 } else if (obj instanceof Violation) {
123 Violation v=(Violation) obj;
124 if (SourceMarkerComparator._compare(getSource(), v.getSource())==0) {
125 return message==null ? v.getMessage()==null : message.equals(v.getMessage());
127 }
128
129 return false;
130 } else {
131 return super.equals(obj);
132 }
133 }
134
135}
136
137
Hammurapi 3 Copyright © 2004 Hammurapi Group. All Rights Reserved.