Skip to content

Commit 6fb2c23

Browse files
committedMay 18, 2014
[JENKINS-23086] Cppcheck plugin shall display verbose information
- Parsing and storing of the verbose attribute implemented. - If the value is the same as msg, it will be ignored. - Verbose information is displayed inside the tooltip on page with source code listing and on the page with all violations.
1 parent 689323a commit 6fb2c23

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed
 

‎src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,20 @@ private void splitSourceFile(final String sourceFile) {
150150
output.append("\">\n");
151151

152152
output.append("<div tooltip=\"");
153-
outputEscaped(output, cppcheckFile.getCppCheckId() + ": " + cppcheckFile.getMessage());
154-
output.append("\" nodismiss=\"\">\n");
153+
154+
outputEscaped(output, "<h3>");
155+
outputEscaped(output, cppcheckFile.getCppCheckId());
156+
output.append(": ");
157+
outputEscaped(output, cppcheckFile.getMessage());
158+
outputEscaped(output, "</h3>");
159+
160+
if(cppcheckFile.getVerbose() != null) {
161+
outputEscaped(output, "<p style=\"white-space: pre-wrap;\">");
162+
outputEscaped(output, cppcheckFile.getVerbose());
163+
outputEscaped(output, "</p>");
164+
}
165+
166+
output.append("\">\n");
155167
output.append("<code><b>\n");
156168

157169
//The current line error

‎src/main/java/com/thalesgroup/hudson/plugins/cppcheck/model/CppcheckFile.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@ExportedBean(defaultVisibility = 999)
3535
public class CppcheckFile implements ModelObject, Serializable {
3636

37-
private static final long serialVersionUID = 2L;
37+
private static final long serialVersionUID = 3L;
3838

3939
private Integer key;
4040

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

4949
private String message;
5050

51+
/** Verbose message, optional. */
52+
private String verbose = null;
53+
5154
/** The issue may be false positive. */
52-
private boolean inconclusive;
55+
private boolean inconclusive = false;
5356

5457
@Exported
5558
public String getFileName() {
@@ -136,6 +139,19 @@ public void setKey(Integer key) {
136139
this.key = key;
137140
}
138141

142+
@Exported
143+
public String getVerbose() {
144+
return verbose;
145+
}
146+
147+
public String getVerboseHtml() {
148+
return StringEscapeUtils.escapeHtml(verbose);
149+
}
150+
151+
public void setVerbose(String verbose) {
152+
this.verbose = verbose;
153+
}
154+
139155
@Exported
140156
public boolean isInconclusive() {
141157
return inconclusive;

‎src/main/java/org/jenkinsci/plugins/cppcheck/parser/CppcheckParser.java

+7
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ private CppcheckReport getReportVersion2(Results results) {
146146
cppcheckFile.setInconclusive((error.getInconclusive() != null)
147147
? error.getInconclusive() : false);
148148

149+
// msg and verbose items have often the same text in XML report,
150+
// there is no need to store duplications
151+
if(error.getVerbose() != null
152+
&& !error.getMsg().equals(error.getVerbose())) {
153+
cppcheckFile.setVerbose(error.getVerbose());
154+
}
155+
149156
if ("warning".equals(cppcheckFile.getSeverity())) {
150157
warningSeverityList.add(cppcheckFile);
151158
} else if ("style".equals(cppcheckFile.getSeverity())) {

‎src/main/resources/org/jenkinsci/plugins/cppcheck/CppcheckSourceAll/index.jelly

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
.cppcheck .lineNumber { color: gray; }
1919
.cppcheck .highlighted { line-height: 2.1em; background-color: #FCAF3E; font-weight: bold; }
2020
.cppcheck .header { font-weight: bold; }
21+
.cppcheck .verbose { white-space: pre-wrap; }
2122
</style>
2223

2324
<h1>${%Cppcheck Results}</h1>
@@ -27,7 +28,7 @@
2728
<j:if test="${file.cppcheckFile.inconclusive}">
2829
<j:set var="inconclusiveCss" value="inconclusiveCppcheck"/>
2930
</j:if>
30-
31+
3132
<div class="cppcheck ${file.diffState.css}Cppcheck ${inconclusiveCss}">
3233
<h2>${file.cppcheckFile.messageHtml}</h2>
3334

@@ -51,11 +52,15 @@
5152
<div><span class="header">${%State:}&amp;nbsp;</span>${file.diffState.text}</div>
5253
<div><span class="header">${%Severity:}&amp;nbsp;</span>${file.cppcheckFile.severity}</div>
5354
<div><span class="header">${%Type:}&amp;nbsp;</span>${file.cppcheckFile.cppCheckId}</div>
54-
55+
5556
<j:if test="${file.cppcheckFile.inconclusive}">
5657
<div><span class="header">${%Inconclusive:}&amp;nbsp;</span>${file.cppcheckFile.inconclusive}</div>
5758
</j:if>
58-
59+
60+
<j:if test="${file.cppcheckFile.verbose != null}">
61+
<p class="verbose">${file.cppcheckFile.verboseHtml}</p>
62+
</j:if>
63+
5964
<j:if test="${not file.sourceIgnored}">
6065
<code>
6166
${it.getSourceCode(file)}

‎src/main/resources/org/jenkinsci/plugins/cppcheck/cppcheck-2.0.xsd

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<xs:attribute name="id" type="xs:string" use="required"/>
2020
<xs:attribute name="severity" type="xs:string" use="required"/>
2121
<xs:attribute name="msg" type="xs:string" use="required"/>
22+
<xs:attribute name="verbose" type="xs:string" use="optional"/>
2223
<xs:attribute name="inconclusive" type="xs:boolean" use="optional"/>
2324
</xs:complexType>
2425
</xs:element>

0 commit comments

Comments
 (0)
Please sign in to comment.