From 074ab641deeb25e262a89bb83b6cbae11d2765cc Mon Sep 17 00:00:00 2001 From: "EUROPE\\wvandepol" Date: Thu, 24 Aug 2017 14:19:06 +0200 Subject: [PATCH 1/9] Add support for Jenkins pipeline 2.0 --- pom.xml | 85 ++++++- .../cppcheck/CppcheckAreaRenderer.java | 26 +++ .../plugins/cppcheck/CppcheckBuildAction.java | 10 +- .../cppcheck/CppcheckParserResult.java | 8 +- .../cppcheck/CppcheckProjectAction.java | 3 + .../plugins/cppcheck/CppcheckResult.java | 2 +- .../plugins/cppcheck/CppcheckSource.java | 13 +- .../plugins/cppcheck/graph/CppcheckGraph.java | 4 +- .../cppcheck/model/CppcheckWorkspaceFile.java | 11 +- .../util/AbstractCppcheckBuildAction.java | 8 +- .../plugins/cppcheck/util/CppcheckUtil.java | 6 +- .../plugins/cppcheck/CppcheckBuildAction.java | 25 +- .../cppcheck/CppcheckParserResult.java | 12 +- .../cppcheck/CppcheckProjectAction.java | 23 +- .../plugins/cppcheck/CppcheckPublisher.java | 214 ++++++++++++++++-- .../plugins/cppcheck/CppcheckReport.java | 1 + .../plugins/cppcheck/CppcheckResult.java | 37 +-- .../plugins/cppcheck/CppcheckSourceAll.java | 16 +- .../cppcheck/CppcheckSourceContainer.java | 7 +- .../cppcheck/config/CppcheckConfigGraph.java | 186 +++++++-------- .../cppcheck/parser/CppcheckParser.java | 8 +- .../util/AbstractCppcheckProjectAction.java | 15 +- .../util/CppcheckBuildResultEvaluator.java | 4 +- .../plugins/cppcheck/util/CppcheckLogger.java | 4 + 24 files changed, 529 insertions(+), 199 deletions(-) diff --git a/pom.xml b/pom.xml index e3ef74a..708a256 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 1.447 + 2.0 cppcheck @@ -31,6 +31,10 @@ Michal Turek mixalturek@users.sf.net + + marcosteffan + Marco Steffan + @@ -38,18 +42,19 @@ scm:git:git@github.com:jenkinsci/cppcheck-plugin.git HEAD - + UTF-8 1.6 1.6 2.2.1 2.2.1.1 - 2.1 + 1.3 5.0 4.8.2 1.8.5 2.0 + 2.30 @@ -102,7 +107,65 @@ + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.jacoco + jacoco-maven-plugin + [0.5,) + + + prepare-agent + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + InjectedTest.java + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + InjectedTest.java + + + + + + + + org.codehaus.mojo jaxb2-maven-plugin @@ -112,9 +175,11 @@ generatedCppcheck1 com.thalesgroup.jenkinsci.plugins.cppcheck.model - - ${basedir}/src/main/resources/com/thalesgroup/hudson/plugins/cppcheck/cppcheck-1.0.xsd - + ${basedir}/src/main/resources/com/thalesgroup/hudson/plugins/cppcheck + + cppcheck-1.0.xsd + ${project.build.directory}/generated-sources/jaxb/cppcheck1/.staleFlag. + false @@ -125,9 +190,11 @@ generatedCppcheck2 org.jenkinsci.plugins.cppcheck.model - - ${basedir}/src/main/resources/org/jenkinsci/plugins/cppcheck/cppcheck-2.0.xsd - + ${basedir}/src/main/resources/org/jenkinsci/plugins/cppcheck + + cppcheck-2.0.xsd + ${project.build.directory}/generated-sources/jaxb/cppcheck2/.staleFlag. + false diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckAreaRenderer.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckAreaRenderer.java index a501df5..f7a5b71 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckAreaRenderer.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckAreaRenderer.java @@ -66,4 +66,30 @@ public final String generateURL(final CategoryDataset dataset, final int row, fi private NumberOnlyBuildLabel getLabel(final CategoryDataset dataset, final int column) { return (NumberOnlyBuildLabel) dataset.getColumnKey(column); } + + /** + * Checks this instance for equality with an arbitrary object. + * + * @param obj the object (null not permitted). + * + * @return A boolean. + */ + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CppcheckAreaRenderer)) { + return false; + } + CppcheckAreaRenderer that = (CppcheckAreaRenderer) obj; + + if (this.url != that.url) { + return false; + } + return super.equals(obj); + } + + public int hashCode() { + return this.url.hashCode(); + } } diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckBuildAction.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckBuildAction.java index b934bf4..71cf1fa 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckBuildAction.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckBuildAction.java @@ -30,7 +30,7 @@ import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckSourceContainer; import com.thalesgroup.hudson.plugins.cppcheck.util.AbstractCppcheckBuildAction; import com.thalesgroup.hudson.plugins.cppcheck.util.CppcheckBuildHealthEvaluator; -import hudson.model.AbstractBuild; +import hudson.model.Run; import hudson.model.HealthReport; import hudson.util.ChartUtil; import hudson.util.ChartUtil.NumberOnlyBuildLabel; @@ -52,7 +52,7 @@ public class CppcheckBuildAction extends AbstractCppcheckBuildAction { private CppcheckResult result; private CppcheckConfig cppcheckConfig; - public CppcheckBuildAction(AbstractBuild owner, CppcheckResult result, CppcheckConfig cppcheckConfig) { + public CppcheckBuildAction(Run owner, CppcheckResult result, CppcheckConfig cppcheckConfig) { super(owner); this.result = result; this.cppcheckConfig = cppcheckConfig; @@ -78,7 +78,7 @@ public CppcheckResult getResult() { return this.result; } - AbstractBuild getBuild() { + Run getBuild() { return this.owner; } @@ -139,7 +139,7 @@ public void doGraph(StaplerRequest req, StaplerResponse rsp) throws IOException // Backward compatibility. Do not remove. // CPPCHECK:OFF @Deprecated - private transient AbstractBuild build; + private transient Run build; /** * Initializes members that were not present in previous versions of this plug-in. @@ -203,6 +203,6 @@ private Object readResolve() { return new org.jenkinsci.plugins.cppcheck.CppcheckBuildAction(owner, - newResult, 100); + newResult, newConfig, 100); } } diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckParserResult.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckParserResult.java index 68805fd..5713a55 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckParserResult.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckParserResult.java @@ -29,10 +29,12 @@ import hudson.Util; import hudson.model.BuildListener; import hudson.remoting.VirtualChannel; +import jenkins.security.Roles; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.selectors.FileSelector; +import org.jenkinsci.remoting.RoleChecker; import java.io.File; import java.io.IOException; @@ -124,5 +126,9 @@ public boolean isSelected(File basedir, String filename, File file) throws Build public String getCppcheckReportPattern() { return cppcheckReportPattern; } - + + @Override + public void checkRoles(RoleChecker checker) throws SecurityException { + checker.check(this, Roles.SLAVE); + } } diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckProjectAction.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckProjectAction.java index 26fb028..2f36e4f 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckProjectAction.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckProjectAction.java @@ -24,6 +24,8 @@ package com.thalesgroup.hudson.plugins.cppcheck; import com.thalesgroup.hudson.plugins.cppcheck.util.AbstractCppcheckProjectAction; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.model.AbstractBuild; import hudson.model.AbstractProject; import hudson.model.Result; @@ -48,6 +50,7 @@ public CppcheckProjectAction(final AbstractProject project) { } @SuppressWarnings("unused") + @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") public final boolean isDisplayGraph() { //Latest AbstractBuild b = getLastFinishedBuild(); diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckResult.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckResult.java index 3c79552..8dfe98a 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckResult.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckResult.java @@ -57,7 +57,7 @@ public class CppcheckResult implements Serializable { /** * The build owner */ - private AbstractBuild owner; + private transient AbstractBuild owner; public CppcheckResult(CppcheckReport report, CppcheckSourceContainer cppcheckSourceContainer, AbstractBuild owner) { this.report = report; diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java index 5c56fb7..a1b667d 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java @@ -29,13 +29,14 @@ import de.java2html.javasource.JavaSource; import de.java2html.javasource.JavaSourceParser; import de.java2html.options.JavaSourceConversionOptions; -import hudson.model.AbstractBuild; +import hudson.model.Run; import org.apache.commons.io.IOUtils; import org.apache.commons.io.LineIterator; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import java.io.*; +import java.nio.charset.StandardCharsets; public class CppcheckSource implements Serializable { @@ -55,7 +56,7 @@ public class CppcheckSource implements Serializable { /** * The current build as owner of this object. */ - private final AbstractBuild owner; + private transient final Run owner; /** * The cppcheck source file in the workspace to be shown. @@ -73,7 +74,7 @@ public class CppcheckSource implements Serializable { * @param owner the current build as owner of this object * @param cppcheckWorkspaceFile the abstract workspace file */ - public CppcheckSource(final AbstractBuild owner, CppcheckWorkspaceFile cppcheckWorkspaceFile) { + public CppcheckSource(final Run owner, CppcheckWorkspaceFile cppcheckWorkspaceFile) { this.owner = owner; this.cppcheckWorkspaceFile = cppcheckWorkspaceFile; buildFileContent(); @@ -106,7 +107,7 @@ private void buildFileContent() { splitSourceFile(highlightSource(is)); } catch (IOException exception) { - sourceCode = "Can't read file: " + exception.getLocalizedMessage(); + sourceCode = "Can't read file : " + exception.getLocalizedMessage(); } catch (RuntimeException re) { sourceCode = "Problem for display the source code content: " + re.getLocalizedMessage(); } finally { @@ -226,7 +227,7 @@ private void copyLine(final StringBuilder output, final LineIterator lineIterato */ public final String highlightSource(final InputStream file) throws IOException { - JavaSource source = new JavaSourceParser().parse(new InputStreamReader(file)); + JavaSource source = new JavaSourceParser().parse(new InputStreamReader(file, StandardCharsets.UTF_8)); JavaSource2HTMLConverter converter = new JavaSource2HTMLConverter(); StringWriter writer = new StringWriter(); JavaSourceConversionOptions options = JavaSourceConversionOptions.getDefault(); @@ -260,7 +261,7 @@ public CppcheckWorkspaceFile getCppcheckWorkspaceFile() { * * @return the build */ - public AbstractBuild getOwner() { + public Run getOwner() { return owner; } } diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/graph/CppcheckGraph.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/graph/CppcheckGraph.java index e57809a..6019faf 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/graph/CppcheckGraph.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/graph/CppcheckGraph.java @@ -22,7 +22,7 @@ *******************************************************************************/ package com.thalesgroup.hudson.plugins.cppcheck.graph; -import hudson.model.AbstractBuild; +import hudson.model.Run; import hudson.util.ColorPalette; import hudson.util.Graph; import hudson.util.ShiftedCategoryAxis; @@ -67,7 +67,7 @@ public class CppcheckGraph extends Graph { private static final List colors = Collections.unmodifiableList( Arrays.asList(RED, BLUE, GREEN, YELLOW, BROWN, GRAY, VIOLET, PINK)); - public CppcheckGraph(AbstractBuild owner, CategoryDataset categoryDataset, + public CppcheckGraph(Run owner, CategoryDataset categoryDataset, String yLabel, int chartWidth, int chartHeight) { super(owner.getTimestamp(), chartWidth, chartHeight); this.yLabel = yLabel; diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/model/CppcheckWorkspaceFile.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/model/CppcheckWorkspaceFile.java index 1b5802d..ce1297d 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/model/CppcheckWorkspaceFile.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/model/CppcheckWorkspaceFile.java @@ -23,11 +23,13 @@ package com.thalesgroup.hudson.plugins.cppcheck.model; -import hudson.model.AbstractBuild; +import hudson.model.Run; import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.cppcheck.CppcheckDiffState; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.io.File; import java.io.Serializable; @@ -57,6 +59,7 @@ public class CppcheckWorkspaceFile implements Serializable { */ private transient CppcheckDiffState diffState = null; + @SuppressFBWarnings("NP_NULL_ON_SOME_PATH") public CppcheckWorkspaceFile(File file) { if (file != null) this.fileName = file.getAbsolutePath().replace('\\', '/'); @@ -103,10 +106,10 @@ public final String getFileName() { return fileName; } - public String getTempName(final AbstractBuild owner) { + public String getTempName(final Run owner) { if (fileName != null) { - return owner.getRootDir().getAbsolutePath() + "/" - + DIR_WORKSPACE_FILES + "/" + return owner.getRootDir() + "/" + + DIR_WORKSPACE_FILES + "/" + Integer.toHexString(fileName.hashCode()) + ".tmp"; } return StringUtils.EMPTY; diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/AbstractCppcheckBuildAction.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/AbstractCppcheckBuildAction.java index 0e9f326..a77891b 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/AbstractCppcheckBuildAction.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/AbstractCppcheckBuildAction.java @@ -26,14 +26,14 @@ import org.kohsuke.stapler.StaplerProxy; public abstract class AbstractCppcheckBuildAction extends Actionable implements Action, HealthReportingAction, StaplerProxy { - protected AbstractBuild owner; + protected Run owner; - protected AbstractCppcheckBuildAction(AbstractBuild owner) { + protected AbstractCppcheckBuildAction(Run owner) { this.owner = owner; } public T getPreviousResult() { - AbstractBuild b = owner; + Run b = owner; while (true) { b = b.getPreviousBuild(); if (b == null) @@ -46,7 +46,7 @@ public T getPreviousResult() { } } - public AbstractBuild getOwner() { + public Run getOwner() { return owner; } } diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java index 5c6131a..1e71204 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java @@ -31,9 +31,9 @@ public class CppcheckUtil { /** * Gets the number of errors * - * @param cppecheckConfig configuration of CppCheck run - * @param result results of the CPPCheck runs - * @param checkNewError check is the number of errors is increasing + * @param cppecheckConfig + * @param result + * @param checkNewError * @return number of errors */ public static int getNumberErrors(CppcheckConfig cppecheckConfig, CppcheckResult result, boolean checkNewError) { diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckBuildAction.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckBuildAction.java index bb3f802..f8b00d8 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckBuildAction.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckBuildAction.java @@ -2,10 +2,15 @@ import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import com.thalesgroup.hudson.plugins.cppcheck.util.AbstractCppcheckBuildAction; -import hudson.model.AbstractBuild; +import hudson.model.Run; +import jenkins.tasks.SimpleBuildStep; +import hudson.model.Action; import hudson.model.HealthReport; import org.jenkinsci.plugins.cppcheck.config.CppcheckConfig; @@ -15,12 +20,13 @@ /** * @author Gregory Boissinot */ -public class CppcheckBuildAction extends AbstractCppcheckBuildAction { +public class CppcheckBuildAction extends AbstractCppcheckBuildAction implements SimpleBuildStep.LastBuildAction { public static final String URL_NAME = "cppcheckResult"; private CppcheckResult result; + private List projectActions; /** * The health report percentage. * @@ -28,11 +34,15 @@ public class CppcheckBuildAction extends AbstractCppcheckBuildAction { */ private int healthReportPercentage; - public CppcheckBuildAction(AbstractBuild owner, CppcheckResult result, + public CppcheckBuildAction(Run owner, CppcheckResult result, CppcheckConfig config, int healthReportPercentage) { super(owner); this.result = result; this.healthReportPercentage = healthReportPercentage; + + List projectActions = new ArrayList(); + projectActions.add(new CppcheckProjectAction(owner, config.getConfigGraph())); + this.projectActions = projectActions; } public String getIconFileName() { @@ -55,7 +65,7 @@ public CppcheckResult getResult() { return this.result; } - AbstractBuild getBuild() { + Run getBuild() { return this.owner; } @@ -85,7 +95,7 @@ public static int computeHealthReportPercentage(CppcheckResult result, // Backward compatibility @Deprecated - private transient AbstractBuild build; + private transient Run build; /** Backward compatibility with version 1.14 and less. */ @Deprecated @@ -108,4 +118,9 @@ private Object readResolve() { return this; } + + @Override + public Collection getProjectActions() { + return this.projectActions; + } } diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckParserResult.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckParserResult.java index b16c8b6..7573817 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckParserResult.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckParserResult.java @@ -3,14 +3,16 @@ import hudson.FilePath; import hudson.Util; -import hudson.model.BuildListener; +import hudson.model.TaskListener; import hudson.remoting.VirtualChannel; +import jenkins.security.Roles; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.selectors.FileSelector; import org.jenkinsci.plugins.cppcheck.parser.CppcheckParser; import org.jenkinsci.plugins.cppcheck.util.CppcheckLogger; +import org.jenkinsci.remoting.RoleChecker; import java.io.File; import java.io.IOException; @@ -22,7 +24,7 @@ public class CppcheckParserResult implements FilePath.FileCallable project, + public CppcheckProjectAction(final Run run, CppcheckConfigGraph configGraph) { - super(project); + super(run); this.configGraph = configGraph; } - public AbstractBuild getLastFinishedBuild() { - AbstractBuild lastBuild = project.getLastBuild(); + public Run getLastFinishedBuild() { + Run lastBuild = run.getPreviousBuild(); while (lastBuild != null && (lastBuild.isBuilding() || lastBuild.getAction(CppcheckBuildAction.class) == null)) { lastBuild = lastBuild.getPreviousBuild(); @@ -49,13 +48,13 @@ public CppcheckProjectAction(final AbstractProject project, * @return the build action or null */ public CppcheckBuildAction getLastFinishedBuildAction() { - AbstractBuild lastBuild = getLastFinishedBuild(); + Run lastBuild = getLastFinishedBuild(); return (lastBuild != null) ? lastBuild.getAction(CppcheckBuildAction.class) : null; } - public final boolean isDisplayGraph() { + public final boolean isDisplayGraph() { //Latest - AbstractBuild b = getLastFinishedBuild(); + Run b = getLastFinishedBuild(); if (b == null) { return false; } @@ -83,7 +82,7 @@ public final boolean isDisplayGraph() { } public Integer getLastResultBuild() { - for (AbstractBuild b = project.getLastBuild(); b != null; b = b.getPreviousBuiltBuild()) { + for (Run b = run.getPreviousBuild(); b != null; b = b.getPreviousBuiltBuild()) { CppcheckBuildAction r = b.getAction(CppcheckBuildAction.class); if (r != null) return b.getNumber(); @@ -106,7 +105,7 @@ public void doGraph(StaplerRequest req, StaplerResponse rsp) throws IOException return; } - AbstractBuild lastBuild = getLastFinishedBuild(); + Run lastBuild = getLastFinishedBuild(); Calendar timestamp = lastBuild.getTimestamp(); if (req.checkIfModified(timestamp, rsp)) { @@ -124,7 +123,7 @@ private DataSetBuilder getDataSetBuilder DataSetBuilder dsb = new DataSetBuilder(); - AbstractBuild lastBuild = getLastFinishedBuild(); + Run lastBuild = getLastFinishedBuild(); CppcheckBuildAction lastAction = lastBuild.getAction(CppcheckBuildAction.class); int numBuilds = 0; diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java index 895b95c..2af04d0 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java @@ -14,13 +14,19 @@ import hudson.tasks.Publisher; import hudson.tasks.Recorder; +import jenkins.tasks.SimpleBuildStep; + +import org.jenkinsci.plugins.cppcheck.CppcheckResult; +import org.jenkinsci.plugins.cppcheck.CppcheckBuildAction; import org.jenkinsci.plugins.cppcheck.config.CppcheckConfig; import org.jenkinsci.plugins.cppcheck.config.CppcheckConfigGraph; import org.jenkinsci.plugins.cppcheck.config.CppcheckConfigSeverityEvaluation; import org.jenkinsci.plugins.cppcheck.util.CppcheckBuildResultEvaluator; import org.jenkinsci.plugins.cppcheck.util.CppcheckLogger; import org.kohsuke.stapler.DataBoundConstructor; +import org.jenkinsci.Symbol; +import javax.annotation.Nonnull; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -29,7 +35,7 @@ /** * @author Gregory Boissinot */ -public class CppcheckPublisher extends Recorder { +public class CppcheckPublisher extends Recorder implements SimpleBuildStep { /** * XML file with source container data. Lazy loading instead of data in build.xml. * @@ -37,7 +43,9 @@ public class CppcheckPublisher extends Recorder { */ public static final String XML_FILE_DETAILS = "cppcheck_details.xml"; - private CppcheckConfig cppcheckConfig; + private CppcheckConfig cppcheckConfig; + private CppcheckConfigSeverityEvaluation configSeverityEvaluation; + private CppcheckConfigGraph configGraph; @DataBoundConstructor public CppcheckPublisher(String pattern, @@ -68,7 +76,7 @@ public CppcheckPublisher(String pattern, cppcheckConfig.setPattern(pattern); cppcheckConfig.setAllowNoReport(allowNoReport); cppcheckConfig.setIgnoreBlankFiles(ignoreBlankFiles); - CppcheckConfigSeverityEvaluation configSeverityEvaluation = new CppcheckConfigSeverityEvaluation( + configSeverityEvaluation = new CppcheckConfigSeverityEvaluation( threshold, newThreshold, failureThreshold, newFailureThreshold, healthy, unHealthy, severityError, severityWarning, @@ -78,7 +86,7 @@ public CppcheckPublisher(String pattern, severityNoCategory, severityPortability); cppcheckConfig.setConfigSeverityEvaluation(configSeverityEvaluation); - CppcheckConfigGraph configGraph = new CppcheckConfigGraph( + configGraph = new CppcheckConfigGraph( xSize, ySize, numBuildsInGraph, displayAllErrors, displayErrorSeverity, @@ -100,11 +108,6 @@ public CppcheckConfig getCppcheckConfig() { return cppcheckConfig; } - @Override - public Action getProjectAction(AbstractProject project) { - return new CppcheckProjectAction(project, cppcheckConfig.getConfigGraph()); - } - protected boolean canContinue(final Result result) { return result != Result.ABORTED && result != Result.FAILURE; } @@ -113,6 +116,77 @@ public BuildStepMonitor getRequiredMonitorService() { return BuildStepMonitor.BUILD; } + @Override + public void perform(@Nonnull Run build, @Nonnull FilePath workspace, @Nonnull Launcher launcher, + @Nonnull TaskListener listener) throws InterruptedException, IOException { + + System.out.println("perform..."); + + if (this.canContinue(build.getResult())) { + CppcheckLogger.log(listener, "ccc Starting the cppcheck analysis."); + + EnvVars env = build.getEnvironment(listener); + String expandedPattern = env.expand(cppcheckConfig.getPattern()); + + + CppcheckParserResult parser = new CppcheckParserResult(listener, + expandedPattern, cppcheckConfig.isIgnoreBlankFiles()); + CppcheckReport cppcheckReport; + try { + cppcheckReport = workspace.act(parser); + + } catch (Exception e) { + CppcheckLogger.log(listener, "Error on cppcheck analysis: " + e); + build.setResult(Result.FAILURE); + return; + } + + if (cppcheckReport == null) { + // Check if we're configured to allow not having a report + if (cppcheckConfig.getAllowNoReport()) { + return; + } else { + build.setResult(Result.FAILURE); + return; + } + } + + CppcheckSourceContainer cppcheckSourceContainer + = new CppcheckSourceContainer(listener, workspace, + workspace, cppcheckReport.getAllErrors()); + + CppcheckResult result = new CppcheckResult(cppcheckReport.getStatistics(), build); + CppcheckConfigSeverityEvaluation severityEvaluation + = cppcheckConfig.getConfigSeverityEvaluation(); + + Result buildResult = new CppcheckBuildResultEvaluator().evaluateBuildResult( + listener, result.getNumberErrorsAccordingConfiguration(severityEvaluation, false), + result.getNumberErrorsAccordingConfiguration(severityEvaluation, true), + severityEvaluation); + + if (buildResult != Result.SUCCESS) { + build.setResult(buildResult); + } + + CppcheckLogger.log(listener, "Starting buildaction."); + + CppcheckBuildAction buildAction = new CppcheckBuildAction(build, result, cppcheckConfig, + CppcheckBuildAction.computeHealthReportPercentage(result, severityEvaluation)); + + build.addAction(buildAction); + + XmlFile xmlSourceContainer = new XmlFile(new File(build.getRootDir(), + XML_FILE_DETAILS)); + xmlSourceContainer.write(cppcheckSourceContainer); + + copyFilesToBuildDirectory(build.getRootDir(), launcher.getChannel(), + cppcheckSourceContainer.getInternalMap().values()); + + CppcheckLogger.log(listener, "Ending the cppcheck analysis."); + } + return; + } + @Override public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { @@ -126,9 +200,14 @@ public boolean perform(AbstractBuild build, Launcher launcher, CppcheckParserResult parser = new CppcheckParserResult(listener, expandedPattern, cppcheckConfig.isIgnoreBlankFiles()); - CppcheckReport cppcheckReport; + CppcheckReport cppcheckReport = null; try { - cppcheckReport = build.getWorkspace().act(parser); + FilePath oWorkspacePath = build.getWorkspace(); + + if( oWorkspacePath != null) { + cppcheckReport = oWorkspacePath.act(parser); + } + } catch (Exception e) { CppcheckLogger.log(listener, "Error on cppcheck analysis: " + e); build.setResult(Result.FAILURE); @@ -162,7 +241,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, build.setResult(buildResult); } - CppcheckBuildAction buildAction = new CppcheckBuildAction(build, result, + CppcheckBuildAction buildAction = new CppcheckBuildAction(build, result, cppcheckConfig, CppcheckBuildAction.computeHealthReportPercentage(result, severityEvaluation)); build.addAction(buildAction); @@ -179,7 +258,6 @@ public boolean perform(AbstractBuild build, Launcher launcher, return true; } - /** * Copies all the source files from the workspace to the build folder. * @@ -213,6 +291,7 @@ private void copyFilesToBuildDirectory(final File rootDir, } @Extension + @Symbol("CppcheckPublisher") public static final class CppcheckDescriptor extends BuildStepDescriptor { public CppcheckDescriptor() { @@ -242,4 +321,113 @@ public CppcheckConfig getConfig() { return new CppcheckConfig(); } } + + //getters of the data variables + public String getPattern(){ + return cppcheckConfig.getPattern(); + } + + public boolean isIgnoreBlankFiles(){ + return cppcheckConfig.isIgnoreBlankFiles(); + } + + public String getThreshold(){ + return configSeverityEvaluation.getThreshold(); + } + + public boolean isAllowNoReport(){ + return cppcheckConfig.getAllowNoReport(); + } + + public String getNewThreshold(){ + return configSeverityEvaluation.getNewThreshold(); + } + + public String getFailureThreshold(){ + return configSeverityEvaluation.getFailureThreshold(); + } + + public String getNewFailureThreshold(){ + return configSeverityEvaluation.getNewFailureThreshold(); + } + + public String getHealthy(){ + return configSeverityEvaluation.getHealthy(); + } + + public String getUnHealthy(){ + return configSeverityEvaluation.getUnHealthy(); + } + + public boolean isSeverityError(){ + return configSeverityEvaluation.isSeverityError(); + } + + public boolean isSeverityWarning(){ + return configSeverityEvaluation.isSeverityWarning(); + } + + public boolean isSeverityStyle(){ + return configSeverityEvaluation.isSeverityStyle(); + } + + public boolean isSeverityPerformance(){ + return configSeverityEvaluation.isSeverityPerformance(); + } + + public boolean isSeverityInformation(){ + return configSeverityEvaluation.isSeverityInformation(); + } + + public boolean isSeverityNoCategory(){ + return configSeverityEvaluation.isSeverityNoCategory(); + } + + public boolean isSeverityPortability(){ + return configSeverityEvaluation.isSeverityPortability(); + } + + public int getXSize(){ + return configGraph.getXSize(); + } + + public int getYSize(){ + return configGraph.getYSize(); + } + + public int getNumBuildsInGraph(){ + return configGraph.getNumBuildsInGraph(); + } + + public boolean isDisplayAllErrors(){ + return configGraph.isDisplayAllErrors(); + } + + public boolean isDisplayErrorSeverity(){ + return configGraph.isDisplayErrorSeverity(); + } + + public boolean isDisplayWarningSeverity(){ + return configGraph.isDisplayWarningSeverity(); + } + + public boolean isDisplayStyleSeverity(){ + return configGraph.isDisplayStyleSeverity(); + } + + public boolean isDisplayPerformanceSeverity(){ + return configGraph.isDisplayPerformanceSeverity(); + } + + public boolean isDisplayInformationSeverity(){ + return configGraph.isDisplayInformationSeverity(); + } + + public boolean isDisplayNoCategorySeverity(){ + return configGraph.isDisplayNoCategorySeverity(); + } + + public boolean isDisplayPortabilitySeverity(){ + return configGraph.isDisplayPortabilitySeverity(); + } } diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckReport.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckReport.java index dcb43b6..fe81a0e 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckReport.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckReport.java @@ -17,6 +17,7 @@ public class CppcheckReport implements Serializable { private String version; + private static final long serialVersionUID = 1; private transient List allErrors = new ArrayList(); private transient Set versions = new HashSet(); diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckResult.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckResult.java index b335b6f..4ecbe26 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckResult.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckResult.java @@ -5,7 +5,7 @@ import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckWorkspaceFile; import hudson.XmlFile; -import hudson.model.AbstractBuild; +import hudson.model.Run; import hudson.model.Api; import hudson.model.Item; @@ -46,7 +46,7 @@ public class CppcheckResult implements Serializable { /** * The build owner. */ - private AbstractBuild owner; + private transient Run owner; /** * The Cppcheck report statistics. @@ -65,7 +65,7 @@ public class CppcheckResult implements Serializable { * * @since 1.15 */ - public CppcheckResult(CppcheckStatistics statistics, AbstractBuild owner) { + public CppcheckResult(CppcheckStatistics statistics, Run owner) { this.statistics = statistics; this.owner = owner; } @@ -73,14 +73,14 @@ public CppcheckResult(CppcheckStatistics statistics, AbstractBuild owner) /** * Constructor. Only for backward compatibility with previous versions. * - * @param report CPPCheck report - * @param cppcheckSourceContainer The Cppcheck container with all source files. - * @param owner the build owner + * @param report + * @param cppcheckSourceContainer + * @param owner * * @deprecated Use a different constructor instead. */ public CppcheckResult(CppcheckReport report, - CppcheckSourceContainer cppcheckSourceContainer, AbstractBuild owner) { + CppcheckSourceContainer cppcheckSourceContainer, Run owner) { this.report = report; this.cppcheckSourceContainer = cppcheckSourceContainer; this.owner = owner; @@ -111,7 +111,7 @@ public CppcheckStatistics getStatistics() { return statistics; } - public AbstractBuild getOwner() { + public Run getOwner() { return owner; } @@ -131,7 +131,7 @@ public CppcheckSourceContainer getCppcheckSourceContainer() { public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) throws IOException { if (link.equals("source.all")) { - if (!owner.getProject().getACL().hasPermission(Item.WORKSPACE)) { + if (!owner.getParent().getACL().hasPermission(Item.WORKSPACE)) { response.sendRedirect2("nosourcepermission"); return null; } @@ -143,7 +143,7 @@ public Object getDynamic(final String link, final StaplerRequest request, return new CppcheckSourceAll(owner, files, before, after); } else if (link.startsWith("source.")) { - if (!owner.getProject().getACL().hasPermission(Item.WORKSPACE)) { + if (!owner.getParent().getACL().hasPermission(Item.WORKSPACE)) { response.sendRedirect2("nosourcepermission"); return null; } @@ -229,7 +229,10 @@ public CppcheckResult getPreviousResult() { * @return the previous Cppcheck Build Action */ private CppcheckBuildAction getPreviousAction() { - AbstractBuild previousBuild = owner.getPreviousBuild(); + if(owner == null) + return null; + + Run previousBuild = owner.getPreviousBuild(); if (previousBuild != null) { return previousBuild.getAction(CppcheckBuildAction.class); } @@ -510,10 +513,16 @@ private CppcheckSourceContainer lazyLoadSourceContainer() { return cppcheckSourceContainer; } - XmlFile xmlSourceContainer = new XmlFile(new File(owner.getRootDir(), - CppcheckPublisher.XML_FILE_DETAILS)); try { - return (CppcheckSourceContainer) xmlSourceContainer.read(); + if(owner != null) { + XmlFile xmlSourceContainer = null; + xmlSourceContainer = new XmlFile(new File(owner.getRootDir(), + CppcheckPublisher.XML_FILE_DETAILS)); + + return (CppcheckSourceContainer) xmlSourceContainer.read(); + } + else + throw new IOException("lazyLoad: Attemped without owner"); } catch (IOException e) { return new CppcheckSourceContainer(new HashMap()); diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceAll.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceAll.java index f005593..82667c2 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceAll.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceAll.java @@ -1,12 +1,12 @@ package org.jenkinsci.plugins.cppcheck; -import hudson.model.AbstractBuild; - import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Collection; import org.apache.commons.io.IOUtils; @@ -14,6 +14,8 @@ import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckWorkspaceFile; +import hudson.model.Run; + /** * Show all violations highlighted on a single page. * @@ -22,7 +24,7 @@ */ public class CppcheckSourceAll { /** The related build. */ - private final AbstractBuild owner; + private final Run owner; /** The files to show. */ private final Collection files; @@ -45,7 +47,7 @@ public class CppcheckSourceAll { * @param linesAfter * number of lines to show after the highlighted line */ - public CppcheckSourceAll(AbstractBuild owner, + public CppcheckSourceAll(Run owner, Collection files, int linesBefore, int linesAfter) { this.owner = owner; @@ -54,7 +56,7 @@ public CppcheckSourceAll(AbstractBuild owner, this.linesAfter = linesAfter; } - public AbstractBuild getOwner() { + public Run getOwner() { return owner; } @@ -87,7 +89,7 @@ public String getSourceCode(CppcheckWorkspaceFile file) { BufferedReader reader = null; try { - reader = new BufferedReader(new FileReader(tempFile)); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(tempFile), StandardCharsets.UTF_8));//new FileReader(tempFile)); return getRelatedLines(reader, file.getCppcheckFile() .getLineNumber()); } catch (FileNotFoundException e) { diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceContainer.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceContainer.java index faf111a..02a7fe7 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceContainer.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceContainer.java @@ -3,7 +3,7 @@ import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckFile; import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckWorkspaceFile; import hudson.FilePath; -import hudson.model.BuildListener; +import hudson.model.TaskListener; import org.jenkinsci.plugins.cppcheck.util.CppcheckLogger; import java.io.IOException; @@ -22,7 +22,7 @@ public CppcheckSourceContainer(Map internalMap) this.internalMap = internalMap; } - public CppcheckSourceContainer(BuildListener listener, + public CppcheckSourceContainer(TaskListener listener, FilePath workspace, FilePath scmRootDir, List files) throws IOException, InterruptedException { @@ -38,7 +38,7 @@ public CppcheckSourceContainer(BuildListener listener, } } - private CppcheckWorkspaceFile getCppcheckWorkspaceFile(BuildListener listener, + private CppcheckWorkspaceFile getCppcheckWorkspaceFile(TaskListener listener, FilePath workspace, FilePath scmRootDir, CppcheckFile cppcheckFile) throws IOException, InterruptedException { @@ -82,5 +82,4 @@ private FilePath getSourceFile(FilePath workspace, FilePath scmRootDir, String c public Map getInternalMap() { return internalMap; } - } diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigGraph.java b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigGraph.java index e6f8ff6..7d580be 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigGraph.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigGraph.java @@ -1,92 +1,94 @@ -package org.jenkinsci.plugins.cppcheck.config; - -import java.io.Serializable; - -/** - * @author Gregory Boissinot - */ -public class CppcheckConfigGraph implements Serializable { - /** Serial version UID. */ - private static final long serialVersionUID = 1L; - - public static final int DEFAULT_CHART_WIDTH = 500; - public static final int DEFAULT_CHART_HEIGHT = 200; - - private int xSize = DEFAULT_CHART_WIDTH; - private int ySize = DEFAULT_CHART_HEIGHT; - private int numBuildsInGraph = 0; // numBuildsInGraph <= 1 means unlimited - private boolean displayAllErrors = true; - private boolean displayErrorSeverity; - private boolean displayWarningSeverity; - private boolean displayStyleSeverity; - private boolean displayPerformanceSeverity; - private boolean displayInformationSeverity; - private boolean displayNoCategorySeverity; - private boolean displayPortabilitySeverity; - - public CppcheckConfigGraph() { - } - - public CppcheckConfigGraph(int xSize, int ySize, int numBuildsInGraph, - boolean displayAllErrors, - boolean displayErrorSeverity, boolean displayWarningSeverity, - boolean displayStyleSeverity, boolean displayPerformanceSeverity, - boolean displayInformationSeverity, boolean displayNoCategorySeverity, - boolean displayPortabilitySeverity) { - this.xSize = xSize; - this.ySize = ySize; - this.numBuildsInGraph = numBuildsInGraph; - this.displayAllErrors = displayAllErrors; - this.displayErrorSeverity = displayErrorSeverity; - this.displayWarningSeverity = displayWarningSeverity; - this.displayStyleSeverity = displayStyleSeverity; - this.displayPerformanceSeverity = displayPerformanceSeverity; - this.displayInformationSeverity = displayInformationSeverity; - this.displayNoCategorySeverity = displayNoCategorySeverity; - this.displayPortabilitySeverity = displayPortabilitySeverity; - } - - public int getXSize() { - return xSize; - } - - public int getYSize() { - return ySize; - } - - public int getNumBuildsInGraph() { - return numBuildsInGraph; - } - - public boolean isDisplayAllErrors() { - return displayAllErrors; - } - - public boolean isDisplayErrorSeverity() { - return displayErrorSeverity; - } - - public boolean isDisplayWarningSeverity() { - return displayWarningSeverity; - } - - public boolean isDisplayStyleSeverity() { - return displayStyleSeverity; - } - - public boolean isDisplayPerformanceSeverity() { - return displayPerformanceSeverity; - } - - public boolean isDisplayInformationSeverity() { - return displayInformationSeverity; - } - - public boolean isDisplayNoCategorySeverity() { - return displayNoCategorySeverity; - } - - public boolean isDisplayPortabilitySeverity() { - return displayPortabilitySeverity; - } -} +package org.jenkinsci.plugins.cppcheck.config; + +import java.io.Serializable; + +/** + * @author Gregory Boissinot + */ +public class CppcheckConfigGraph implements Serializable { + /** Serial version UID. */ + private static final long serialVersionUID = 1L; + + public static final int DEFAULT_CHART_WIDTH = 500; + public static final int DEFAULT_CHART_HEIGHT = 200; + + private int xSize = DEFAULT_CHART_WIDTH; + private int ySize = DEFAULT_CHART_HEIGHT; + private int numBuildsInGraph = 0; // numBuildsInGraph <= 1 means unlimited + private boolean displayAllErrors = true; + private boolean displayErrorSeverity; + private boolean displayWarningSeverity; + private boolean displayStyleSeverity; + private boolean displayPerformanceSeverity; + private boolean displayInformationSeverity; + private boolean displayNoCategorySeverity; + private boolean displayPortabilitySeverity; + + public CppcheckConfigGraph() { + } + + public CppcheckConfigGraph(int xSize, int ySize, int numBuildsInGraph, + boolean displayAllErrors, + boolean displayErrorSeverity, boolean displayWarningSeverity, + boolean displayStyleSeverity, boolean displayPerformanceSeverity, + boolean displayInformationSeverity, boolean displayNoCategorySeverity, + boolean displayPortabilitySeverity) { + if ( xSize > 0 && ySize > 0) { + this.xSize = xSize; + this.ySize = ySize; + } + this.numBuildsInGraph = numBuildsInGraph; + this.displayAllErrors = displayAllErrors; + this.displayErrorSeverity = displayErrorSeverity; + this.displayWarningSeverity = displayWarningSeverity; + this.displayStyleSeverity = displayStyleSeverity; + this.displayPerformanceSeverity = displayPerformanceSeverity; + this.displayInformationSeverity = displayInformationSeverity; + this.displayNoCategorySeverity = displayNoCategorySeverity; + this.displayPortabilitySeverity = displayPortabilitySeverity; + } + + public int getXSize() { + return xSize; + } + + public int getYSize() { + return ySize; + } + + public int getNumBuildsInGraph() { + return numBuildsInGraph; + } + + public boolean isDisplayAllErrors() { + return displayAllErrors; + } + + public boolean isDisplayErrorSeverity() { + return displayErrorSeverity; + } + + public boolean isDisplayWarningSeverity() { + return displayWarningSeverity; + } + + public boolean isDisplayStyleSeverity() { + return displayStyleSeverity; + } + + public boolean isDisplayPerformanceSeverity() { + return displayPerformanceSeverity; + } + + public boolean isDisplayInformationSeverity() { + return displayInformationSeverity; + } + + public boolean isDisplayNoCategorySeverity() { + return displayNoCategorySeverity; + } + + public boolean isDisplayPortabilitySeverity() { + return displayPortabilitySeverity; + } +} \ No newline at end of file diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/parser/CppcheckParser.java b/src/main/java/org/jenkinsci/plugins/cppcheck/parser/CppcheckParser.java index 4f9025c..12b9830 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/parser/CppcheckParser.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/parser/CppcheckParser.java @@ -1,7 +1,7 @@ package org.jenkinsci.plugins.cppcheck.parser; import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckFile; -import hudson.model.BuildListener; +import hudson.model.TaskListener; import org.jenkinsci.plugins.cppcheck.CppcheckReport; import org.jenkinsci.plugins.cppcheck.model.Errors; import org.jenkinsci.plugins.cppcheck.model.Results; @@ -24,7 +24,7 @@ public class CppcheckParser implements Serializable { private static final long serialVersionUID = 1L; - public CppcheckReport parse(final File file, BuildListener listener) throws IOException { + public CppcheckReport parse(final File file, TaskListener listener) throws IOException { if (file == null) { throw new IllegalArgumentException("File input is mandatory."); @@ -150,8 +150,8 @@ private CppcheckReport getReportVersion2(Results results) { cppcheckFile.setCppCheckId(error.getId()); cppcheckFile.setSeverity(error.getSeverity()); cppcheckFile.setMessage(error.getMsg()); - cppcheckFile.setInconclusive((error.isInconclusive() != null) - ? error.isInconclusive() : false); + 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 diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/util/AbstractCppcheckProjectAction.java b/src/main/java/org/jenkinsci/plugins/cppcheck/util/AbstractCppcheckProjectAction.java index 5b196d7..1157b41 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/util/AbstractCppcheckProjectAction.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/util/AbstractCppcheckProjectAction.java @@ -1,8 +1,7 @@ package org.jenkinsci.plugins.cppcheck.util; -import hudson.model.AbstractBuild; -import hudson.model.AbstractProject; import hudson.model.Actionable; +import hudson.model.Run; import hudson.model.Action; import org.kohsuke.stapler.StaplerRequest; @@ -15,14 +14,14 @@ */ public abstract class AbstractCppcheckProjectAction extends Actionable implements Action { - protected final AbstractProject project; + protected final Run run; - public AbstractCppcheckProjectAction(AbstractProject project) { - this.project = project; + public AbstractCppcheckProjectAction(Run run) { + this.run = run; } - public AbstractProject getProject() { - return project; + public Run getRun() { + return run; } public String getIconFileName() { @@ -33,7 +32,7 @@ public String getSearchUrl() { return getUrlName(); } - protected abstract AbstractBuild getLastFinishedBuild(); + protected abstract Run getLastFinishedBuild(); protected abstract Integer getLastResultBuild(); diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/util/CppcheckBuildResultEvaluator.java b/src/main/java/org/jenkinsci/plugins/cppcheck/util/CppcheckBuildResultEvaluator.java index 5e9e88f..b7b747c 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/util/CppcheckBuildResultEvaluator.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/util/CppcheckBuildResultEvaluator.java @@ -1,7 +1,7 @@ package org.jenkinsci.plugins.cppcheck.util; -import hudson.model.BuildListener; +import hudson.model.TaskListener; import hudson.model.Result; import org.jenkinsci.plugins.cppcheck.config.CppcheckConfigSeverityEvaluation; @@ -11,7 +11,7 @@ */ public class CppcheckBuildResultEvaluator { public Result evaluateBuildResult( - final BuildListener listener, + final TaskListener listener, int errorsCount, int newErrorsCount, CppcheckConfigSeverityEvaluation severityEvaluation) { diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/util/CppcheckLogger.java b/src/main/java/org/jenkinsci/plugins/cppcheck/util/CppcheckLogger.java index 25ee4be..3d1c08d 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/util/CppcheckLogger.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/util/CppcheckLogger.java @@ -1,6 +1,7 @@ package org.jenkinsci.plugins.cppcheck.util; import hudson.model.BuildListener; +import hudson.model.TaskListener; import java.io.Serializable; @@ -21,4 +22,7 @@ public static void log(BuildListener listener, final String message) { listener.getLogger().println("[Cppcheck] " + message); } + public static void log(TaskListener listener, final String message) { + listener.getLogger().println("[Cppcheck] " + message); + } } \ No newline at end of file From 2191e3e4b7d7dc4d211b3e64f5e170e274cb8458 Mon Sep 17 00:00:00 2001 From: "EUROPE\\wvandepol" Date: Thu, 24 Aug 2017 14:58:40 +0200 Subject: [PATCH 2/9] Remove unneeded local ref --- .../plugins/cppcheck/CppcheckPublisher.java | 73 +++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java index 2af04d0..ed7343f 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java @@ -43,9 +43,7 @@ public class CppcheckPublisher extends Recorder implements SimpleBuildStep { */ public static final String XML_FILE_DETAILS = "cppcheck_details.xml"; - private CppcheckConfig cppcheckConfig; - private CppcheckConfigSeverityEvaluation configSeverityEvaluation; - private CppcheckConfigGraph configGraph; + private CppcheckConfig cppcheckConfig; @DataBoundConstructor public CppcheckPublisher(String pattern, @@ -76,7 +74,9 @@ public CppcheckPublisher(String pattern, cppcheckConfig.setPattern(pattern); cppcheckConfig.setAllowNoReport(allowNoReport); cppcheckConfig.setIgnoreBlankFiles(ignoreBlankFiles); - configSeverityEvaluation = new CppcheckConfigSeverityEvaluation( + + cppcheckConfig.setConfigSeverityEvaluation( + new CppcheckConfigSeverityEvaluation( threshold, newThreshold, failureThreshold, newFailureThreshold, healthy, unHealthy, severityError, severityWarning, @@ -84,9 +84,9 @@ public CppcheckPublisher(String pattern, severityPerformance, severityInformation, severityNoCategory, - severityPortability); - cppcheckConfig.setConfigSeverityEvaluation(configSeverityEvaluation); - configGraph = new CppcheckConfigGraph( + severityPortability)); + + cppcheckConfig.setConfigGraph( new CppcheckConfigGraph( xSize, ySize, numBuildsInGraph, displayAllErrors, displayErrorSeverity, @@ -95,8 +95,7 @@ public CppcheckPublisher(String pattern, displayPerformanceSeverity, displayInformationSeverity, displayNoCategorySeverity, - displayPortabilitySeverity); - cppcheckConfig.setConfigGraph(configGraph); + displayPortabilitySeverity)); } @@ -331,103 +330,103 @@ public boolean isIgnoreBlankFiles(){ return cppcheckConfig.isIgnoreBlankFiles(); } - public String getThreshold(){ - return configSeverityEvaluation.getThreshold(); - } - public boolean isAllowNoReport(){ - return cppcheckConfig.getAllowNoReport(); + return cppcheckConfig.getAllowNoReport(); + } + + public String getThreshold(){ + return cppcheckConfig.getConfigSeverityEvaluation().getThreshold(); } public String getNewThreshold(){ - return configSeverityEvaluation.getNewThreshold(); + return cppcheckConfig.getConfigSeverityEvaluation().getNewThreshold(); } public String getFailureThreshold(){ - return configSeverityEvaluation.getFailureThreshold(); + return cppcheckConfig.getConfigSeverityEvaluation().getFailureThreshold(); } public String getNewFailureThreshold(){ - return configSeverityEvaluation.getNewFailureThreshold(); + return cppcheckConfig.getConfigSeverityEvaluation().getNewFailureThreshold(); } public String getHealthy(){ - return configSeverityEvaluation.getHealthy(); + return cppcheckConfig.getConfigSeverityEvaluation().getHealthy(); } public String getUnHealthy(){ - return configSeverityEvaluation.getUnHealthy(); + return cppcheckConfig.getConfigSeverityEvaluation().getUnHealthy(); } public boolean isSeverityError(){ - return configSeverityEvaluation.isSeverityError(); + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityError(); } public boolean isSeverityWarning(){ - return configSeverityEvaluation.isSeverityWarning(); + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityWarning(); } public boolean isSeverityStyle(){ - return configSeverityEvaluation.isSeverityStyle(); + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityStyle(); } public boolean isSeverityPerformance(){ - return configSeverityEvaluation.isSeverityPerformance(); + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPerformance(); } public boolean isSeverityInformation(){ - return configSeverityEvaluation.isSeverityInformation(); + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityInformation(); } public boolean isSeverityNoCategory(){ - return configSeverityEvaluation.isSeverityNoCategory(); + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityNoCategory(); } public boolean isSeverityPortability(){ - return configSeverityEvaluation.isSeverityPortability(); + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPortability(); } public int getXSize(){ - return configGraph.getXSize(); + return cppcheckConfig.getConfigGraph().getXSize(); } public int getYSize(){ - return configGraph.getYSize(); + return cppcheckConfig.getConfigGraph().getYSize(); } public int getNumBuildsInGraph(){ - return configGraph.getNumBuildsInGraph(); + return cppcheckConfig.getConfigGraph().getNumBuildsInGraph(); } public boolean isDisplayAllErrors(){ - return configGraph.isDisplayAllErrors(); + return cppcheckConfig.getConfigGraph().isDisplayAllErrors(); } public boolean isDisplayErrorSeverity(){ - return configGraph.isDisplayErrorSeverity(); + return cppcheckConfig.getConfigGraph().isDisplayErrorSeverity(); } public boolean isDisplayWarningSeverity(){ - return configGraph.isDisplayWarningSeverity(); + return cppcheckConfig.getConfigGraph().isDisplayWarningSeverity(); } public boolean isDisplayStyleSeverity(){ - return configGraph.isDisplayStyleSeverity(); + return cppcheckConfig.getConfigGraph().isDisplayStyleSeverity(); } public boolean isDisplayPerformanceSeverity(){ - return configGraph.isDisplayPerformanceSeverity(); + return cppcheckConfig.getConfigGraph().isDisplayPerformanceSeverity(); } public boolean isDisplayInformationSeverity(){ - return configGraph.isDisplayInformationSeverity(); + return cppcheckConfig.getConfigGraph().isDisplayInformationSeverity(); } public boolean isDisplayNoCategorySeverity(){ - return configGraph.isDisplayNoCategorySeverity(); + return cppcheckConfig.getConfigGraph().isDisplayNoCategorySeverity(); } public boolean isDisplayPortabilitySeverity(){ - return configGraph.isDisplayPortabilitySeverity(); + return cppcheckConfig.getConfigGraph().isDisplayPortabilitySeverity(); } } From 649bec8523b2eca588be4d21cb04c39c0fe300ab Mon Sep 17 00:00:00 2001 From: "EUROPE\\wvandepol" Date: Thu, 24 Aug 2017 14:59:18 +0200 Subject: [PATCH 3/9] Fix spacing --- pom.xml | 47 +++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index 708a256..3139cfe 100644 --- a/pom.xml +++ b/pom.xml @@ -111,12 +111,11 @@ - + org.eclipse.m2e lifecycle-mapping 1.0.0 - @@ -140,32 +139,28 @@ - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - InjectedTest.java - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - InjectedTest.java - - - - - + + + org.apache.maven.plugins + maven-surefire-plugin + + + InjectedTest.java + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + InjectedTest.java + + + + - org.codehaus.mojo jaxb2-maven-plugin From 8b56218a72e4a75348fd71a3276148a98bc3f98b Mon Sep 17 00:00:00 2001 From: Michael Doubez Date: Sun, 29 Apr 2018 01:10:06 +0200 Subject: [PATCH 4/9] Revert to most recent changes in master --- pom.xml | 48 +++++++------------ .../plugins/cppcheck/CppcheckSource.java | 2 +- .../plugins/cppcheck/util/CppcheckUtil.java | 6 +-- .../plugins/cppcheck/CppcheckResult.java | 6 +-- .../cppcheck/parser/CppcheckParser.java | 4 +- 5 files changed, 27 insertions(+), 39 deletions(-) diff --git a/pom.xml b/pom.xml index 0717172..70b1844 100644 --- a/pom.xml +++ b/pom.xml @@ -49,12 +49,12 @@ 1.6 2.2.1 2.2.1.1 - 1.3 + 2.3 5.0 4.8.2 1.8.5 2.0 - 2.30 + 2.30 @@ -163,15 +163,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - InjectedTest.java - - - @@ -185,11 +176,9 @@ generatedCppcheck1 com.thalesgroup.jenkinsci.plugins.cppcheck.model - ${basedir}/src/main/resources/com/thalesgroup/hudson/plugins/cppcheck - cppcheck-1.0.xsd - ${project.build.directory}/generated-sources/jaxb/cppcheck1/.staleFlag. - - false + + ${basedir}/src/main/resources/com/thalesgroup/hudson/plugins/cppcheck/cppcheck-1.0.xsd + xjc @@ -199,10 +188,9 @@ generatedCppcheck2 org.jenkinsci.plugins.cppcheck.model - ${basedir}/src/main/resources/org/jenkinsci/plugins/cppcheck - cppcheck-2.0.xsd - ${project.build.directory}/generated-sources/jaxb/cppcheck2/.staleFlag. - + + ${basedir}/src/main/resources/org/jenkinsci/plugins/cppcheck/cppcheck-2.0.xsd + false @@ -210,16 +198,16 @@ - - - org.apache.maven.plugins - maven-javadoc-plugin - - - - org.jenkinsci.plugins.cppcheck.model:com.thalesgroup.jenkinsci.plugins.cppcheck.model - - + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + org.jenkinsci.plugins.cppcheck.model:com.thalesgroup.jenkinsci.plugins.cppcheck.model + + diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java index c1f2b00..df243a9 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java @@ -224,7 +224,7 @@ private void copyLine(final StringBuilder output, final LineIterator lineIterato * * @param file the source file to highlight * @return the source as an HTML string - * @throws IOException + * @throws IOException if cannot read source or cannot write highlighted source */ public final String highlightSource(final InputStream file) throws IOException { diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java index 1e71204..b3f7c63 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java @@ -31,9 +31,9 @@ public class CppcheckUtil { /** * Gets the number of errors * - * @param cppecheckConfig - * @param result - * @param checkNewError + * @param cppecheckConfig configuration of CppCheck run + * @param result results of the CPPCheck runs + * @param checkNewError is the number of errors is increasing * @return number of errors */ public static int getNumberErrors(CppcheckConfig cppecheckConfig, CppcheckResult result, boolean checkNewError) { diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckResult.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckResult.java index 346b4ac..41b431f 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckResult.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckResult.java @@ -73,9 +73,9 @@ public CppcheckResult(CppcheckStatistics statistics, Run owner) { /** * Constructor. Only for backward compatibility with previous versions. * - * @param report - * @param cppcheckSourceContainer - * @param owner + * @param report CPPCheck report + * @param cppcheckSourceContainer The Cppcheck container with all source files. + * @param owner the build owner * * @deprecated Use a different constructor instead. */ diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/parser/CppcheckParser.java b/src/main/java/org/jenkinsci/plugins/cppcheck/parser/CppcheckParser.java index b0fe19d..850e463 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/parser/CppcheckParser.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/parser/CppcheckParser.java @@ -150,8 +150,8 @@ private CppcheckReport getReportVersion2(Results results) { cppcheckFile.setCppCheckId(error.getId()); cppcheckFile.setSeverity(error.getSeverity()); cppcheckFile.setMessage(error.getMsg()); - cppcheckFile.setInconclusive((error.getInconclusive() != null) - ? error.getInconclusive() : false); + cppcheckFile.setInconclusive((error.isInconclusive() != null) + ? error.isInconclusive() : false); // msg and verbose items have often the same text in XML report, // there is no need to store duplications From 729a1850eb29e4ed9b8713b5269ef944c6566746 Mon Sep 17 00:00:00 2001 From: Michael Doubez Date: Mon, 30 Apr 2018 00:23:48 +0200 Subject: [PATCH 5/9] Fixing configuration of freestyle job --- .../plugins/cppcheck/CppcheckPublisher.java | 375 +++++++----------- .../cppcheck/config/CppcheckConfig.java | 4 +- .../cppcheck/config/CppcheckConfigGraph.java | 59 ++- .../CppcheckConfigSeverityEvaluation.java | 51 ++- 4 files changed, 221 insertions(+), 268 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java index df66284..0340c68 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java @@ -65,37 +65,12 @@ public class CppcheckPublisher extends Recorder implements SimpleBuildStep { private CppcheckConfig cppcheckConfig; - private String pattern; - private boolean ignoreBlankFiles; - private String threshold; - private boolean allowNoReport; - private String newThreshold; - private String failureThreshold; - private String newFailureThreshold; - private String healthy; - private String unHealthy; - private boolean severityError; - private boolean severityWarning; - private boolean severityStyle; - private boolean severityPerformance; - private boolean severityInformation; - private boolean severityNoCategory; - private boolean severityPortability; - private int xSize; - private int ySize; - private int numBuildsInGraph; - private boolean displayAllErrors; - private boolean displayErrorSeverity; - private boolean displayWarningSeverity; - private boolean displayStyleSeverity; - private boolean displayPerformanceSeverity; - private boolean displayInformationSeverity; - private boolean displayNoCategorySeverity; - private boolean displayPortabilitySeverity; - - @DataBoundConstructor - public CppcheckPublisher() {this("", false, "", false, "", "", "", "", "", true, true, true, true, true, true, true, 500, 200, 0, true, false, false, false, false, false, false, false);} + public CppcheckPublisher() { + cppcheckConfig = new CppcheckConfig(); + cppcheckConfig.setConfigSeverityEvaluation(new CppcheckConfigSeverityEvaluation()); + cppcheckConfig.setConfigGraph( new CppcheckConfigGraph()); + } @Deprecated public CppcheckPublisher(String pattern, @@ -120,37 +95,7 @@ public CppcheckPublisher(String pattern, boolean displayInformationSeverity, boolean displayNoCategorySeverity, boolean displayPortabilitySeverity) { - - this.pattern = pattern; - this.ignoreBlankFiles = ignoreBlankFiles; - this.threshold = threshold; - this.allowNoReport = allowNoReport; - this.newThreshold = newThreshold; - this.failureThreshold = failureThreshold; - this.newFailureThreshold = newFailureThreshold; - this.healthy = healthy; - this.unHealthy = unHealthy; - this.severityError = severityError; - this.severityWarning = severityWarning; - this.severityStyle = severityStyle; - this.severityPerformance = severityPerformance; - this.severityInformation = severityInformation; - this.severityNoCategory = severityNoCategory; - this.severityPortability = severityPortability; - this.xSize = xSize; - this.ySize = ySize; - this.numBuildsInGraph = numBuildsInGraph; - this.displayAllErrors = displayAllErrors; - this.displayErrorSeverity = displayErrorSeverity; - this.displayWarningSeverity = displayWarningSeverity; - this.displayStyleSeverity = displayStyleSeverity; - this.displayPerformanceSeverity = displayPerformanceSeverity; - this.displayInformationSeverity = displayInformationSeverity; - this.displayNoCategorySeverity = displayNoCategorySeverity; - this.displayPortabilitySeverity = displayPortabilitySeverity; - - cppcheckConfig = new CppcheckConfig(); - + cppcheckConfig = new CppcheckConfig(); cppcheckConfig.setPattern(pattern); cppcheckConfig.setAllowNoReport(allowNoReport); cppcheckConfig.setIgnoreBlankFiles(ignoreBlankFiles); @@ -179,179 +124,192 @@ public CppcheckPublisher(String pattern, } @DataBoundSetter - public void setpattern(String pattern) { - this.pattern = pattern; + public void setPattern(String pattern) { + cppcheckConfig.setPattern(pattern); } - public String getpattern() { - return pattern; + public String getPattern() { + return cppcheckConfig.getPattern(); } @DataBoundSetter - public void setnewThreshold(String newThreshold) { - this.newThreshold = newThreshold; + public void setThreshold(String threshold) { + cppcheckConfig.getConfigSeverityEvaluation().setThreshold(threshold); } - public String getnewThreshold() { - return this.newThreshold; + public String geThreshold() { + return cppcheckConfig.getConfigSeverityEvaluation().getThreshold(); } @DataBoundSetter - public void setfailureThreshold(String failureThreshold) { - this.failureThreshold = failureThreshold; + public void setNewThreshold(String newThreshold) { + cppcheckConfig.getConfigSeverityEvaluation().setNewThreshold(newThreshold); } - public String getfailureThreshold() { - return this.failureThreshold; + public String getNewThreshold() { + return cppcheckConfig.getConfigSeverityEvaluation().getNewThreshold(); } @DataBoundSetter - public void setnewFailureThreshold(String newFailureThreshold) { - this.newFailureThreshold = newFailureThreshold; + public void setFailureThreshold(String failureThreshold) { + cppcheckConfig.getConfigSeverityEvaluation().setFailureThreshold(failureThreshold); } - public String getnewFailureThreshold() { - return this.newFailureThreshold; + public String getFailureThreshold() { + return cppcheckConfig.getConfigSeverityEvaluation().getFailureThreshold(); } @DataBoundSetter - public void sethealthy(String healthy) { - this.healthy = healthy; + public void setNewFailureThreshold(String newFailureThreshold) { + cppcheckConfig.getConfigSeverityEvaluation().setNewFailureThreshold(newFailureThreshold); } - public String gethealthy() { - return this.healthy; + public String getNewFailureThreshold() { + return cppcheckConfig.getConfigSeverityEvaluation().getNewFailureThreshold(); } @DataBoundSetter - public void setunHealthy(String unHealthy) { - this.unHealthy = unHealthy; + public void setHealthy(String healthy) { + cppcheckConfig.getConfigSeverityEvaluation().setHealthy(healthy); } - public String getunHealthy() { - return this.unHealthy; + public String getHealthy() { + return cppcheckConfig.getConfigSeverityEvaluation().getHealthy(); } @DataBoundSetter - public void setignoreBlankFiles(boolean ignoreBlankFiles) { - this.ignoreBlankFiles = ignoreBlankFiles; + public void setUnHealthy(String unHealthy) { + cppcheckConfig.getConfigSeverityEvaluation().setUnHealthy(unHealthy); } - public boolean getignoreBlankFiles() { - return this.ignoreBlankFiles; + public String getUnHealthy() { + return cppcheckConfig.getConfigSeverityEvaluation().getUnHealthy(); } @DataBoundSetter - public void setallowNoReport(boolean allowNoReport) { - this.allowNoReport = allowNoReport; + public void setIgnoreBlankFiles(boolean ignoreBlankFiles) { + cppcheckConfig.setIgnoreBlankFiles(ignoreBlankFiles); } - public boolean getallowNoReport() { - return this.allowNoReport; + public boolean getIgnoreBlankFiles() { + return cppcheckConfig.isIgnoreBlankFiles(); } @DataBoundSetter - public void setseverityError(boolean severityError) { - this.severityError = severityError; + public void setAllowNoReport(boolean allowNoReport) { + cppcheckConfig.setAllowNoReport(allowNoReport); } - public boolean getseverityError() { - return this.severityError; + public boolean getAllowNoReport() { + return cppcheckConfig.getAllowNoReport(); } @DataBoundSetter - public void setseverityWarning(boolean severityWarning) { - this.severityWarning = severityWarning; + public void setSeverityError(boolean severityError) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityError(severityError); } - public boolean getseverityWarning() { - return this.severityWarning; + public boolean getSeverityError() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityError(); } @DataBoundSetter - public void setseverityStyle(boolean severityStyle) { - this.severityStyle = severityStyle; + public void setSeverityWarning(boolean severityWarning) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityWarning(severityWarning); } - public boolean getseverityStyle() { - return this.severityStyle; + public boolean getSeverityWarning() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityWarning(); + } + @DataBoundSetter + public void setSeverityStyle(boolean severityStyle) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityStyle(severityStyle); + } + public boolean getSeverityStyle() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityStyle(); } @DataBoundSetter - public void setseverityPerformance(boolean severityPerformance) { - this.severityPerformance = severityPerformance; + public void setSeverityPerformance(boolean severityPerformance) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityPerformance(severityPerformance); } - public boolean getseverityPerformance() { - return this.severityPerformance; + public boolean getSeverityPerformance() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPerformance(); } @DataBoundSetter - public void setseverityInformation(boolean severityInformation) { - this.severityInformation = severityInformation; + public void setSeverityInformation(boolean severityInformation) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityInformation(severityInformation); } - public boolean getseverityInformation() { - return this.severityInformation; + public boolean getSeverityInformation() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityInformation(); } @DataBoundSetter - public void setseverityNoCategory(boolean severityNoCategory) { - this.severityNoCategory = severityNoCategory; + public void setSeverityNoCategory(boolean severityNoCategory) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityNoCategory(severityNoCategory); } - public boolean getseverityNoCategory() { - return this.severityNoCategory; + public boolean getSeverityNoCategory() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityNoCategory(); } @DataBoundSetter - public void setseverityPortability(boolean severityPortability) { - this.severityPortability = severityPortability; + public void setSeverityPortability(boolean severityPortability) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityPortability(severityPortability); } - public boolean getseverityPortability() { - return this.severityPortability; + public boolean getSeverityPortability() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPortability(); } @DataBoundSetter - public void setdisplayAllErrors(boolean displayAllErrors) { - this.displayAllErrors = displayAllErrors; + public void setDisplayAllErrors(boolean displayAllErrors) { + cppcheckConfig.getConfigGraph().setDisplayAllErrors(displayAllErrors); } - public boolean getdisplayAllErrors() { - return this.displayAllErrors; + public boolean getDisplayAllErrors() { + return cppcheckConfig.getConfigGraph().isDisplayAllErrors(); } @DataBoundSetter - public void setdisplayErrorSeverity(boolean displayErrorSeverity) { - this.displayErrorSeverity = displayErrorSeverity; + public void setDisplayErrorSeverity(boolean displayErrorSeverity) { + cppcheckConfig.getConfigGraph().setDisplayErrorSeverity(displayErrorSeverity); } - public boolean getdisplayErrorSeverity() { - return this.displayErrorSeverity; + public boolean getDisplayErrorSeverity() { + return cppcheckConfig.getConfigGraph().isDisplayErrorSeverity(); } @DataBoundSetter - public void setdisplayWarningSeverity(boolean displayWarningSeverity) { - this.displayWarningSeverity = displayWarningSeverity; + public void setDisplayWarningSeverity(boolean displayWarningSeverity) { + cppcheckConfig.getConfigGraph().setDisplayWarningSeverity(displayWarningSeverity); } - public boolean getdisplayWarningSeverity() { - return this.displayWarningSeverity; + public boolean getDisplayWarningSeverity() { + return cppcheckConfig.getConfigGraph().isDisplayWarningSeverity(); } @DataBoundSetter - public void setdisplayStyleSeverity(boolean displayStyleSeverity) { - this.displayStyleSeverity = displayStyleSeverity; + public void setDisplayStyleSeverity(boolean displayStyleSeverity) { + cppcheckConfig.getConfigGraph().setDisplayStyleSeverity(displayStyleSeverity); } - public boolean getdisplayStyleSeverity() { - return this.displayStyleSeverity; + public boolean getDisplayStyleSeverity() { + return cppcheckConfig.getConfigGraph().isDisplayStyleSeverity(); } @DataBoundSetter - public void setdisplayPerformanceSeverity(boolean displayPerformanceSeverity) { - this.displayPerformanceSeverity = displayPerformanceSeverity; + public void setDisplayPerformanceSeverity(boolean displayPerformanceSeverity) { + cppcheckConfig.getConfigGraph().setDisplayPerformanceSeverity(displayPerformanceSeverity); + } + public boolean getDisplayPerformanceSeverity() { + return cppcheckConfig.getConfigGraph().isDisplayPerformanceSeverity(); } - public boolean getdisplayPerformanceSeverity() { - return this.displayPerformanceSeverity; + public void setDisplayInformationSeverity(boolean displayInformationSeverity) { + cppcheckConfig.getConfigGraph().setDisplayInformationSeverity(displayInformationSeverity); + } + public boolean getDisplayInformationSeverity() { + return cppcheckConfig.getConfigGraph().isDisplayInformationSeverity(); } @DataBoundSetter - public void setdisplayNoCategorySeverity(boolean displayNoCategorySeverity) { - this.displayNoCategorySeverity = displayNoCategorySeverity; + public void setDisplayNoCategorySeverity(boolean displayNoCategorySeverity) { + cppcheckConfig.getConfigGraph().setDisplayNoCategorySeverity(displayNoCategorySeverity); } - public boolean getdisplayNoCategorySeverity() { - return this.displayNoCategorySeverity; + public boolean getDisplayNoCategorySeverity() { + return cppcheckConfig.getConfigGraph().isDisplayNoCategorySeverity(); } @DataBoundSetter - public void setdisplayPortabilitySeverity(boolean displayPortabilitySeverity) { - this.displayPortabilitySeverity = displayPortabilitySeverity; + public void setDisplayPortabilitySeverity(boolean displayPortabilitySeverity) { + cppcheckConfig.getConfigGraph().setDisplayPortabilitySeverity(displayPortabilitySeverity); } - public boolean getdisplayPortabilitySeverity() { - return this.displayPortabilitySeverity; + public boolean getDisplayPortabilitySeverity() { + return cppcheckConfig.getConfigGraph().isDisplayPortabilitySeverity(); } @DataBoundSetter - public void setxSize(int xSize) { - this.xSize = xSize; + public void setXSize(int xSize) { + cppcheckConfig.getConfigGraph().setXSize(xSize); } - public int getxSize() { - return this.xSize; + public int getXSize() { + return cppcheckConfig.getConfigGraph().getXSize(); } @DataBoundSetter - public void setySize(int ySize) { - this.ySize = ySize; + public void setYSize(int ySize) { + cppcheckConfig.getConfigGraph().setYSize(ySize); } - public int getySize() { - return this.ySize; + public int getYSize() { + return cppcheckConfig.getConfigGraph().getYSize(); } @DataBoundSetter - public void setnumBuildsInGraph(int numBuildsInGraph) { - this.numBuildsInGraph = numBuildsInGraph; + public void setNumBuildsInGraph(int numBuildsInGraph) { + cppcheckConfig.getConfigGraph().setNumBuildsInGraph(numBuildsInGraph); } - public int getnumBuildsInGraph() { - return this.numBuildsInGraph; + public int getNumBuildsInGraph() { + return cppcheckConfig.getConfigGraph().getNumBuildsInGraph(); } @@ -576,113 +534,58 @@ public CppcheckConfig getConfig() { return new CppcheckConfig(); } } - - //getters of the data variables - public String getPattern(){ - return cppcheckConfig.getPattern(); - } - + + // getters aliases public boolean isIgnoreBlankFiles(){ - return cppcheckConfig.isIgnoreBlankFiles(); + return getIgnoreBlankFiles(); } - public boolean isAllowNoReport(){ - return cppcheckConfig.getAllowNoReport(); + return getAllowNoReport(); } - - public String getThreshold(){ - return cppcheckConfig.getConfigSeverityEvaluation().getThreshold(); - } - - public String getNewThreshold(){ - return cppcheckConfig.getConfigSeverityEvaluation().getNewThreshold(); - } - - public String getFailureThreshold(){ - return cppcheckConfig.getConfigSeverityEvaluation().getFailureThreshold(); - } - - public String getNewFailureThreshold(){ - return cppcheckConfig.getConfigSeverityEvaluation().getNewFailureThreshold(); - } - - public String getHealthy(){ - return cppcheckConfig.getConfigSeverityEvaluation().getHealthy(); - } - - public String getUnHealthy(){ - return cppcheckConfig.getConfigSeverityEvaluation().getUnHealthy(); - } - public boolean isSeverityError(){ - return cppcheckConfig.getConfigSeverityEvaluation().isSeverityError(); + return getSeverityError(); } - public boolean isSeverityWarning(){ - return cppcheckConfig.getConfigSeverityEvaluation().isSeverityWarning(); + return getSeverityWarning(); } - public boolean isSeverityStyle(){ - return cppcheckConfig.getConfigSeverityEvaluation().isSeverityStyle(); + return getSeverityStyle(); } - public boolean isSeverityPerformance(){ - return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPerformance(); + return getSeverityPerformance(); } - public boolean isSeverityInformation(){ - return cppcheckConfig.getConfigSeverityEvaluation().isSeverityInformation(); + return getSeverityInformation(); } - public boolean isSeverityNoCategory(){ - return cppcheckConfig.getConfigSeverityEvaluation().isSeverityNoCategory(); + return getSeverityNoCategory(); } - public boolean isSeverityPortability(){ - return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPortability(); - } - - public int getXSize(){ - return cppcheckConfig.getConfigGraph().getXSize(); - } - - public int getYSize(){ - return cppcheckConfig.getConfigGraph().getYSize(); - } - - public int getNumBuildsInGraph(){ - return cppcheckConfig.getConfigGraph().getNumBuildsInGraph(); + return getSeverityPortability(); } - public boolean isDisplayAllErrors(){ - return cppcheckConfig.getConfigGraph().isDisplayAllErrors(); + return getDisplayAllErrors(); } - public boolean isDisplayErrorSeverity(){ - return cppcheckConfig.getConfigGraph().isDisplayErrorSeverity(); + return getDisplayErrorSeverity(); } - public boolean isDisplayWarningSeverity(){ - return cppcheckConfig.getConfigGraph().isDisplayWarningSeverity(); + return getDisplayWarningSeverity(); } - public boolean isDisplayStyleSeverity(){ - return cppcheckConfig.getConfigGraph().isDisplayStyleSeverity(); + return getDisplayStyleSeverity(); } - public boolean isDisplayPerformanceSeverity(){ - return cppcheckConfig.getConfigGraph().isDisplayPerformanceSeverity(); + return getDisplayPerformanceSeverity(); } - public boolean isDisplayInformationSeverity(){ - return cppcheckConfig.getConfigGraph().isDisplayInformationSeverity(); + return getDisplayInformationSeverity(); } - public boolean isDisplayNoCategorySeverity(){ - return cppcheckConfig.getConfigGraph().isDisplayNoCategorySeverity(); + return getDisplayNoCategorySeverity(); } - public boolean isDisplayPortabilitySeverity(){ - return cppcheckConfig.getConfigGraph().isDisplayPortabilitySeverity(); + return getDisplayPortabilitySeverity(); } + } diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfig.java b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfig.java index 9298601..3f5a242 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfig.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfig.java @@ -11,8 +11,8 @@ public class CppcheckConfig implements Serializable { private static final long serialVersionUID = 1L; private String pattern; - private boolean ignoreBlankFiles; - private boolean allowNoReport; + private boolean ignoreBlankFiles = false; + private boolean allowNoReport = false; private CppcheckConfigSeverityEvaluation configSeverityEvaluation = new CppcheckConfigSeverityEvaluation(); private CppcheckConfigGraph configGraph = new CppcheckConfigGraph(); diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigGraph.java b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigGraph.java index 7d580be..db2668b 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigGraph.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigGraph.java @@ -14,15 +14,15 @@ public class CppcheckConfigGraph implements Serializable { private int xSize = DEFAULT_CHART_WIDTH; private int ySize = DEFAULT_CHART_HEIGHT; - private int numBuildsInGraph = 0; // numBuildsInGraph <= 1 means unlimited + private int numBuildsInGraph = 0; // numBuildsInGraph <= 0 means unlimited private boolean displayAllErrors = true; - private boolean displayErrorSeverity; - private boolean displayWarningSeverity; - private boolean displayStyleSeverity; - private boolean displayPerformanceSeverity; - private boolean displayInformationSeverity; - private boolean displayNoCategorySeverity; - private boolean displayPortabilitySeverity; + private boolean displayErrorSeverity = false; + private boolean displayWarningSeverity = false; + private boolean displayStyleSeverity = false; + private boolean displayPerformanceSeverity = false; + private boolean displayInformationSeverity = false; + private boolean displayNoCategorySeverity = false; + private boolean displayPortabilitySeverity = false; public CppcheckConfigGraph() { } @@ -48,46 +48,69 @@ public CppcheckConfigGraph(int xSize, int ySize, int numBuildsInGraph, this.displayPortabilitySeverity = displayPortabilitySeverity; } + public void setXSize(int xSize) { + if(xSize>0){this.xSize = xSize; } + } public int getXSize() { return xSize; } - + public void setYSize(int ySize) { + if(ySize>0){this.ySize = ySize; } + } public int getYSize() { return ySize; } - + public void setNumBuildsInGraph(int numBuildsInGraph) { + this.numBuildsInGraph = numBuildsInGraph; + } public int getNumBuildsInGraph() { return numBuildsInGraph; } - + public void setDisplayAllErrors(boolean displayAllErrors) { + this.displayAllErrors = displayAllErrors; + } public boolean isDisplayAllErrors() { return displayAllErrors; } - + public void setDisplayErrorSeverity(boolean displayErrorSeverity) { + this.displayErrorSeverity = displayErrorSeverity; + } public boolean isDisplayErrorSeverity() { return displayErrorSeverity; } - + public void setDisplayWarningSeverity(boolean displayWarningSeverity) { + this.displayWarningSeverity = displayWarningSeverity; + } public boolean isDisplayWarningSeverity() { return displayWarningSeverity; } - + public void setDisplayStyleSeverity(boolean displayStyleSeverity) { + this.displayStyleSeverity = displayStyleSeverity; + } public boolean isDisplayStyleSeverity() { return displayStyleSeverity; } - + public void setDisplayPerformanceSeverity(boolean displayPerformanceSeverity) { + this.displayPerformanceSeverity = displayPerformanceSeverity; + } public boolean isDisplayPerformanceSeverity() { return displayPerformanceSeverity; } - + public void setDisplayInformationSeverity(boolean displayInformationSeverity) { + this.displayInformationSeverity = displayInformationSeverity; + } public boolean isDisplayInformationSeverity() { return displayInformationSeverity; } - + public void setDisplayNoCategorySeverity(boolean displayNoCategorySeverity) { + this.displayNoCategorySeverity = displayNoCategorySeverity; + } public boolean isDisplayNoCategorySeverity() { return displayNoCategorySeverity; } - + public void setDisplayPortabilitySeverity(boolean displayPortabilitySeverity) { + this.displayPortabilitySeverity = displayPortabilitySeverity; + } public boolean isDisplayPortabilitySeverity() { return displayPortabilitySeverity; } diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigSeverityEvaluation.java b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigSeverityEvaluation.java index 3d697f3..e2472d8 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigSeverityEvaluation.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigSeverityEvaluation.java @@ -59,54 +59,81 @@ public CppcheckConfigSeverityEvaluation(String threshold, String newThreshold, this.severityPortability = severityPortability; } + public void setThreshold(String threshold) { + this.threshold = threshold; + } public String getThreshold() { return threshold; } - + public void setNewThreshold(String newThreshold) { + this.newThreshold = newThreshold; + } public String getNewThreshold() { return newThreshold; } - + public void setFailureThreshold(String failureThreshold) { + this.failureThreshold = failureThreshold; + } public String getFailureThreshold() { return failureThreshold; } - + public void setNewFailureThreshold(String newFailureThreshold) { + this.newFailureThreshold = newFailureThreshold; + } public String getNewFailureThreshold() { return newFailureThreshold; } - + public void setHealthy(String healthy) { + this.healthy = healthy; + } public String getHealthy() { return healthy; } - + public void setUnHealthy(String unHealthy) { + this.unHealthy = unHealthy; + } public String getUnHealthy() { return unHealthy; } - + public void setSeverityError(boolean severityError) { + this.severityError = severityError; + } public boolean isSeverityError() { return severityError; } - + public void setSeverityWarning(boolean severityWarning) { + this.severityWarning = severityWarning; + } public boolean isSeverityWarning() { return severityWarning; } - + public void setSeverityStyle(boolean severityStyle) { + this.severityStyle = severityStyle; + } public boolean isSeverityStyle() { return severityStyle; } - + public void setSeverityPerformance(boolean severityPerformance) { + this.severityPerformance = severityPerformance; + } public boolean isSeverityPerformance() { return severityPerformance; } - + public void setSeverityInformation(boolean severityInformation) { + this.severityInformation = severityInformation; + } public boolean isSeverityInformation() { return severityInformation; } - + public void setSeverityNoCategory(boolean severityNoCategory) { + this.severityNoCategory = severityNoCategory; + } public boolean isSeverityNoCategory() { return severityNoCategory; } - + public void setSeverityPortability(boolean severityPortability) { + this.severityPortability = severityPortability; + } public boolean isSeverityPortability() { return severityPortability; } From dd468a54af9cf627e3944abe82be601541912d8b Mon Sep 17 00:00:00 2001 From: Michael Doubez Date: Mon, 30 Apr 2018 09:44:07 +0200 Subject: [PATCH 6/9] Fix pipeline configuration --- .../plugins/cppcheck/CppcheckPublisher.java | 105 ++++-------------- .../cppcheck/config/CppcheckConfig.java | 2 +- .../CppcheckConfigSeverityEvaluation.java | 12 +- 3 files changed, 26 insertions(+), 93 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java index 0340c68..2c9685e 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java @@ -134,7 +134,7 @@ public String getPattern() { public void setThreshold(String threshold) { cppcheckConfig.getConfigSeverityEvaluation().setThreshold(threshold); } - public String geThreshold() { + public String getThreshold() { return cppcheckConfig.getConfigSeverityEvaluation().getThreshold(); } @DataBoundSetter @@ -176,118 +176,118 @@ public String getUnHealthy() { public void setIgnoreBlankFiles(boolean ignoreBlankFiles) { cppcheckConfig.setIgnoreBlankFiles(ignoreBlankFiles); } - public boolean getIgnoreBlankFiles() { + public boolean isIgnoreBlankFiles() { return cppcheckConfig.isIgnoreBlankFiles(); } @DataBoundSetter public void setAllowNoReport(boolean allowNoReport) { cppcheckConfig.setAllowNoReport(allowNoReport); } - public boolean getAllowNoReport() { + public boolean isAllowNoReport() { return cppcheckConfig.getAllowNoReport(); } @DataBoundSetter public void setSeverityError(boolean severityError) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityError(severityError); } - public boolean getSeverityError() { + public boolean isSeverityError() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityError(); } @DataBoundSetter public void setSeverityWarning(boolean severityWarning) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityWarning(severityWarning); } - public boolean getSeverityWarning() { + public boolean isSeverityWarning() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityWarning(); } @DataBoundSetter public void setSeverityStyle(boolean severityStyle) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityStyle(severityStyle); } - public boolean getSeverityStyle() { + public boolean isSeverityStyle() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityStyle(); } @DataBoundSetter public void setSeverityPerformance(boolean severityPerformance) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityPerformance(severityPerformance); } - public boolean getSeverityPerformance() { + public boolean isSeverityPerformance() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPerformance(); } @DataBoundSetter public void setSeverityInformation(boolean severityInformation) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityInformation(severityInformation); } - public boolean getSeverityInformation() { + public boolean isSeverityInformation() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityInformation(); } @DataBoundSetter public void setSeverityNoCategory(boolean severityNoCategory) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityNoCategory(severityNoCategory); } - public boolean getSeverityNoCategory() { + public boolean isSeverityNoCategory() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityNoCategory(); } @DataBoundSetter public void setSeverityPortability(boolean severityPortability) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityPortability(severityPortability); } - public boolean getSeverityPortability() { + public boolean isSeverityPortability() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPortability(); } @DataBoundSetter public void setDisplayAllErrors(boolean displayAllErrors) { cppcheckConfig.getConfigGraph().setDisplayAllErrors(displayAllErrors); } - public boolean getDisplayAllErrors() { + public boolean isDisplayAllErrors() { return cppcheckConfig.getConfigGraph().isDisplayAllErrors(); } @DataBoundSetter public void setDisplayErrorSeverity(boolean displayErrorSeverity) { cppcheckConfig.getConfigGraph().setDisplayErrorSeverity(displayErrorSeverity); } - public boolean getDisplayErrorSeverity() { + public boolean isDisplayErrorSeverity() { return cppcheckConfig.getConfigGraph().isDisplayErrorSeverity(); } @DataBoundSetter public void setDisplayWarningSeverity(boolean displayWarningSeverity) { cppcheckConfig.getConfigGraph().setDisplayWarningSeverity(displayWarningSeverity); } - public boolean getDisplayWarningSeverity() { + public boolean isDisplayWarningSeverity() { return cppcheckConfig.getConfigGraph().isDisplayWarningSeverity(); } @DataBoundSetter public void setDisplayStyleSeverity(boolean displayStyleSeverity) { cppcheckConfig.getConfigGraph().setDisplayStyleSeverity(displayStyleSeverity); } - public boolean getDisplayStyleSeverity() { + public boolean isDisplayStyleSeverity() { return cppcheckConfig.getConfigGraph().isDisplayStyleSeverity(); } @DataBoundSetter public void setDisplayPerformanceSeverity(boolean displayPerformanceSeverity) { cppcheckConfig.getConfigGraph().setDisplayPerformanceSeverity(displayPerformanceSeverity); } - public boolean getDisplayPerformanceSeverity() { + public boolean isDisplayPerformanceSeverity() { return cppcheckConfig.getConfigGraph().isDisplayPerformanceSeverity(); } public void setDisplayInformationSeverity(boolean displayInformationSeverity) { cppcheckConfig.getConfigGraph().setDisplayInformationSeverity(displayInformationSeverity); } - public boolean getDisplayInformationSeverity() { + public boolean isDisplayInformationSeverity() { return cppcheckConfig.getConfigGraph().isDisplayInformationSeverity(); } @DataBoundSetter public void setDisplayNoCategorySeverity(boolean displayNoCategorySeverity) { cppcheckConfig.getConfigGraph().setDisplayNoCategorySeverity(displayNoCategorySeverity); } - public boolean getDisplayNoCategorySeverity() { + public boolean isDisplayNoCategorySeverity() { return cppcheckConfig.getConfigGraph().isDisplayNoCategorySeverity(); } @DataBoundSetter public void setDisplayPortabilitySeverity(boolean displayPortabilitySeverity) { cppcheckConfig.getConfigGraph().setDisplayPortabilitySeverity(displayPortabilitySeverity); } - public boolean getDisplayPortabilitySeverity() { + public boolean isDisplayPortabilitySeverity() { return cppcheckConfig.getConfigGraph().isDisplayPortabilitySeverity(); } @DataBoundSetter @@ -507,11 +507,6 @@ private void copyFilesToBuildDirectory(final File rootDir, @Symbol("CppcheckPublisher") public static final class CppcheckDescriptor extends BuildStepDescriptor { - public CppcheckDescriptor() { - super(CppcheckPublisher.class); - load(); - } - public boolean isApplicable(Class jobType) { return true; } @@ -523,69 +518,7 @@ public String getDisplayName() { @Override public final String getHelpFile() { - return getPluginRoot() + "help.html"; - } - - public String getPluginRoot() { - return "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/plugin/cppcheck/"; - } - - public CppcheckConfig getConfig() { - return new CppcheckConfig(); + return "/plugin/cppcheck/help.html"; } } - - // getters aliases - public boolean isIgnoreBlankFiles(){ - return getIgnoreBlankFiles(); - } - public boolean isAllowNoReport(){ - return getAllowNoReport(); - } - public boolean isSeverityError(){ - return getSeverityError(); - } - public boolean isSeverityWarning(){ - return getSeverityWarning(); - } - public boolean isSeverityStyle(){ - return getSeverityStyle(); - } - public boolean isSeverityPerformance(){ - return getSeverityPerformance(); - } - public boolean isSeverityInformation(){ - return getSeverityInformation(); - } - public boolean isSeverityNoCategory(){ - return getSeverityNoCategory(); - } - public boolean isSeverityPortability(){ - return getSeverityPortability(); - } - public boolean isDisplayAllErrors(){ - return getDisplayAllErrors(); - } - public boolean isDisplayErrorSeverity(){ - return getDisplayErrorSeverity(); - } - public boolean isDisplayWarningSeverity(){ - return getDisplayWarningSeverity(); - } - public boolean isDisplayStyleSeverity(){ - return getDisplayStyleSeverity(); - } - public boolean isDisplayPerformanceSeverity(){ - return getDisplayPerformanceSeverity(); - } - public boolean isDisplayInformationSeverity(){ - return getDisplayInformationSeverity(); - } - public boolean isDisplayNoCategorySeverity(){ - return getDisplayNoCategorySeverity(); - } - public boolean isDisplayPortabilitySeverity(){ - return getDisplayPortabilitySeverity(); - } - } diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfig.java b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfig.java index 3f5a242..e324c50 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfig.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfig.java @@ -10,7 +10,7 @@ public class CppcheckConfig implements Serializable { /** Serial version UID. */ private static final long serialVersionUID = 1L; - private String pattern; + private String pattern = ""; private boolean ignoreBlankFiles = false; private boolean allowNoReport = false; private CppcheckConfigSeverityEvaluation configSeverityEvaluation = new CppcheckConfigSeverityEvaluation(); diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigSeverityEvaluation.java b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigSeverityEvaluation.java index e2472d8..8f87d7a 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigSeverityEvaluation.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfigSeverityEvaluation.java @@ -9,17 +9,17 @@ public class CppcheckConfigSeverityEvaluation implements Serializable { /** Serial version UID. */ private static final long serialVersionUID = 1L; - private String threshold; + private String threshold = ""; - private String newThreshold; + private String newThreshold = ""; - private String failureThreshold; + private String failureThreshold = ""; - private String newFailureThreshold; + private String newFailureThreshold = ""; - private String healthy; + private String healthy = ""; - private String unHealthy; + private String unHealthy = ""; private boolean severityError = true; From 04c3447f633e126e5f060a3a29f0414f5e429b6f Mon Sep 17 00:00:00 2001 From: Michael Doubez Date: Mon, 30 Apr 2018 23:43:27 +0200 Subject: [PATCH 7/9] Step name must start with lowercase --- .../plugins/cppcheck/CppcheckPublisher.java | 91 +++++++++++++++---- 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java index 2c9685e..4e40fcf 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java @@ -68,8 +68,6 @@ public class CppcheckPublisher extends Recorder implements SimpleBuildStep { @DataBoundConstructor public CppcheckPublisher() { cppcheckConfig = new CppcheckConfig(); - cppcheckConfig.setConfigSeverityEvaluation(new CppcheckConfigSeverityEvaluation()); - cppcheckConfig.setConfigGraph( new CppcheckConfigGraph()); } @Deprecated @@ -176,118 +174,118 @@ public String getUnHealthy() { public void setIgnoreBlankFiles(boolean ignoreBlankFiles) { cppcheckConfig.setIgnoreBlankFiles(ignoreBlankFiles); } - public boolean isIgnoreBlankFiles() { + public boolean getIgnoreBlankFiles() { return cppcheckConfig.isIgnoreBlankFiles(); } @DataBoundSetter public void setAllowNoReport(boolean allowNoReport) { cppcheckConfig.setAllowNoReport(allowNoReport); } - public boolean isAllowNoReport() { + public boolean getAllowNoReport() { return cppcheckConfig.getAllowNoReport(); } @DataBoundSetter public void setSeverityError(boolean severityError) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityError(severityError); } - public boolean isSeverityError() { + public boolean getSeverityError() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityError(); } @DataBoundSetter public void setSeverityWarning(boolean severityWarning) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityWarning(severityWarning); } - public boolean isSeverityWarning() { + public boolean getSeverityWarning() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityWarning(); } @DataBoundSetter public void setSeverityStyle(boolean severityStyle) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityStyle(severityStyle); } - public boolean isSeverityStyle() { + public boolean getSeverityStyle() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityStyle(); } @DataBoundSetter public void setSeverityPerformance(boolean severityPerformance) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityPerformance(severityPerformance); } - public boolean isSeverityPerformance() { + public boolean getSeverityPerformance() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPerformance(); } @DataBoundSetter public void setSeverityInformation(boolean severityInformation) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityInformation(severityInformation); } - public boolean isSeverityInformation() { + public boolean getSeverityInformation() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityInformation(); } @DataBoundSetter public void setSeverityNoCategory(boolean severityNoCategory) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityNoCategory(severityNoCategory); } - public boolean isSeverityNoCategory() { + public boolean getSeverityNoCategory() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityNoCategory(); } @DataBoundSetter public void setSeverityPortability(boolean severityPortability) { cppcheckConfig.getConfigSeverityEvaluation().setSeverityPortability(severityPortability); } - public boolean isSeverityPortability() { + public boolean getSeverityPortability() { return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPortability(); } @DataBoundSetter public void setDisplayAllErrors(boolean displayAllErrors) { cppcheckConfig.getConfigGraph().setDisplayAllErrors(displayAllErrors); } - public boolean isDisplayAllErrors() { + public boolean getDisplayAllErrors() { return cppcheckConfig.getConfigGraph().isDisplayAllErrors(); } @DataBoundSetter public void setDisplayErrorSeverity(boolean displayErrorSeverity) { cppcheckConfig.getConfigGraph().setDisplayErrorSeverity(displayErrorSeverity); } - public boolean isDisplayErrorSeverity() { + public boolean getDisplayErrorSeverity() { return cppcheckConfig.getConfigGraph().isDisplayErrorSeverity(); } @DataBoundSetter public void setDisplayWarningSeverity(boolean displayWarningSeverity) { cppcheckConfig.getConfigGraph().setDisplayWarningSeverity(displayWarningSeverity); } - public boolean isDisplayWarningSeverity() { + public boolean getDisplayWarningSeverity() { return cppcheckConfig.getConfigGraph().isDisplayWarningSeverity(); } @DataBoundSetter public void setDisplayStyleSeverity(boolean displayStyleSeverity) { cppcheckConfig.getConfigGraph().setDisplayStyleSeverity(displayStyleSeverity); } - public boolean isDisplayStyleSeverity() { + public boolean getDisplayStyleSeverity() { return cppcheckConfig.getConfigGraph().isDisplayStyleSeverity(); } @DataBoundSetter public void setDisplayPerformanceSeverity(boolean displayPerformanceSeverity) { cppcheckConfig.getConfigGraph().setDisplayPerformanceSeverity(displayPerformanceSeverity); } - public boolean isDisplayPerformanceSeverity() { + public boolean getDisplayPerformanceSeverity() { return cppcheckConfig.getConfigGraph().isDisplayPerformanceSeverity(); } public void setDisplayInformationSeverity(boolean displayInformationSeverity) { cppcheckConfig.getConfigGraph().setDisplayInformationSeverity(displayInformationSeverity); } - public boolean isDisplayInformationSeverity() { + public boolean getDisplayInformationSeverity() { return cppcheckConfig.getConfigGraph().isDisplayInformationSeverity(); } @DataBoundSetter public void setDisplayNoCategorySeverity(boolean displayNoCategorySeverity) { cppcheckConfig.getConfigGraph().setDisplayNoCategorySeverity(displayNoCategorySeverity); } - public boolean isDisplayNoCategorySeverity() { + public boolean getDisplayNoCategorySeverity() { return cppcheckConfig.getConfigGraph().isDisplayNoCategorySeverity(); } @DataBoundSetter public void setDisplayPortabilitySeverity(boolean displayPortabilitySeverity) { cppcheckConfig.getConfigGraph().setDisplayPortabilitySeverity(displayPortabilitySeverity); } - public boolean isDisplayPortabilitySeverity() { + public boolean getDisplayPortabilitySeverity() { return cppcheckConfig.getConfigGraph().isDisplayPortabilitySeverity(); } @DataBoundSetter @@ -504,7 +502,7 @@ private void copyFilesToBuildDirectory(final File rootDir, } @Extension - @Symbol("CppcheckPublisher") + @Symbol("cppcheckPublisher") public static final class CppcheckDescriptor extends BuildStepDescriptor { public boolean isApplicable(Class jobType) { @@ -521,4 +519,57 @@ public final String getHelpFile() { return "/plugin/cppcheck/help.html"; } } + + // getters aliases for boolean + public boolean isIgnoreBlankFiles(){ + return getIgnoreBlankFiles(); + } + public boolean isAllowNoReport(){ + return getAllowNoReport(); + } + public boolean isSeverityError(){ + return getSeverityError(); + } + public boolean isSeverityWarning(){ + return getSeverityWarning(); + } + public boolean isSeverityStyle(){ + return getSeverityStyle(); + } + public boolean isSeverityPerformance(){ + return getSeverityPerformance(); + } + public boolean isSeverityInformation(){ + return getSeverityInformation(); + } + public boolean isSeverityNoCategory(){ + return getSeverityNoCategory(); + } + public boolean isSeverityPortability(){ + return getSeverityPortability(); + } + public boolean isDisplayAllErrors(){ + return getDisplayAllErrors(); + } + public boolean isDisplayErrorSeverity(){ + return getDisplayErrorSeverity(); + } + public boolean isDisplayWarningSeverity(){ + return getDisplayWarningSeverity(); + } + public boolean isDisplayStyleSeverity(){ + return getDisplayStyleSeverity(); + } + public boolean isDisplayPerformanceSeverity(){ + return getDisplayPerformanceSeverity(); + } + public boolean isDisplayInformationSeverity(){ + return getDisplayInformationSeverity(); + } + public boolean isDisplayNoCategorySeverity(){ + return getDisplayNoCategorySeverity(); + } + public boolean isDisplayPortabilitySeverity(){ + return getDisplayPortabilitySeverity(); + } } From 021159a92cf9be8b2d6221c0d72329f1209b3f10 Mon Sep 17 00:00:00 2001 From: Michael Doubez Date: Tue, 1 May 2018 01:00:39 +0200 Subject: [PATCH 8/9] Last fixes --- pom.xml | 2 +- .../hudson/plugins/cppcheck/util/CppcheckUtil.java | 2 +- .../org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 70b1844..e0c15f3 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ 4.8.2 1.8.5 2.0 - 2.30 + 2.30 diff --git a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java index b3f7c63..f60e7b1 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/util/CppcheckUtil.java @@ -33,7 +33,7 @@ public class CppcheckUtil { * * @param cppecheckConfig configuration of CppCheck run * @param result results of the CPPCheck runs - * @param checkNewError is the number of errors is increasing + * @param checkNewError check if the number of errors is increasing * @return number of errors */ public static int getNumberErrors(CppcheckConfig cppecheckConfig, CppcheckResult result, boolean checkNewError) { diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java index 4e40fcf..61e13d4 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java @@ -505,6 +505,12 @@ private void copyFilesToBuildDirectory(final File rootDir, @Symbol("cppcheckPublisher") public static final class CppcheckDescriptor extends BuildStepDescriptor { + public CppcheckDescriptor() { + super(CppcheckPublisher.class); + load(); + } + + @Override public boolean isApplicable(Class jobType) { return true; } From 9bb595f2672aa6486d33803062405873b4ece080 Mon Sep 17 00:00:00 2001 From: Michael DOUBEZ Date: Wed, 2 May 2018 08:21:43 +0200 Subject: [PATCH 9/9] Restore default config display for Pipeline Syntax generator --- .../org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java index 61e13d4..20ecb18 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java @@ -524,6 +524,11 @@ public String getDisplayName() { public final String getHelpFile() { return "/plugin/cppcheck/help.html"; } + + // default config for pipeline syntax generator + public CppcheckConfig getConfig() { + return new CppcheckConfig(); + } } // getters aliases for boolean