Navigation Menu

Skip to content

Commit

Permalink
Fix JENKINS-11114
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed Apr 21, 2012
1 parent 8143509 commit f637c83
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
Expand Up @@ -169,6 +169,7 @@ private CppcheckBuildAction getPreviousAction() {
*
* @return the number of new errors
*/
@SuppressWarnings("unused")
public int getNumberNewErrorsFromPreviousBuild() {
CppcheckResult previousCppcheckResult = getPreviousResult();
if (previousCppcheckResult == null) {
Expand Down
54 changes: 42 additions & 12 deletions src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSummary.java
Expand Up @@ -46,28 +46,58 @@ public static String createReportSummary(CppcheckResult result) {
/**
* Creates an HTML Cppcheck detailed summary.
*
* @param result the cppcheck result object
* @param cppcheckResult the cppcheck result object
* @return the HTML fragment representing the cppcheck report details summary
*/
public static String createReportSummaryDetails(CppcheckResult result) {
public static String createReportSummaryDetails(CppcheckResult cppcheckResult) {

if (cppcheckResult == null) {
return null;
}

StringBuilder builder = new StringBuilder();
int nbNewErrors = result.getNumberNewErrorsFromPreviousBuild();

CppcheckResult previousCppcheckResult = cppcheckResult.getPreviousResult();

CppcheckReport cppcheckReport = cppcheckResult.getReport();
CppcheckReport previousCppcheckReport = previousCppcheckResult.getReport();

builder.append("<li>");
int nbNewErrorSeverity = getNbNew(cppcheckReport.getNumberErrorSeverity(), previousCppcheckReport.getNumberErrorSeverity());
builder.append(String.format("Severity Error (nb/new) : %s/+%s", cppcheckReport.getNumberErrorSeverity(), nbNewErrorSeverity));
builder.append("</li>");

builder.append("<li>");
int nbNewWarningSeverity = getNbNew(cppcheckReport.getNumberWarningSeverity(), previousCppcheckReport.getNumberWarningSeverity());
builder.append(String.format("Severity Warning (nb/new) : %s/+%s", cppcheckReport.getNumberWarningSeverity(), nbNewWarningSeverity));
builder.append("</li>");

if (nbNewErrors == 0) {
builder.append(Messages.cppcheck_ResultAction_Detail_NoNewError());
} else if (nbNewErrors == 1) {
builder.append(Messages.cppcheck_ResultAction_Detail_NewOneError());
} else {
builder.append(Messages.cppcheck_ResultAction_Detail_NewMultipleErrors());
builder.append(": ");
builder.append(nbNewErrors);
}
builder.append("<li>");
int nbNewStyleSeverity = getNbNew(cppcheckReport.getNumberStyleSeverity(), previousCppcheckReport.getNumberStyleSeverity());
builder.append(String.format("Severity Style (nb/new) : %s/+%s", cppcheckReport.getNumberStyleSeverity(), nbNewStyleSeverity));
builder.append("</li>");

builder.append("<li>");
int nbNewPerformanceSeverity = getNbNew(cppcheckReport.getNumberPerformanceSeverity(), previousCppcheckReport.getNumberPerformanceSeverity());
builder.append(String.format("Severity Performance (nb/new) : %s/+%s", cppcheckReport.getNumberPerformanceSeverity(), nbNewPerformanceSeverity));
builder.append("</li>");

builder.append("<li>");
int nbNewInformationSeverity = getNbNew(cppcheckReport.getNumberInformationSeverity(), previousCppcheckReport.getNumberInformationSeverity());
builder.append(String.format("Severity Information (nb/new) : %s/+%s", cppcheckReport.getNumberInformationSeverity(), nbNewInformationSeverity));
builder.append("</li>");

builder.append("<li>");
int nbNewNoCategorySeverity = getNbNew(cppcheckReport.getNumberNoCategorySeverity(), previousCppcheckReport.getNumberNoCategorySeverity());
builder.append(String.format("Severity Unknown (nb/new) : %s/%s", cppcheckReport.getNumberNoCategorySeverity(), nbNewNoCategorySeverity));
builder.append("</li>");

return builder.toString();
}

private static int getNbNew(int numberError, int numberPreviousError) {
int diff = numberError - numberPreviousError;
return (diff > 0) ? diff : 0;
}

}
@@ -0,0 +1,4 @@
cppcheck.Errors_ProjectAction_Name=Cppcheck
cppcheck.ResultAction.NoError=no error
cppcheck.ResultAction.OneError=1 error
cppcheck.ResultAction.MultipleErrors={0} errors

0 comments on commit f637c83

Please sign in to comment.