diff --git a/pom.xml b/pom.xml index b85cd69..e0c15f3 100644 --- a/pom.xml +++ b/pom.xml @@ -42,19 +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 + 2.3 5.0 4.8.2 1.8.5 2.0 - 2.30 + 2.30 @@ -121,6 +121,50 @@ + + + + + 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 + + + + + @@ -135,7 +179,6 @@ ${basedir}/src/main/resources/com/thalesgroup/hudson/plugins/cppcheck/cppcheck-1.0.xsd - false xjc @@ -155,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/CppcheckAreaRenderer.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckAreaRenderer.java index 9616f9b..8efc369 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckAreaRenderer.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckAreaRenderer.java @@ -67,7 +67,7 @@ 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. * 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 443cd27..9e39b8c 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckBuildAction.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckBuildAction.java @@ -38,7 +38,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.Run; import hudson.model.HealthReport; import hudson.model.Run; import hudson.util.ChartUtil; 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/CppcheckSource.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java index 37ba24a..df243a9 100644 --- a/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java +++ b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource.java @@ -108,7 +108,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 { @@ -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/model/CppcheckWorkspaceFile.java b/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/model/CppcheckWorkspaceFile.java index eaf32d4..8d54218 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 @@ -28,6 +28,8 @@ 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('\\', '/'); 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..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 check 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/CppcheckBuildAction.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckBuildAction.java index fcc3c7d..f8b00d8 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckBuildAction.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckBuildAction.java @@ -40,7 +40,7 @@ public CppcheckBuildAction(Run owner, CppcheckResult result, CppcheckConfi this.result = result; this.healthReportPercentage = healthReportPercentage; - List projectActions = new ArrayList<>(); + List projectActions = new ArrayList(); projectActions.add(new CppcheckProjectAction(owner, config.getConfigGraph())); this.projectActions = projectActions; } diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java index 1cc4c6f..20ecb18 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java @@ -33,8 +33,25 @@ import hudson.tasks.BuildStepMonitor; 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; +import java.util.Collection; + /** * @author Gregory Boissinot */ @@ -48,37 +65,10 @@ 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(); + } @Deprecated public CppcheckPublisher(String pattern, @@ -103,41 +93,13 @@ 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); - CppcheckConfigSeverityEvaluation configSeverityEvaluation = new CppcheckConfigSeverityEvaluation( + + cppcheckConfig.setConfigSeverityEvaluation( + new CppcheckConfigSeverityEvaluation( threshold, newThreshold, failureThreshold, newFailureThreshold, healthy, unHealthy, severityError, severityWarning, @@ -145,9 +107,9 @@ public CppcheckPublisher(String pattern, severityPerformance, severityInformation, severityNoCategory, - severityPortability); - cppcheckConfig.setConfigSeverityEvaluation(configSeverityEvaluation); - CppcheckConfigGraph configGraph = new CppcheckConfigGraph( + severityPortability)); + + cppcheckConfig.setConfigGraph( new CppcheckConfigGraph( xSize, ySize, numBuildsInGraph, displayAllErrors, displayErrorSeverity, @@ -156,184 +118,196 @@ public CppcheckPublisher(String pattern, displayPerformanceSeverity, displayInformationSeverity, displayNoCategorySeverity, - displayPortabilitySeverity); - cppcheckConfig.setConfigGraph(configGraph); + displayPortabilitySeverity)); } @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 getThreshold() { + 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 setseverityPerformance(boolean severityPerformance) { - this.severityPerformance = severityPerformance; + public void setSeverityStyle(boolean severityStyle) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityStyle(severityStyle); } - public boolean getseverityPerformance() { - return this.severityPerformance; + public boolean getSeverityStyle() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityStyle(); } @DataBoundSetter - public void setseverityInformation(boolean severityInformation) { - this.severityInformation = severityInformation; + public void setSeverityPerformance(boolean severityPerformance) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityPerformance(severityPerformance); } - public boolean getseverityInformation() { - return this.severityInformation; + public boolean getSeverityPerformance() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPerformance(); } @DataBoundSetter - public void setseverityNoCategory(boolean severityNoCategory) { - this.severityNoCategory = severityNoCategory; + public void setSeverityInformation(boolean severityInformation) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityInformation(severityInformation); } - public boolean getseverityNoCategory() { - return this.severityNoCategory; + public boolean getSeverityInformation() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityInformation(); } @DataBoundSetter - public void setseverityPortability(boolean severityPortability) { - this.severityPortability = severityPortability; + public void setSeverityNoCategory(boolean severityNoCategory) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityNoCategory(severityNoCategory); } - public boolean getseverityPortability() { - return this.severityPortability; + public boolean getSeverityNoCategory() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityNoCategory(); } @DataBoundSetter - public void setdisplayAllErrors(boolean displayAllErrors) { - this.displayAllErrors = displayAllErrors; + public void setSeverityPortability(boolean severityPortability) { + cppcheckConfig.getConfigSeverityEvaluation().setSeverityPortability(severityPortability); } - public boolean getdisplayAllErrors() { - return this.displayAllErrors; + public boolean getSeverityPortability() { + return cppcheckConfig.getConfigSeverityEvaluation().isSeverityPortability(); } @DataBoundSetter - public void setdisplayErrorSeverity(boolean displayErrorSeverity) { - this.displayErrorSeverity = displayErrorSeverity; + public void setDisplayAllErrors(boolean displayAllErrors) { + cppcheckConfig.getConfigGraph().setDisplayAllErrors(displayAllErrors); } - public boolean getdisplayErrorSeverity() { - return this.displayErrorSeverity; + public boolean getDisplayAllErrors() { + return cppcheckConfig.getConfigGraph().isDisplayAllErrors(); } @DataBoundSetter - public void setdisplayWarningSeverity(boolean displayWarningSeverity) { - this.displayWarningSeverity = displayWarningSeverity; + public void setDisplayErrorSeverity(boolean displayErrorSeverity) { + cppcheckConfig.getConfigGraph().setDisplayErrorSeverity(displayErrorSeverity); } - public boolean getdisplayWarningSeverity() { - return this.displayWarningSeverity; + public boolean getDisplayErrorSeverity() { + return cppcheckConfig.getConfigGraph().isDisplayErrorSeverity(); } @DataBoundSetter - public void setdisplayStyleSeverity(boolean displayStyleSeverity) { - this.displayStyleSeverity = displayStyleSeverity; + public void setDisplayWarningSeverity(boolean displayWarningSeverity) { + cppcheckConfig.getConfigGraph().setDisplayWarningSeverity(displayWarningSeverity); } - public boolean getdisplayStyleSeverity() { - return this.displayStyleSeverity; + public boolean getDisplayWarningSeverity() { + return cppcheckConfig.getConfigGraph().isDisplayWarningSeverity(); } @DataBoundSetter - public void setdisplayPerformanceSeverity(boolean displayPerformanceSeverity) { - this.displayPerformanceSeverity = displayPerformanceSeverity; + public void setDisplayStyleSeverity(boolean displayStyleSeverity) { + cppcheckConfig.getConfigGraph().setDisplayStyleSeverity(displayStyleSeverity); + } + public boolean getDisplayStyleSeverity() { + return cppcheckConfig.getConfigGraph().isDisplayStyleSeverity(); + } + @DataBoundSetter + 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(); } @@ -372,6 +346,7 @@ public void perform(@Nonnull Run build, @Nonnull FilePath workspace, @Nonnu CppcheckReport cppcheckReport; try { cppcheckReport = workspace.act(parser); + } catch (Exception e) { CppcheckLogger.log(listener, "Error on cppcheck analysis: " + e); build.setResult(Result.FAILURE); @@ -423,7 +398,6 @@ public void perform(@Nonnull Run build, @Nonnull FilePath workspace, @Nonnu } return; } - @Override public boolean perform(AbstractBuild build, Launcher launcher, @@ -444,7 +418,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, if( oWorkspacePath != null) { cppcheckReport = oWorkspacePath.act(parser); } - + } catch (Exception e) { CppcheckLogger.log(listener, "Error on cppcheck analysis: " + e); build.setResult(Result.FAILURE); @@ -495,7 +469,6 @@ public boolean perform(AbstractBuild build, Launcher launcher, return true; } - /** * Copies all the source files from the workspace to the build folder. * @@ -529,6 +502,7 @@ private void copyFilesToBuildDirectory(final File rootDir, } @Extension + @Symbol("cppcheckPublisher") public static final class CppcheckDescriptor extends BuildStepDescriptor { public CppcheckDescriptor() { @@ -536,6 +510,7 @@ public CppcheckDescriptor() { load(); } + @Override public boolean isApplicable(Class jobType) { return true; } @@ -547,15 +522,65 @@ public String getDisplayName() { @Override public final String getHelpFile() { - return getPluginRoot() + "help.html"; - } - - public String getPluginRoot() { - return "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/plugin/cppcheck/"; + return "/plugin/cppcheck/help.html"; } + // default config for pipeline syntax generator public CppcheckConfig getConfig() { return new CppcheckConfig(); } } + + // 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(); + } } diff --git a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceContainer.java b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceContainer.java index a4f151c..02a7fe7 100644 --- a/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceContainer.java +++ b/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckSourceContainer.java @@ -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/CppcheckConfig.java b/src/main/java/org/jenkinsci/plugins/cppcheck/config/CppcheckConfig.java index 9298601..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,9 +10,9 @@ public class CppcheckConfig implements Serializable { /** Serial version UID. */ private static final long serialVersionUID = 1L; - private String pattern; - private boolean ignoreBlankFiles; - private boolean allowNoReport; + private String pattern = ""; + 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 e6f8ff6..db2668b 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,117 @@ -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 <= 0 means unlimited + private boolean displayAllErrors = true; + 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() { + } + + 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 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; + } +} \ No newline at end of file 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..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; @@ -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; }