Skip to content

Commit

Permalink
[JENKINS-24007] Put a warning about report in legacy format to build log
Browse files Browse the repository at this point in the history
  • Loading branch information
mixalturek committed Jul 28, 2014
1 parent d894e8e commit 5e25a29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -63,7 +63,7 @@ public CppcheckReport invoke(java.io.File basedir, VirtualChannel channel) throw
CppcheckLogger.log(listener, "Processing " + cppcheckReportFiles.length + " files with the pattern '" + cppcheckReportPattern + "'.");

for (String cppchecReportkFileName : cppcheckReportFiles) {
CppcheckReport cppcheckReport = new CppcheckParser().parse(new File(basedir, cppchecReportkFileName));
CppcheckReport cppcheckReport = new CppcheckParser().parse(new File(basedir, cppchecReportkFileName), listener);
mergeReport(cppcheckReportResult, cppcheckReport);
}
} catch (Exception e) {
Expand Down
@@ -1,9 +1,11 @@
package org.jenkinsci.plugins.cppcheck.parser;

import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckFile;
import hudson.model.BuildListener;
import org.jenkinsci.plugins.cppcheck.CppcheckReport;
import org.jenkinsci.plugins.cppcheck.model.Errors;
import org.jenkinsci.plugins.cppcheck.model.Results;
import org.jenkinsci.plugins.cppcheck.util.CppcheckLogger;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
Expand All @@ -22,7 +24,7 @@ public class CppcheckParser implements Serializable {

private static final long serialVersionUID = 1L;

public CppcheckReport parse(final File file) throws IOException {
public CppcheckReport parse(final File file, BuildListener listener) throws IOException {

if (file == null) {
throw new IllegalArgumentException("File input is mandatory.");
Expand Down Expand Up @@ -52,6 +54,11 @@ public CppcheckReport parse(final File file) throws IOException {
Unmarshaller unmarshaller = jc.get().createUnmarshaller();
com.thalesgroup.jenkinsci.plugins.cppcheck.model.Results results = (com.thalesgroup.jenkinsci.plugins.cppcheck.model.Results) unmarshaller.unmarshal(file);
report = getReportVersion1(results);

CppcheckLogger.log(listener, "WARNING: Legacy format of report file detected, "
+ "please consider to pass additional argument '--xml-version=2' to Cppcheck. "
+ "It often detects and reports more issues with the new format, "
+ "so its usage is highly recommended.");
} catch (JAXBException jxe1) {
// Since Java 1.6
// throw new IOException(jxe1);
Expand Down

0 comments on commit 5e25a29

Please sign in to comment.