Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor glitches in coverage table #35

Merged
merged 1 commit into from
Sep 13, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions src/main/java/hudson/plugins/jacoco/report/CoverageReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,20 @@ private String getMethodName(IClassCoverage classCov, IMethodCoverage methodCov)
return sb.toString();
}

static NumberFormat dataFormat = new DecimalFormat("000.00", new DecimalFormatSymbols(Locale.US));
static NumberFormat percentFormat = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.US));
static NumberFormat intFormat = new DecimalFormat("0", new DecimalFormatSymbols(Locale.US));
static final NumberFormat dataFormat = new DecimalFormat("000.00", new DecimalFormatSymbols(Locale.US));
static final NumberFormat percentFormat = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.US));

@Override
protected void printRatioCell(boolean failed, Coverage ratio, StringBuilder buf) {
if (ratio != null && ratio.isInitialized()) {
//String className = "nowrap" + (failed ? " red" : "");
String bgColor = "#FFFFFF";

if (JacocoHealthReportThresholds.RESULT.BETWEENMINMAX == healthReports.getResultByTypeAndRatio(ratio)) {
bgColor = "#FF8000";
} else if (JacocoHealthReportThresholds.RESULT.BELLOWMINIMUM == healthReports.getResultByTypeAndRatio(ratio)) {
bgColor = "#FF0000";
}
buf.append("<td bgcolor=\" "+ bgColor +" \" class='").append("").append("'");
buf.append("<td bgcolor='").append(bgColor).append("'");
buf.append(" data='").append(dataFormat.format(ratio.getPercentageFloat()));
buf.append("'>\n");
printRatioTable(ratio, buf);
Expand All @@ -199,21 +197,17 @@ protected void printRatioCell(boolean failed, Coverage ratio, StringBuilder buf)

@Override
protected void printRatioTable(Coverage ratio, StringBuilder buf){
//String percent = percentFormat.format(ratio.getPercentageFloat());
String numerator = intFormat.format(ratio.getMissed());
String denominator = intFormat.format(ratio.getCovered());

buf.append("<table class='percentgraph' cellpadding='0px' cellspacing='0px'><tr class='percentgraph'>")
.append("<td width='40px' class='data'>").append(ratio.getPercentage()).append("%</td>")
buf.append("<table class='percentgraph' cellpadding='0' cellspacing='0'><tr class='percentgraph'>")
.append("<td style='width:40px' class='data'>").append(ratio.getPercentage()).append("%</td>")
.append("<td class='percentgraph'>")
.append("<div class='percentgraph' style='width: ").append(100).append("px;'>")
.append("<div class='redbar' style='width: ").append(((float)ratio.getMissed()/(float)(ratio.getMissed() + ratio.getCovered()))*100).append("px;'>")
.append("</div></div></td></tr>" +
"<tr>").append("<span class='text'>").append("<b>M:</b> "+numerator).append(" ").append("<b>C:</b> "+ denominator).append("</span></tr>").append("</table>");
.append("<div class='percentgraph' style='width:100px'>")
.append("<div class='redbar' style='width:")
.append(100 - ratio.getPercentage()).append("px'>")
.append("</div></div></td></tr><tr><td colspan='2'>")
.append("<span class='text'><b>M:</b> ").append(ratio.getMissed())
.append(" <b>C:</b> ").append(ratio.getCovered()).append("</span></td></tr></table>\n");
}



@Override
public CoverageReport getPreviousResult() {
JacocoBuildAction prev = action.getPreviousResult();
Expand Down