WaiverSet.java
Package: org.hammurapi
Results
Date | 2007/07/27 |
Codebase | 1509 |
Reviews | 2974 |
DPMO | 107 |
Sigma | 5.2 |
Metrics
Name | Number | Min | Avg | Max | Total |
Class complexity | 1 | 23.00 | 23.00 | 23.00 | 23.00 |
Code length | 6 | 1.00 | 10.66 | 35.00 | 64.00 |
File length | 1 | 150.00 | 150.00 | 150.00 | 150.00 |
Operation complexity | 6 | 1.00 | 3.83 | 12.00 | 23.00 |
Work order | 1 | 64.85 | 64.85 | 64.85 | 64.85 |
Violations
# | Line | Column | Name | Severity | Description |
1 | 24 | 1 | ER-023 | 3 | Packages should begin with [] |
2 | 85 | 82 | ER-036 | 3 | Line is too long |
3 | 87 | 101 | ER-036 | 3 | Line is too long |
4 | 90 | 126 | ER-036 | 3 | Line is too long |
5 | 94 | 100 | ER-036 | 3 | Line is too long |
6 | 105 | 118 | ER-036 | 3 | Line is too long |
7 | 106 | 81 | ER-036 | 3 | Line is too long |
8 | 123 | 97 | ER-036 | 3 | Line is too long |
9 | 129 | 101 | ER-036 | 3 | Line is too long |
10 | 132 | 88 | ER-036 | 3 | Line is too long |
11 | 40 | 1 | ER-049 | 2 | Unify logging strategy - define individual logger for class |
12 | 44 | 9 | ER-113 | 2 | Unused private/local variables |
13 | 60 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
14 | 122 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
-
JavaDoc
-
WaiverSet
1
23
24package org.hammurapi;
25
26import java.util.Collection;
27import java.util.Date;
28import java.util.HashMap;
29import java.util.Iterator;
30import java.util.LinkedList;
31import java.util.Map;
32
33import com.pavelvlasov.review.Signed;
34import com.pavelvlasov.review.SourceMarker;
35
36
40public class WaiverSet {
41
44 private static final long serialVersionUID = 4873150699959326186L;
45 private Map signatureMap=new HashMap();
46 private Collection rejectedRequests=new LinkedList();
47
48
51 public Collection getWaivers() {
52 Collection ret=new LinkedList();
53 Iterator it=signatureMap.values().iterator();
54 while (it.hasNext()) {
55 ret.addAll(((Map) it.next()).values());
56 }
57 return ret;
58 }
59
60 public int size() {
61 int ret=0;
62 Iterator it=signatureMap.values().iterator();
63 while (it.hasNext()) {
64 ret+=((Map) it.next()).size();
65 }
66 return ret;
67 }
68
69
73 public Collection getRejectedRequests() {
74 return rejectedRequests;
75 }
76
77
84 public Waiver requestWaiver(Violation violation, boolean peek) {
85 if (Boolean.TRUE.equals(violation.getDescriptor().isWaivable())) {
86 SourceMarker sm=violation.getSource();
87 String signature= sm instanceof Signed ? ((Signed) sm).getSignature() : null;
88 if (signature!=null) {
89 Map nameMap=(Map) signatureMap.get(signature);
90 Waiver ret = nameMap==null ? null : (Waiver) nameMap.get(violation.getDescriptor().getName());
91
92 if (ret!=null) {
93 if (!peek) {
94 nameMap.remove(violation.getDescriptor().getName());
95 }
96
97 if (ret.waive(violation, peek)) {
98 return ret;
99 }
100 }
101 }
102
103
104 Map nameMap=(Map) signatureMap.get(null);
105 Waiver ret = nameMap==null ? null : (Waiver) nameMap.get(violation.getDescriptor().getName());
106 boolean waived = ret!=null && ret.waive(violation, peek);
107
108 if (!waived) {
109 rejectedRequests.add(violation);
110 }
111
112 if (ret!=null && !ret.isActive()) {
113 nameMap.remove(ret.getInspectorName());
114 }
115
116 return waived ? ret : null;
117 }
118
119 return null;
120 }
121
122 public void addWaiver(Waiver waiver, Date now) {
123 if (waiver.getExpirationDate()==null || now.before(waiver.getExpirationDate())) {
124 Collection signatures = waiver.getSignatures();
125 if (signatures!=null && !signatures.isEmpty()) {
126 Iterator it=signatures.iterator();
127 while (it.hasNext()) {
128 String signature=(String) it.next();
129 getNameMap(signature).put(waiver.getInspectorName(), waiver);
130 }
131 } else {
132 getNameMap(null).put(waiver.getInspectorName(), waiver);
133 }
134 }
135 }
136
137
141 private Map getNameMap(String signature) {
142 Map nameMap=(Map) signatureMap.get(signature);
143 if (nameMap==null) {
144 nameMap=new HashMap();
145 signatureMap.put(signature, nameMap);
146 }
147 return nameMap;
148 }
149}
150
151
Hammurapi 3 Copyright © 2004 Hammurapi Group. All Rights Reserved.