Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #17 from mixalturek/master
[JENKINS-23086] Cppcheck plugin shall display verbose information
  • Loading branch information
mixalturek committed May 18, 2014
2 parents 0f3a26e + 7edf263 commit 386c638
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
Expand Up @@ -150,7 +150,19 @@ private void splitSourceFile(final String sourceFile) {
output.append("\">\n");

output.append("<div tooltip=\"");
outputEscaped(output, cppcheckFile.getCppCheckId() + ": " + cppcheckFile.getMessage());

outputEscaped(output, "<h3>");
outputEscaped(output, cppcheckFile.getCppCheckId());
output.append(": ");
outputEscaped(output, cppcheckFile.getMessage());
outputEscaped(output, "</h3>");

if(cppcheckFile.getVerbose() != null) {
outputEscaped(output, "<p style=\"white-space: pre-wrap;\">");
outputEscaped(output, cppcheckFile.getVerbose());
outputEscaped(output, "</p>");
}

output.append("\" nodismiss=\"\">\n");
output.append("<code><b>\n");

Expand Down
Expand Up @@ -34,7 +34,7 @@
@ExportedBean(defaultVisibility = 999)
public class CppcheckFile implements ModelObject, Serializable {

private static final long serialVersionUID = 2L;
private static final long serialVersionUID = 3L;

private Integer key;

Expand All @@ -48,8 +48,11 @@ public class CppcheckFile implements ModelObject, Serializable {

private String message;

/** Verbose message, optional. */
private String verbose = null;

/** The issue may be false positive. */
private boolean inconclusive;
private boolean inconclusive = false;

@Exported
public String getFileName() {
Expand Down Expand Up @@ -136,6 +139,19 @@ public void setKey(Integer key) {
this.key = key;
}

@Exported
public String getVerbose() {
return verbose;
}

public String getVerboseHtml() {
return StringEscapeUtils.escapeHtml(verbose);
}

public void setVerbose(String verbose) {
this.verbose = verbose;
}

@Exported
public boolean isInconclusive() {
return inconclusive;
Expand Down
Expand Up @@ -146,6 +146,13 @@ private CppcheckReport getReportVersion2(Results results) {
cppcheckFile.setInconclusive((error.getInconclusive() != null)
? error.getInconclusive() : false);

// msg and verbose items have often the same text in XML report,
// there is no need to store duplications
if(error.getVerbose() != null
&& !error.getMsg().equals(error.getVerbose())) {
cppcheckFile.setVerbose(error.getVerbose());
}

if ("warning".equals(cppcheckFile.getSeverity())) {
warningSeverityList.add(cppcheckFile);
} else if ("style".equals(cppcheckFile.getSeverity())) {
Expand Down
Expand Up @@ -18,6 +18,7 @@
.cppcheck .lineNumber { color: gray; }
.cppcheck .highlighted { line-height: 2.1em; background-color: #FCAF3E; font-weight: bold; }
.cppcheck .header { font-weight: bold; }
.cppcheck .verbose { white-space: pre-wrap; }
</style>

<h1>${%Cppcheck Results}</h1>
Expand All @@ -27,7 +28,7 @@
<j:if test="${file.cppcheckFile.inconclusive}">
<j:set var="inconclusiveCss" value="inconclusiveCppcheck"/>
</j:if>

<div class="cppcheck ${file.diffState.css}Cppcheck ${inconclusiveCss}">
<h2>${file.cppcheckFile.messageHtml}</h2>

Expand All @@ -51,11 +52,15 @@
<div><span class="header">${%State:}&amp;nbsp;</span>${file.diffState.text}</div>
<div><span class="header">${%Severity:}&amp;nbsp;</span>${file.cppcheckFile.severity}</div>
<div><span class="header">${%Type:}&amp;nbsp;</span>${file.cppcheckFile.cppCheckId}</div>

<j:if test="${file.cppcheckFile.inconclusive}">
<div><span class="header">${%Inconclusive:}&amp;nbsp;</span>${file.cppcheckFile.inconclusive}</div>
</j:if>


<j:if test="${file.cppcheckFile.verbose != null}">
<p class="verbose">${file.cppcheckFile.verboseHtml}</p>
</j:if>

<j:if test="${not file.sourceIgnored}">
<code>
${it.getSourceCode(file)}
Expand Down
Expand Up @@ -19,6 +19,7 @@
<xs:attribute name="id" type="xs:string" use="required"/>
<xs:attribute name="severity" type="xs:string" use="required"/>
<xs:attribute name="msg" type="xs:string" use="required"/>
<xs:attribute name="verbose" type="xs:string" use="optional"/>
<xs:attribute name="inconclusive" type="xs:boolean" use="optional"/>
</xs:complexType>
</xs:element>
Expand Down

0 comments on commit 386c638

Please sign in to comment.