Skip to content

Commit

Permalink
[JENKINS-21927] Redesign of build summary page
Browse files Browse the repository at this point in the history
- List in build summary updated to a sortable table that is better readable and more usable. The displayed values were fixed, e.g. negative result in delta can be displayed.
- The design is fully defined in jelly instead of in Java code.
- CppcheckSummary class is not needed, removed.
  • Loading branch information
mixalturek committed Feb 23, 2014
1 parent 5db2c79 commit 8edec09
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 132 deletions.
46 changes: 26 additions & 20 deletions src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckResult.java
Expand Up @@ -143,29 +143,10 @@ public Object getDynamic(final String link, final StaplerRequest request, final
return null;
}


/**
* Renders the summary Cppcheck report for the build result.
*
* @return the HTML fragment of the summary Cppcheck report
*/
public String getSummary() {
return CppcheckSummary.createReportSummary(this);
}

/**
* Renders the detailed summary Cppcheck report for the build result.
*
* @return the HTML fragment of the summary Cppcheck report
*/
public String getDetails() {
return CppcheckSummary.createReportSummaryDetails(this);
}

/**
* Gets the previous Cppcheck result for the build result.
*
* @return the previous Cppcheck result
* @return the previous Cppcheck result or null
*/
public CppcheckResult getPreviousResult() {
CppcheckBuildAction previousAction = getPreviousAction();
Expand All @@ -190,6 +171,31 @@ private CppcheckBuildAction getPreviousAction() {
return null;
}

/**
* Get differences between current and previous statistics.
*
* @return the differences
*/
public CppcheckStatistics getDiff(){
CppcheckStatistics current = getStatistics();
CppcheckResult previousResult = getPreviousResult();

if(previousResult == null) {
return new CppcheckStatistics(0, 0, 0, 0, 0, 0, current.getVersions());
}

CppcheckStatistics previous = previousResult.getStatistics();

return new CppcheckStatistics(
current.getNumberErrorSeverity() - previous.getNumberErrorSeverity(),
current.getNumberWarningSeverity() - previous.getNumberWarningSeverity(),
current.getNumberStyleSeverity() - previous.getNumberStyleSeverity(),
current.getNumberPerformanceSeverity() - previous.getNumberPerformanceSeverity(),
current.getNumberInformationSeverity() - previous.getNumberInformationSeverity(),
current.getNumberNoCategorySeverity() - previous.getNumberNoCategorySeverity(),
current.getVersions());
}

/**
* Returns the number of new errors from the previous build result.
*
Expand Down
Expand Up @@ -113,4 +113,14 @@ public Set<String> getVersions() {
return (versions != null) ? Collections.unmodifiableSet(versions)
: null;
}

public String formatDiff(int value)
{
if(value == 0)
{
return "";
}

return String.format("%+d", value);
}
}
106 changes: 0 additions & 106 deletions src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSummary.java

This file was deleted.

@@ -1,9 +1,74 @@
<j:jelly xmlns:j="jelly:core"
xmlns:t="/lib/hudson">
xmlns:d="jelly:define"
xmlns:l="/lib/layout"
xmlns:t="/lib/hudson"
xmlns:f="/lib/form"
xmlns:i="jelly:fmt">

<t:summary icon="/plugin/cppcheck/icons/cppcheck-48.png">
${it.result.summary}
<ul>
${it.result.details}
</ul>
<div><a href="cppcheckResult">${%Cppcheck}</a></div>

<j:set var="current" value="${it.result.statistics}"/>
<j:set var="diff" value="${it.result.diff}"/>

<style type="text/css">
#cppcheckSummary { width: auto; }
#cppcheckSummary .number { text-align: right; }
</style>

<table class="pane sortable" id="cppcheckSummary">
<thead>
<tr>
<td class="pane-header">${%Severity}</td>
<td class="pane-header">${%Count}</td>
<td class="pane-header">${%Delta}</td>
</tr>
</thead>
<tbody>
<tr>
<td class="pane" data="6">${%Error}</td>
<td class="pane number" data="${current.numberErrorSeverity}">${current.numberErrorSeverity}</td>
<td class="pane number" data="${diff.numberErrorSeverity}">${diff.formatDiff(diff.numberErrorSeverity)}</td>
</tr>

<tr>
<td class="pane" data="5">${%Warning}</td>
<td class="pane number" data="${current.numberWarningSeverity}">${current.numberWarningSeverity}</td>
<td class="pane number" data="${diff.numberWarningSeverity}">${diff.formatDiff(diff.numberWarningSeverity)}</td>
</tr>

<tr>
<td class="pane" data="4">${%Style}</td>
<td class="pane number" data="${current.numberStyleSeverity}">${current.numberStyleSeverity}</td>
<td class="pane number" data="${diff.numberStyleSeverity}">${diff.formatDiff(diff.numberStyleSeverity)}</td>
</tr>

<tr>
<td class="pane" data="3">${%Performance}</td>
<td class="pane number" data="${current.numberPerformanceSeverity}">${current.numberPerformanceSeverity}</td>
<td class="pane number" data="${diff.numberPerformanceSeverity}">${diff.formatDiff(diff.numberPerformanceSeverity)}</td>
</tr>

<tr>
<td class="pane" data="2">${%Information}</td>
<td class="pane number" data="${current.numberInformationSeverity}">${current.numberInformationSeverity}</td>
<td class="pane number" data="${diff.numberInformationSeverity}">${diff.formatDiff(diff.numberInformationSeverity)}</td>
</tr>

<tr>
<td class="pane" data="1">${%No Category}</td>
<td class="pane number" data="${current.numberNoCategorySeverity}">${current.numberNoCategorySeverity}</td>
<td class="pane number" data="${diff.numberNoCategorySeverity}">${diff.formatDiff(diff.numberNoCategorySeverity)}</td>
</tr>
</tbody>
<tfoot>
<tr class="sortbottom">
<td class="pane-header" data="0">${%Total}</td>
<td class="pane-header number" data="${current.numberTotal}">${current.numberTotal}</td>
<td class="pane-header number" data="${diff.numberTotal}">${diff.formatDiff(diff.numberTotal)}</td>
</tr>
</tfoot>
</table>

</t:summary>
</j:jelly>
</j:jelly>

0 comments on commit 8edec09

Please sign in to comment.