Changeset 1319
- Timestamp:
- 03/28/09 14:15:26 (3 years ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
config/build-report.xml (modified) (3 diffs)
-
config/jcoderz-report-filter.xsl (modified) (1 diff)
-
src/java/org/jcoderz/phoenix/report/JcReportAntTask.java (modified) (8 diffs)
-
src/java/org/jcoderz/phoenix/report/ReportMerger.java (modified) (7 diffs)
-
src/java/org/jcoderz/phoenix/report/Severity.java (modified) (2 diffs)
-
src/xml/schema/report-types.xsd (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/config/build-report.xml
r1317 r1319 94 94 </path> 95 95 96 97 96 98 <delete dir="${base.dir}/build/jcreport"/> 97 99 <jcreport name="fawkez" … … 106 108 maxheap="128" 107 109 encoding="US-ASCII" 108 cpus="0"> <!-- Increase to speed up --> 110 cpus="0" 111 oldReportFile="${env.CRUISECONTROL_HOME}/artifacts/${name}/global/jcoderz-report.xml"> 109 112 <classpath refid="jcreport.classpath"/> 110 113 <reports> … … 152 155 </filters> 153 156 </jcreport> 157 <!-- TODO: Only do this on the cc machine. --> 158 <copy 159 file="${base.dir}/build/doc/findings-report/jcoderz-report.xml" 160 tofile="${env.CRUISECONTROL_HOME}/artifacts/${name}/global/jcoderz-report.xml" /> 154 161 </target> 155 162 -
trunk/config/jcoderz-report-filter.xsl
r1011 r1319 267 267 </xs:template> 268 268 269 <xs:template 270 match="/report/file[@classname = 'LogViewer'][@package = 'org.jcoderz.commons.logging']/ 271 item[@finding-type = 'SMII_STATIC_METHOD_INSTANCE_INVOCATION']"> 272 <item> 273 <xs:apply-templates select="@*"/> 274 <xs:attribute name="severity">filtered</xs:attribute> 275 <xs:attribute name="severity-reason">Intended use of return value.</xs:attribute> 276 </item> 277 </xs:template> 269 278 270 279 </xs:stylesheet> -
trunk/src/java/org/jcoderz/phoenix/report/JcReportAntTask.java
r1237 r1319 94 94 private String mName = null; 95 95 private File mDest = null; 96 private File mOldReportFile = null; 96 97 private String mWikiBase = null; 97 98 private String mWebRcsBase = null; … … 120 121 } 121 122 122 123 123 /** 124 124 * @param cpus the cpus to set … … 129 129 } 130 130 131 132 /** 131 /** 133 132 * @return the sourceEncoding 134 133 */ … … 137 136 return mSourceEncoding.name(); 138 137 } 139 140 138 141 139 /** … … 147 145 } 148 146 149 150 /** 147 /** 151 148 * Returns the working directory. 152 149 * … … 157 154 return mWorkingDir; 158 155 } 159 160 156 161 157 /** … … 223 219 } 224 220 221 public void setOldReportsFile (String oldReportsFile) 222 { 223 mOldReportFile = new File(oldReportsFile); 224 } 225 225 226 226 /** … … 594 594 final NestedFilterElement filterElement = filterIter.next(); 595 595 merger.addFilter(filterElement.getFile()); 596 } 597 if (mOldReportFile != null) 598 { 599 merger.setOldFile(mOldReportFile); 596 600 } 597 601 merger.merge(); -
trunk/src/java/org/jcoderz/phoenix/report/ReportMerger.java
r1011 r1319 52 52 53 53 import org.jcoderz.commons.ArgumentMalformedException; 54 import org.jcoderz.commons.util.Assert; 54 55 import org.jcoderz.commons.util.FileUtils; 55 56 import org.jcoderz.commons.util.IoUtil; 56 57 import org.jcoderz.commons.util.LoggingUtils; 58 import org.jcoderz.phoenix.report.jaxb.Item; 57 59 import org.jcoderz.phoenix.report.jaxb.ObjectFactory; 58 60 import org.jcoderz.phoenix.report.jaxb.Report; … … 85 87 private final List<File> mFilters = new ArrayList<File>(); 86 88 89 /** The old Report. */ 90 private File mOldReport; 91 87 92 88 93 /** … … 135 140 logger.log(Level.FINE, "Filter: " + filterFile); 136 141 final TransformerFactory tFactory 137 = TransformerFactory.newInstance();138 139 final Transformer transformer = tFactory.newTransformer(140 new StreamSource(filterFile));141 142 final File tempOutputFile = new File(143 mOutFile.getCanonicalPath() + ".tmp");142 = TransformerFactory.newInstance(); 143 144 final Transformer transformer 145 = tFactory.newTransformer(new StreamSource(filterFile)); 146 147 final File tempOutputFile 148 = new File(mOutFile.getCanonicalPath() + ".tmp"); 144 149 tempOutputFile.createNewFile(); 145 150 … … 153 158 } 154 159 155 156 160 /** 161 * Searches for new findings based on the old jcReport and increases the 162 * severity of such findings to NEW. 163 */ 164 public void flagNewFindings () 165 throws JAXBException, FileNotFoundException 166 { 167 logger.log(Level.FINE, "Searching for NEW findings..."); 168 final Report currentReport 169 = (Report) new ObjectFactory().createUnmarshaller().unmarshal(mOutFile); 170 final Report oldReport 171 = (Report) new ObjectFactory().createUnmarshaller().unmarshal(mOldReport); 172 for(org.jcoderz.phoenix.report.jaxb.File newFile : 173 (List<org.jcoderz.phoenix.report.jaxb.File>) currentReport.getFile()) 174 { 175 final org.jcoderz.phoenix.report.jaxb.File oldFile 176 = findFile(newFile, oldReport); 177 for(Item item:(List<Item>) newFile.getItem()) 178 { 179 if (findItem(item, oldFile) == null) 180 { 181 flagAsNew(item); 182 } 183 } 184 } 185 186 final FileOutputStream out = new FileOutputStream(mOutFile); 187 try 188 { 189 new ObjectFactory().createMarshaller().marshal(currentReport, out); 190 } 191 finally 192 { 193 IoUtil.close(out); 194 } 195 } 196 197 // be more smart in finding matching items... (eg if the file was edited) 198 private Item findItem ( 199 Item newItem, org.jcoderz.phoenix.report.jaxb.File oldFile) 200 { 201 Item result = null; 202 for(Item item:(List<Item>) oldFile.getItem()) 203 { 204 if (item.getLine() == newItem.getLine() 205 && item.getColumn() == newItem.getColumn() 206 && item.getFindingType().equals(newItem.getFindingType()) 207 && item.getCounter() <= newItem.getCounter()) 208 { 209 result = item; 210 break; 211 } 212 } 213 return result; 214 } 215 216 217 private void flagAsNew (Item item) 218 { 219 final Severity oldSeverity = item.getSeverity(); 220 item.setSeverity(Severity.NEW); 221 item.setMessage( 222 item.getMessage() + " Severity " + oldSeverity + "."); 223 } 224 225 226 // This could be done faster, might be restructure the data first for 227 // faster lookup. 228 private org.jcoderz.phoenix.report.jaxb.File findFile ( 229 org.jcoderz.phoenix.report.jaxb.File newFile, Report oldReport) 230 { 231 final String className = newFile.getClassname(); 232 final String packageName = newFile.getPackage(); 233 final String fileName = newFile.getName(); 234 org.jcoderz.phoenix.report.jaxb.File result = null; 235 for(org.jcoderz.phoenix.report.jaxb.File file : 236 (List<org.jcoderz.phoenix.report.jaxb.File>) oldReport.getFile()) 237 { 238 if (file.getName().equals(fileName) 239 || (file.getClassname().equals(className) 240 && file.getPackage().equals(packageName))) 241 { 242 result = file; 243 break; 244 } 245 } 246 return result; 247 } 248 249 250 /** 157 251 * Parses the arguments. 158 252 * … … 175 269 { 176 270 addFilter(new File(args[i + 1])); 271 } 272 else if ("-old".equals(args[i])) 273 { 274 setOldFile(new File(args[i + 1])); 177 275 } 178 276 else if ("-loglevel".equals(args[i])) … … 210 308 } 211 309 212 213 310 /** 214 311 * The main method. … … 280 377 281 378 /** 379 * Set the old report to compare with. 380 * @param file old report file. 381 */ 382 public void setOldFile (File file) 383 throws IOException 384 { 385 Assert.notNull(file, "file"); 386 if (mOldReport != null) 387 { 388 throw new ArgumentMalformedException("old", file, 389 "Old Report File has already set to '" + mOldReport + "'."); 390 } 391 mOldReport = file.getCanonicalFile(); 392 } 393 394 /** 282 395 * Sets the out file. 283 396 * -
trunk/src/java/org/jcoderz/phoenix/report/Severity.java
r217 r1319 172 172 public static final Severity ERROR = new Severity("error", 100); 173 173 174 /** 175 * New findings of this build. 176 * <p>Findings of this level are new in this build and because of that 177 * rated at higher severity level in this one build.</p> 178 * <p>A severity of this level marks 10 lines as bad.</p> 179 */ 180 public static final Severity NEW = new Severity("new", 100); 181 174 182 /** 175 183 * The maximum possible severity. 176 * Is {@link # ERROR}.177 */ 178 public static final Severity MAX_SEVERITY = ERROR;184 * Is {@link #NEW}. 185 */ 186 public static final Severity MAX_SEVERITY = NEW; 179 187 180 188 /** The maximum possible severity as int. */ 181 public static final int MAX_SEVERITY_INT = ERROR.toInt();189 public static final int MAX_SEVERITY_INT = MAX_SEVERITY.toInt(); 182 190 183 191 /** Internal list of all available severities. */ … … 192 200 Severity.WARNING, 193 201 Severity.CPD, 194 Severity.ERROR 202 Severity.ERROR, 203 Severity.NEW 195 204 }; 196 205 -
trunk/src/xml/schema/report-types.xsd
r1011 r1319 28 28 <xsd:enumeration value='cpd'/> 29 29 <xsd:enumeration value='error'/> 30 <xsd:enumeration value='new'/> 30 31 </xsd:restriction> 31 32 </xsd:simpleType>
