Skip to content

Commit

Permalink
Fixed JENKINS-11096
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory authored and Gregory committed Sep 28, 2011
1 parent 6f20b56 commit 98289b4
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
Expand Up @@ -169,6 +169,7 @@ private Object readResolve() {
//Config
org.jenkinsci.plugins.cppcheck.config.CppcheckConfig newConfig = new org.jenkinsci.plugins.cppcheck.config.CppcheckConfig(
cppcheckConfig.getCppcheckReportPattern(),
true,
cppcheckConfig.isIgnoreBlankFiles(),
cppcheckConfig.getConfigSeverityEvaluation().getThreshold(),
cppcheckConfig.getConfigSeverityEvaluation().getNewThreshold(),
Expand Down
Expand Up @@ -223,6 +223,7 @@ public void setCppcheckConfig(CppcheckConfig cppcheckConfig) {
private Object readResolve() {
org.jenkinsci.plugins.cppcheck.config.CppcheckConfig newConfig = new org.jenkinsci.plugins.cppcheck.config.CppcheckConfig(
cppcheckConfig.getCppcheckReportPattern(),
true,
cppcheckConfig.isIgnoreBlankFiles(),
cppcheckConfig.getConfigSeverityEvaluation().getThreshold(),
cppcheckConfig.getConfigSeverityEvaluation().getNewThreshold(),
Expand Down
Expand Up @@ -53,10 +53,14 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
if (this.canContinue(build.getResult())) {
CppcheckLogger.log(listener, "Starting the cppcheck analysis.");

CppcheckParserResult parser = new CppcheckParserResult(listener, cppcheckConfig.getCppcheckReportPattern(), cppcheckConfig.isIgnoreBlankFiles());
CppcheckParserResult parser = new CppcheckParserResult(listener, cppcheckConfig.getPattern(), cppcheckConfig.isIgnoreBlankFiles());
CppcheckReport cppcheckReport;
try {
cppcheckReport = build.getModuleRoot().act(parser);
if (cppcheckConfig.isUseWorkspaceAsRootPath()) {
cppcheckReport = build.getWorkspace().act(parser);
} else {
cppcheckReport = build.getModuleRoot().act(parser);
}
} catch (Exception e) {
CppcheckLogger.log(listener, "Error on cppcheck analysis: " + e);
build.setResult(Result.FAILURE);
Expand Down Expand Up @@ -180,7 +184,6 @@ public Publisher newInstance(StaplerRequest req, JSONObject formData)
throws hudson.model.Descriptor.FormException {

CppcheckPublisher pub = new CppcheckPublisher();

CppcheckConfig cppcheckConfig = req.bindJSON(CppcheckConfig.class, formData);
pub.setCppcheckConfig(cppcheckConfig);

Expand Down
Expand Up @@ -10,7 +10,11 @@
*/
public class CppcheckConfig implements Serializable {

private String cppcheckReportPattern;
private transient String cppcheckReportPattern;

private String pattern;

private boolean useWorkspaceAsRootPath;

private boolean ignoreBlankFiles;

Expand All @@ -23,7 +27,8 @@ public CppcheckConfig() {

@DataBoundConstructor
@SuppressWarnings("unused")
public CppcheckConfig(String cppcheckReportPattern,
public CppcheckConfig(String pattern,
boolean useWorkspaceAsRootPath,
boolean ignoreBlankFiles, String threshold,
String newThreshold, String failureThreshold,
String newFailureThreshold, String healthy, String unHealthy,
Expand All @@ -40,7 +45,8 @@ public CppcheckConfig(String cppcheckReportPattern,
boolean displayPerformanceSeverity,
boolean displayInformationSeverity) {

this.cppcheckReportPattern = cppcheckReportPattern;
this.pattern = pattern;
this.useWorkspaceAsRootPath = useWorkspaceAsRootPath;
this.ignoreBlankFiles = ignoreBlankFiles;
this.configSeverityEvaluation = new CppcheckConfigSeverityEvaluation(
threshold, newThreshold, failureThreshold, newFailureThreshold, healthy, unHealthy,
Expand All @@ -59,10 +65,19 @@ public CppcheckConfig(String cppcheckReportPattern,
displayInformationSeverity);
}

public String getPattern() {
return pattern;
}

@Deprecated
public String getCppcheckReportPattern() {
return cppcheckReportPattern;
}

public boolean isUseWorkspaceAsRootPath() {
return useWorkspaceAsRootPath;
}

public boolean isIgnoreBlankFiles() {
return ignoreBlankFiles;
}
Expand All @@ -74,4 +89,12 @@ public CppcheckConfigSeverityEvaluation getConfigSeverityEvaluation() {
public CppcheckConfigGraph getConfigGraph() {
return configGraph;
}

@SuppressWarnings("unused")
private Object readResolve() {
if (this.cppcheckReportPattern != null) {
this.pattern = cppcheckReportPattern;
}
return this;
}
}
@@ -1,23 +1,28 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:u="/util">

<j:set var="config" value="${instance.cppcheckConfig}"/>
<j:if test="${config == null}">
<j:set var="config" value="${descriptor.config}"/>
</j:if>
<j:set var="config" value="${instance.cppcheckConfig}"/>
<j:if test="${config == null}">
<j:set var="config" value="${descriptor.config}"/>
</j:if>

<f:entry title="${%Cppcheck report XMLs}"
description="${%description.pattern('http://ant.apache.org/manual/Types/fileset.html')}">
<f:textbox name="cppcheckReportPattern" value="${config.cppcheckReportPattern}"/>
</f:entry>
<f:entry title="${%Cppcheck report XMLs}"
description="${%description.pattern('http://ant.apache.org/manual/Types/fileset.html')}">
<f:textbox name="cppcheck.pattern" value="${config.pattern}"/>
</f:entry>

<f:entry>
<f:checkbox name="ignoreBlankFiles" value="${config.ignoreBlankFiles}"/>
<label>Ignore blank files</label>
</f:entry>
<f:entry>
<f:checkbox name="cppcheck.useWorkspaceAsRootPath" checked="${config.useWorkspaceAsRootPath}"/>
<label>${%Use the workspace as root path to look for reports}</label>
</f:entry>

<f:advanced>
<f:entry>
<f:checkbox name="cppcheck.ignoreBlankFiles" checked="${config.ignoreBlankFiles}"/>
<label>${%Ignore blank files}</label>
</f:entry>

<f:advanced>
<u:thresholds id="cppcheck"/>
</f:advanced>
</f:advanced>

</j:jelly>

0 comments on commit 98289b4

Please sign in to comment.