1 23 24 package org.hammurapi; 25 26 import java.text.MessageFormat ; 27 import java.util.Iterator ; 28 29 import org.apache.tools.ant.Project; 30 import org.hammurapi.results.CompositeResults; 31 import org.hammurapi.results.ReviewResults; 32 33 38 public class ReviewToLogListener implements Listener { 39 private Project project; 40 41 42 public ReviewToLogListener(Project project) { 43 this.project=project; 44 } 45 46 public void onReview(ReviewResults reviewResult) throws HammurapiException { 47 if (reviewResult.getViolations().size()!=0) { 48 project.log("Violations in "+reviewResult.getCompilationUnit().getRelativeName()+":", Project.MSG_VERBOSE); 49 Iterator vit=reviewResult.getViolations().iterator(); 50 while (vit.hasNext()) { 51 Violation violation=(Violation) vit.next(); 52 Object [] objs = { 53 new Integer (violation.getSource().getLine()), 54 new Integer (violation.getSource().getColumn()), 55 violation.getDescriptor().getName(), 56 violation.getDescriptor().getSeverity(), 57 violation.getMessage() 58 }; 59 60 project.log(MessageFormat.format("{0}:{1} - {2}[{3}] {4}", objs), Project.MSG_VERBOSE); 61 } 62 } 63 64 project.log("Codebase: "+reviewResult.getCodeBase(), Project.MSG_VERBOSE); 65 project.log("Reviews: "+reviewResult.getReviewsNumber(), Project.MSG_VERBOSE); 66 project.log("Violations: "+reviewResult.getViolations().size(), Project.MSG_VERBOSE); 67 project.log("DPMO: "+reviewResult.getDPMO(), Project.MSG_VERBOSE); 69 project.log("Sigma: "+reviewResult.getSigma(), Project.MSG_VERBOSE); 70 project.log(" ", Project.MSG_VERBOSE); 71 } 72 73 public void onSummary(CompositeResults summary, InspectorSet ruleSet) throws HammurapiException { 74 project.log("=== Summary ==="); 75 project.log("Codebase: "+summary.getCodeBase()); 76 project.log("Reviews: "+summary.getReviewsNumber()); 77 project.log("Violations: "+summary.getViolationsNumber()); 78 project.log("DPMO: "+summary.getDPMO()); 80 project.log("Sigma: "+summary.getSigma()); 81 } 82 83 public void onPackage(CompositeResults packageResults) { 84 project.log("=== Package ===", Project.MSG_VERBOSE); 85 project.log("Package: "+packageResults.getName(), Project.MSG_VERBOSE); 86 project.log("Codebase: "+packageResults.getCodeBase(), Project.MSG_VERBOSE); 87 project.log("Reviews: "+packageResults.getReviewsNumber(), Project.MSG_VERBOSE); 88 project.log("Violations: "+packageResults.getViolationsNumber(), Project.MSG_VERBOSE); 89 project.log("DPMO: "+packageResults.getDPMO(), Project.MSG_VERBOSE); 91 project.log("Sigma: "+packageResults.getSigma(), Project.MSG_VERBOSE); 92 } 93 94 public void onBegin(InspectorSet inspectorSet) { 95 project.log("Review started with "+inspectorSet.size()+" inspectors"); 96 } 97 } 98 | Popular Tags |