Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JENKINS-10651] Add cppcheck to "Dashboard View"
- Cppcheck dashboard view implemented. There is a table, each job is a row and columns contain severity types. - Plugin dashboard-view is a new optional dependency.
- Loading branch information
1 parent
844874a
commit c7fbdb6
Showing
5 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckTablePortlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.jenkinsci.plugins.cppcheck; | ||
|
||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Descriptor; | ||
import hudson.model.Job; | ||
import hudson.model.Run; | ||
import hudson.plugins.view.dashboard.DashboardPortlet; | ||
|
||
/** | ||
* Dashboard portlet that shows a sortable table with jobs and Cppcheck | ||
* statistics per severity type. | ||
* | ||
* @author Michal Turek | ||
*/ | ||
public class CppcheckTablePortlet extends DashboardPortlet { | ||
/** | ||
* Constructor. | ||
* | ||
* @param name | ||
* the name of the portlet | ||
*/ | ||
@DataBoundConstructor | ||
public CppcheckTablePortlet(String name) { | ||
super(name); | ||
} | ||
|
||
/** | ||
* Get latest available Cppcheck statistics of a job. | ||
* | ||
* @param job | ||
* the job | ||
* @return the statistics, always non-null value | ||
*/ | ||
public CppcheckStatistics getStatistics(Job<?, ?> job) { | ||
Run<?, ?> build = job.getLastBuild(); | ||
|
||
while(build != null){ | ||
CppcheckBuildAction action = build.getAction(CppcheckBuildAction.class); | ||
|
||
if (action != null) { | ||
CppcheckResult result = action.getResult(); | ||
|
||
if(result != null) { | ||
return result.getStatistics(); | ||
} | ||
} | ||
|
||
build = build.getPreviousBuild(); | ||
} | ||
|
||
return new CppcheckStatistics(); | ||
} | ||
|
||
/** | ||
* Extension point registration. | ||
* | ||
* @author Michal Turek | ||
*/ | ||
@Extension(optional = true) | ||
public static class CppcheckTableDescriptor extends Descriptor<DashboardPortlet> { | ||
@Override | ||
public String getDisplayName() { | ||
return Messages.cppcheck_PortletName(); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/resources/org/jenkinsci/plugins/cppcheck/CppcheckTablePortlet/portlet.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<j:jelly xmlns:j="jelly:core" | ||
xmlns:st="jelly:stapler" | ||
xmlns:d="jelly:define" | ||
xmlns:dp="/hudson/plugins/view/dashboard" | ||
xmlns:l="/lib/layout" | ||
xmlns:t="/lib/hudson" | ||
xmlns:f="/lib/form"> | ||
|
||
<!-- According to https://wiki.jenkins-ci.org/display/JENKINS/Dashboard+View --> | ||
<dp:decorate portlet="${it}"> | ||
<tr><td> | ||
<div align="center"> | ||
<st:include page="table.jelly"/> | ||
</div> | ||
</td></tr> | ||
</dp:decorate> | ||
</j:jelly> |
74 changes: 74 additions & 0 deletions
74
src/main/resources/org/jenkinsci/plugins/cppcheck/CppcheckTablePortlet/table.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<j:jelly xmlns:j="jelly:core" | ||
xmlns:st="jelly:stapler" | ||
xmlns:l="/lib/layout" | ||
xmlns:t="/lib/hudson" | ||
xmlns:dp="/hudson/plugins/view/dashboard"> | ||
|
||
<style type="text/css"> | ||
.cppcheckTablePortlet .number { text-align: right; } | ||
</style> | ||
|
||
<table class="pane sortable cppcheckTablePortlet"> | ||
<j:set var="numberTotal" value="${0}"/> | ||
<j:set var="numberErrorSeverity" value="${0}"/> | ||
<j:set var="numberWarningSeverity" value="${0}"/> | ||
<j:set var="numberStyleSeverity" value="${0}"/> | ||
<j:set var="numberPerformanceSeverity" value="${0}"/> | ||
<j:set var="numberPortabilitySeverity" value="${0}"/> | ||
<j:set var="numberInformationSeverity" value="${0}"/> | ||
<j:set var="numberNoCategorySeverity" value="${0}"/> | ||
|
||
<thead> | ||
<tr> | ||
<td class="pane-header">${%Job}</td> | ||
<td class="pane-header">${%Total}</td> | ||
<td class="pane-header">${%Error}</td> | ||
<td class="pane-header">${%Warning}</td> | ||
<td class="pane-header">${%Style}</td> | ||
<td class="pane-header">${%Performance}</td> | ||
<td class="pane-header">${%Portability}</td> | ||
<td class="pane-header">${%Information}</td> | ||
<td class="pane-header">${%No category}</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<j:forEach var="job" items="${jobs}"> | ||
<tr> | ||
<j:set var="stats" value="${it.getStatistics(job)}" /> | ||
|
||
<td class="pane"><dp:jobLink job="${job}" /></td> | ||
<td class="pane number">${stats.numberTotal}</td> | ||
<td class="pane number">${stats.numberErrorSeverity}</td> | ||
<td class="pane number">${stats.numberWarningSeverity}</td> | ||
<td class="pane number">${stats.numberStyleSeverity}</td> | ||
<td class="pane number">${stats.numberPerformanceSeverity}</td> | ||
<td class="pane number">${stats.numberPortabilitySeverity}</td> | ||
<td class="pane number">${stats.numberInformationSeverity}</td> | ||
<td class="pane number">${stats.numberNoCategorySeverity}</td> | ||
|
||
<j:set var="numberTotal" value="${numberTotal + stats.numberTotal}"/> | ||
<j:set var="numberErrorSeverity" value="${numberErrorSeverity + stats.numberErrorSeverity}"/> | ||
<j:set var="numberWarningSeverity" value="${numberWarningSeverity + stats.numberWarningSeverity}"/> | ||
<j:set var="numberStyleSeverity" value="${numberStyleSeverity + stats.numberStyleSeverity}"/> | ||
<j:set var="numberPerformanceSeverity" value="${numberPerformanceSeverity + stats.numberPerformanceSeverity}"/> | ||
<j:set var="numberPortabilitySeverity" value="${numberPortabilitySeverity + stats.numberPortabilitySeverity}"/> | ||
<j:set var="numberInformationSeverity" value="${numberInformationSeverity + stats.numberInformationSeverity}"/> | ||
<j:set var="numberNoCategorySeverity" value="${numberNoCategorySeverity + stats.numberNoCategorySeverity}"/> | ||
</tr> | ||
</j:forEach> | ||
</tbody> | ||
<tfoot> | ||
<tr class="sortbottom"> | ||
<td class="pane-header">${%Total}</td> | ||
<td class="pane-header number">${numberTotal}</td> | ||
<td class="pane-header number">${numberErrorSeverity}</td> | ||
<td class="pane-header number">${numberWarningSeverity}</td> | ||
<td class="pane-header number">${numberStyleSeverity}</td> | ||
<td class="pane-header number">${numberPerformanceSeverity}</td> | ||
<td class="pane-header number">${numberPortabilitySeverity}</td> | ||
<td class="pane-header number">${numberInformationSeverity}</td> | ||
<td class="pane-header number">${numberNoCategorySeverity}</td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
</j:jelly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters