null
not permitted).
75 | *
76 | * @return A boolean.
77 | */
78 | public boolean equals(Object obj) {
79 | if (obj == this) {
80 | return true;
81 | }
82 | if (!(obj instanceof CppcheckAreaRenderer)) {
83 | return false;
84 | }
85 | CppcheckAreaRenderer that = (CppcheckAreaRenderer) obj;
86 |
87 | if (this.url != that.url) {
88 | return false;
89 | }
90 | return super.equals(obj);
91 | }
92 |
93 |
94 | public int hashCode() {
95 | return this.url.hashCode();
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckHealthReportThresholds.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2009 Thales Corporate Services SAS *
3 | * Author : Gregory Boissinot *
4 | * *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy *
6 | * of this software and associated documentation files (the "Software"), to deal*
7 | * in the Software without restriction, including without limitation the rights *
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
9 | * copies of the Software, and to permit persons to whom the Software is *
10 | * furnished to do so, subject to the following conditions: *
11 | * *
12 | * The above copyright notice and this permission notice shall be included in *
13 | * all copies or substantial portions of the Software. *
14 | * *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,*
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
21 | * THE SOFTWARE. *
22 | *******************************************************************************/
23 |
24 |
25 | package com.thalesgroup.hudson.plugins.cppcheck;
26 |
27 | import java.io.Serializable;
28 |
29 |
30 | public class CppcheckHealthReportThresholds implements Serializable {
31 |
32 | private static final long serialVersionUID = 1L;
33 |
34 | private final String threshold;
35 |
36 | private final String newThreshold;
37 |
38 | private final String failureThreshold;
39 |
40 | private final String newFailureThreshold;
41 |
42 | private final String healthy;
43 |
44 | private final String unHealthy;
45 |
46 | private final String thresholdLimit;
47 |
48 |
49 | public CppcheckHealthReportThresholds(String threshold, String newThreshold, String failureThreshold, String newFailureThreshold, String healthy, String unHealthy, String thresholdLimit) {
50 | this.threshold = threshold;
51 | this.newThreshold = newThreshold;
52 | this.failureThreshold = failureThreshold;
53 | this.newFailureThreshold = newFailureThreshold;
54 | this.healthy = healthy;
55 | this.unHealthy = unHealthy;
56 | this.thresholdLimit = thresholdLimit;
57 | }
58 |
59 | public String getThreshold() {
60 | return threshold;
61 | }
62 |
63 | public String getNewThreshold() {
64 | return newThreshold;
65 | }
66 |
67 | public String getFailureThreshold() {
68 | return failureThreshold;
69 | }
70 |
71 | public String getNewFailureThreshold() {
72 | return newFailureThreshold;
73 | }
74 |
75 | public String getHealthy() {
76 | return healthy;
77 | }
78 |
79 | public String getUnHealthy() {
80 | return unHealthy;
81 | }
82 |
83 | public String getThresholdLimit() {
84 | return thresholdLimit;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckMetricUtil.java:
--------------------------------------------------------------------------------
1 | package com.thalesgroup.hudson.plugins.cppcheck;
2 |
3 | import com.thalesgroup.hudson.plugins.cppcheck.config.CppcheckConfig;
4 | import org.apache.commons.lang.StringUtils;
5 |
6 | public class CppcheckMetricUtil {
7 |
8 | public static int convert(String threshold) {
9 | if (isValid(threshold)) {
10 | if (StringUtils.isNotBlank(threshold)) {
11 | try {
12 | return Integer.parseInt(threshold);
13 | } catch (NumberFormatException exception) {
14 | // not valid
15 | }
16 | }
17 | }
18 | throw new IllegalArgumentException("Not a parsable integer value >= 0: " + threshold);
19 | }
20 |
21 | public static boolean isValid(final String threshold) {
22 | if (StringUtils.isNotBlank(threshold)) {
23 | try {
24 | return Integer.parseInt(threshold) >= 0;
25 | } catch (NumberFormatException exception) {
26 | // not valid
27 | }
28 | }
29 | return false;
30 | }
31 |
32 | public static String getMessageSelectedSeverties(CppcheckConfig cppcheckConfig) {
33 | StringBuffer sb = new StringBuffer();
34 |
35 | if (cppcheckConfig.getConfigSeverityEvaluation().isAllSeverities()) {
36 | sb.append("with all severities");
37 | return sb.toString();
38 | }
39 |
40 | if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityError()) {
41 | sb.append(" and ");
42 | sb.append("severity 'error'");
43 | }
44 |
45 | if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityPossibleError()) {
46 | sb.append(" and ");
47 | sb.append("severity 'possible error'");
48 | }
49 |
50 |
51 | if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityPossibleStyle()) {
52 | sb.append(" and ");
53 | sb.append("severity 'possible style'");
54 | }
55 |
56 |
57 | if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityStyle()) {
58 | sb.append(" and ");
59 | sb.append("severity 'style'");
60 | }
61 |
62 | if (sb.length() != 0)
63 | sb.delete(0, 5);
64 |
65 | return sb.toString();
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckProjectAction.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2009 Thales Corporate Services SAS *
3 | * Author : Gregory Boissinot *
4 | * *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy *
6 | * of this software and associated documentation files (the "Software"), to deal*
7 | * in the Software without restriction, including without limitation the rights *
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
9 | * copies of the Software, and to permit persons to whom the Software is *
10 | * furnished to do so, subject to the following conditions: *
11 | * *
12 | * The above copyright notice and this permission notice shall be included in *
13 | * all copies or substantial portions of the Software. *
14 | * *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,*
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
21 | * THE SOFTWARE. *
22 | *******************************************************************************/
23 |
24 | package com.thalesgroup.hudson.plugins.cppcheck;
25 |
26 | import com.thalesgroup.hudson.plugins.cppcheck.util.AbstractCppcheckProjectAction;
27 | import hudson.model.AbstractBuild;
28 | import hudson.model.AbstractProject;
29 | import hudson.model.Result;
30 |
31 |
32 | public class CppcheckProjectAction extends AbstractCppcheckProjectAction {
33 |
34 | public String getSearchUrl() {
35 | return getUrlName();
36 | }
37 |
38 | public CppcheckProjectAction(final AbstractProject, ?> project) {
39 | super(project);
40 | }
41 |
42 | public AbstractBuild, ?> getLastFinishedBuild() {
43 | AbstractBuild, ?> lastBuild = project.getLastBuild();
44 | while (lastBuild != null && (lastBuild.isBuilding() || lastBuild.getAction(CppcheckBuildAction.class) == null)) {
45 | lastBuild = lastBuild.getPreviousBuild();
46 | }
47 | return lastBuild;
48 | }
49 |
50 | @SuppressWarnings("unused")
51 | public final boolean isDisplayGraph() {
52 | //Latest
53 | AbstractBuild, ?> b = getLastFinishedBuild();
54 | if (b == null) {
55 | return false;
56 | }
57 |
58 | //Affect previous
59 | b = b.getPreviousBuild();
60 | if (b != null) {
61 |
62 | for (; b != null; b = b.getPreviousBuild()) {
63 | if (b.getResult().isWorseOrEqualTo(Result.FAILURE)) {
64 | continue;
65 | }
66 | CppcheckBuildAction action = b.getAction(CppcheckBuildAction.class);
67 | if (action == null || action.getResult() == null) {
68 | continue;
69 | }
70 | CppcheckResult result = action.getResult();
71 | if (result == null)
72 | continue;
73 |
74 | return true;
75 | }
76 | }
77 | return false;
78 | }
79 |
80 | public Integer getLastResultBuild() {
81 | for (AbstractBuild, ?> b = (AbstractBuild, ?>) project.getLastBuild(); b != null; b = b.getPreviousNotFailedBuild()) {
82 | if (b.getResult() == Result.FAILURE)
83 | continue;
84 | CppcheckBuildAction r = b.getAction(CppcheckBuildAction.class);
85 | if (r != null)
86 | return b.getNumber();
87 | }
88 | return null;
89 | }
90 |
91 |
92 | public String getDisplayName() {
93 | return "Cppcheck Results";
94 | }
95 |
96 | public String getUrlName() {
97 | return CppcheckBuildAction.URL_NAME;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckPublisher.java:
--------------------------------------------------------------------------------
1 | package com.thalesgroup.hudson.plugins.cppcheck;
2 |
3 | import com.thalesgroup.hudson.plugins.cppcheck.config.CppcheckConfig;
4 | import hudson.model.AbstractProject;
5 | import hudson.tasks.BuildStepDescriptor;
6 | import hudson.tasks.BuildStepMonitor;
7 | import hudson.tasks.Publisher;
8 | import hudson.tasks.Recorder;
9 |
10 | /**
11 | * @author Gregory Boissinot
12 | */
13 | @Deprecated
14 | public class CppcheckPublisher extends Recorder {
15 |
16 | private transient CppcheckConfig cppcheckConfig;
17 |
18 | public BuildStepMonitor getRequiredMonitorService() {
19 | return BuildStepMonitor.BUILD;
20 | }
21 |
22 | public static final CppcheckDescriptor DESCRIPTOR = new CppcheckDescriptor();
23 |
24 | /**
25 | * The Cppcheck Descriptor
26 | */
27 | public static final class CppcheckDescriptor extends BuildStepDescriptor32 | ${%This plugin will not report Cppcheck result until there is at least one success or unstable build.} 33 |
34 |All errors | 38 |New errors | 39 |
${it.report.numberTotal} | 43 |${it.numberNewErrorsFromPreviousBuild} | 44 |
Total | 53 |Severity 'error' | 54 |Severity 'possible error' | 55 |Severity 'style' | 56 |Severity 'possible style' | 57 |no category | 58 |
${it.report.numberTotal} | 62 |${it.report.numberSeverityError} | 63 |${it.report.numberSeverityPossibleError} | 64 |${it.report.numberSeverityStyle} | 65 |${it.report.numberSeverityPossibleStyle} | 66 |${it.report.numberSeverityNoCategory} | 67 |
32 | ${%The current user must have the WORKSPACE permission for the job.} 33 |
34 |Filename | 33 |LineNumber | 34 |CppCheckId | 35 |Severity | 36 |Message | 37 |
44 | |
53 |
${%Severity} | 18 |${%Count} | 19 |${%Delta} | 20 |
${%Error} | 25 |${stat.numberErrorSeverity} | 26 |${diff.formatDiff(diff.numberErrorSeverity)} | 27 |
${%Warning} | 31 |${stat.numberWarningSeverity} | 32 |${diff.formatDiff(diff.numberWarningSeverity)} | 33 |
${%Style} | 37 |${stat.numberStyleSeverity} | 38 |${diff.formatDiff(diff.numberStyleSeverity)} | 39 |
${%Performance} | 43 |${stat.numberPerformanceSeverity} | 44 |${diff.formatDiff(diff.numberPerformanceSeverity)} | 45 |
${%Portability} | 49 |${stat.numberPortabilitySeverity} | 50 |${diff.formatDiff(diff.numberPortabilitySeverity)} | 51 |
${%Information} | 55 |${stat.numberInformationSeverity} | 56 |${diff.formatDiff(diff.numberInformationSeverity)} | 57 |
${%No category} | 61 |${stat.numberNoCategorySeverity} | 62 |${diff.formatDiff(diff.numberNoCategorySeverity)} | 63 |
${%Total} | 68 |${stat.numberTotal} | 69 |${diff.formatDiff(diff.numberTotal)} | 70 |
8 | ${%This plugin will not report Cppcheck result until there is at least one success or unstable build.} 9 |
10 |Cppcheck must be executed to generate XML reports for this plugin to function. 2 | Fileset 3 | 'includes' setting specifies the generated Cppcheck XML report files, 4 | such as '**/cppcheck-result-*.xml'. Base directory of the fileset is relative 5 | to the workspace root directory.
6 | 7 |If no value is set, then the default '**/cppcheck-result.xml' will be used. 8 | Be sure to never include any non-report files into this pattern.
9 | 10 |The plugin is able to work with both XML formats produced by Cppcheck, 11 | but always prefer to use the newer version 2. Cppcheck doesn't report some 12 | issues with the legacy format.
13 | -------------------------------------------------------------------------------- /src/main/resources/org/jenkinsci/plugins/cppcheck/CppcheckPublisher/help-severity.html: -------------------------------------------------------------------------------- 1 | Determines which severity of issues should be considered when evaluating the 2 | build status and health. -------------------------------------------------------------------------------- /src/main/resources/org/jenkinsci/plugins/cppcheck/CppcheckPublisher/help-thresholds.html: -------------------------------------------------------------------------------- 1 | Configure the build status and health. A build is considered as unstable or 2 | failure if the new or total number of issues exceeds the specified thresholds. 3 | The build health is also determined by thresholds. If the actual number of 4 | issues is between the provided thresholds, then the build health is interpolated. -------------------------------------------------------------------------------- /src/main/resources/org/jenkinsci/plugins/cppcheck/CppcheckResult/details.jelly: -------------------------------------------------------------------------------- 1 | 2 |Show issues highlighted on a single page
19 |${%State} | 31 |${%File} | 32 |${%Line} | 33 |${%Severity} | 34 |${%Type} | 35 |${%Inconclusive} | 36 |${%Message} | 37 |
${elt.diffState.text} | 50 |
51 | |
58 |
59 | |
66 | ${cppcheckFile.severity} | 67 |${cppcheckFile.cppCheckId} | 68 |${cppcheckFile.inconclusive} | 69 |${cppcheckFile.messageHtml} | 70 |
${stat.versions}
17 |8 | ${%The current user must have the WORKSPACE permission for the job.} 9 |
10 |${%The result set is empty.}
29 |${file.cppcheckFile.verboseHtml}
67 |
71 | ${it.getSourceCode(file)}
72 |
73 | ${%Job} | 25 |${%Total} | 26 |${%Error} | 27 |${%Warning} | 28 |${%Style} | 29 |${%Performance} | 30 |${%Portability} | 31 |${%Information} | 32 |${%No category} | 33 |
${stats.numberTotal} | 42 |${stats.numberErrorSeverity} | 43 |${stats.numberWarningSeverity} | 44 |${stats.numberStyleSeverity} | 45 |${stats.numberPerformanceSeverity} | 46 |${stats.numberPortabilitySeverity} | 47 |${stats.numberInformationSeverity} | 48 |${stats.numberNoCategorySeverity} | 49 | 50 ||
${%Total} | 64 |${numberTotal} | 65 |${numberErrorSeverity} | 66 |${numberWarningSeverity} | 67 |${numberStyleSeverity} | 68 |${numberPerformanceSeverity} | 69 |${numberPortabilitySeverity} | 70 |${numberInformationSeverity} | 71 |${numberNoCategorySeverity} | 72 |
Jenkins understands the Cppcheck report XML format. 3 | When this option is configured, Jenkins can provide useful information about results in different views: 4 | historical result trend, analysis reports.
5 | 6 |You need to set up your build to run Cppcheck in order to use 7 | this feature - this Jenkins plug-in does not perform the actual analysis! 8 | This plug-in is not invoked for failed builds, it is only called for 9 | stable or unstable builds (i.e., a build with failed tests).
10 |