├── src ├── main │ ├── resources │ │ ├── util │ │ │ ├── taglib │ │ │ └── thresholds.properties │ │ ├── jelly │ │ │ └── cppcheck │ │ │ │ ├── taglib │ │ │ │ └── format.jelly │ │ ├── com │ │ │ └── thalesgroup │ │ │ │ └── hudson │ │ │ │ └── plugins │ │ │ │ └── cppcheck │ │ │ │ ├── CppcheckSource │ │ │ │ ├── index.properties │ │ │ │ └── index.jelly │ │ │ │ ├── Messages.properties │ │ │ │ ├── CppcheckPublisher │ │ │ │ ├── config.properties │ │ │ │ └── config.jelly │ │ │ │ ├── CppcheckBuildAction │ │ │ │ └── summary.jelly │ │ │ │ ├── CppcheckResult │ │ │ │ ├── nosourcepermission.jelly │ │ │ │ ├── summary.jelly │ │ │ │ └── index.jelly │ │ │ │ ├── CppcheckProjectAction │ │ │ │ ├── nodata.jelly │ │ │ │ └── floatingBox.jelly │ │ │ │ └── cppcheck-1.0.xsd │ │ ├── org │ │ │ └── jenkinsci │ │ │ │ └── plugins │ │ │ │ └── cppcheck │ │ │ │ ├── CppcheckPublisher │ │ │ │ ├── help-severity.html │ │ │ │ ├── help-thresholds.html │ │ │ │ ├── help-pattern.html │ │ │ │ └── config.jelly │ │ │ │ ├── CppcheckProjectAction │ │ │ │ ├── floatingBox.jelly │ │ │ │ ├── nodata.jelly │ │ │ │ └── jobMain.jelly │ │ │ │ ├── CppcheckResult │ │ │ │ ├── nosourcepermission.jelly │ │ │ │ ├── index.jelly │ │ │ │ └── details.jelly │ │ │ │ ├── CppcheckBuildAction │ │ │ │ ├── summary.jelly │ │ │ │ └── statistics.jelly │ │ │ │ ├── CppcheckTablePortlet │ │ │ │ ├── portlet.jelly │ │ │ │ └── table.jelly │ │ │ │ ├── Messages.properties │ │ │ │ ├── cppcheck-2.0.xsd │ │ │ │ └── CppcheckSourceAll │ │ │ │ └── index.jelly │ │ └── index.jelly │ ├── webapp │ │ ├── icons │ │ │ ├── cppcheck-24.png │ │ │ ├── cppcheck-32.png │ │ │ └── cppcheck-48.png │ │ └── help.html │ └── java │ │ ├── org │ │ └── jenkinsci │ │ │ └── plugins │ │ │ └── cppcheck │ │ │ ├── util │ │ │ ├── CppcheckLogger.java │ │ │ ├── CppcheckMetricUtil.java │ │ │ ├── AbstractCppcheckProjectAction.java │ │ │ ├── CppcheckBuildHealthEvaluator.java │ │ │ └── CppcheckBuildResultEvaluator.java │ │ │ ├── CppcheckDiffState.java │ │ │ ├── CppcheckTablePortlet.java │ │ │ ├── config │ │ │ ├── CppcheckConfig.java │ │ │ └── CppcheckConfigGraph.java │ │ │ ├── CppcheckSourceContainer.java │ │ │ ├── CppcheckStatistics.java │ │ │ ├── CppcheckBuildAction.java │ │ │ ├── CppcheckSourceAll.java │ │ │ └── CppcheckParserResult.java │ │ └── com │ │ └── thalesgroup │ │ └── hudson │ │ └── plugins │ │ └── cppcheck │ │ ├── CppcheckMetricUtil.java │ │ ├── exception │ │ └── CppcheckException.java │ │ ├── util │ │ ├── CppcheckLogger.java │ │ ├── AbstractCppcheckBuildAction.java │ │ ├── AbstractCppcheckProjectAction.java │ │ ├── CppcheckBuildHealthEvaluator.java │ │ ├── CppcheckUtil.java │ │ └── CppcheckBuildResultEvaluator.java │ │ ├── CppcheckHealthReportThresholds.java │ │ ├── CppcheckPublisher.java │ │ ├── CppcheckAreaRenderer.java │ │ ├── CppcheckSummary.java │ │ ├── config │ │ └── CppcheckConfigGraph.java │ │ ├── model │ │ ├── CppcheckSourceContainer.java │ │ ├── CppcheckWorkspaceFile.java │ │ └── CppcheckFile.java │ │ └── CppcheckProjectAction.java ├── test │ ├── resources │ │ ├── com │ │ │ └── thalesgroup │ │ │ │ └── hudson │ │ │ │ └── plugins │ │ │ │ └── cppcheck │ │ │ │ ├── testcppcheck-part1.xml │ │ │ │ ├── testcppcheck-part2.xml │ │ │ │ ├── testcppcheck.cpp │ │ │ │ ├── testcppcheck1.xml │ │ │ │ └── testcppcheck2.xml │ │ └── org │ │ │ └── jenkinsci │ │ │ └── plugins │ │ │ └── cppcheck │ │ │ └── version2 │ │ │ └── testCppcheck.xml │ └── java │ │ ├── com │ │ └── thalesgroup │ │ │ └── hudson │ │ │ └── plugins │ │ │ └── cppcheck │ │ │ ├── AbstractWorkspaceTest.java │ │ │ ├── CppcheckParserResultTest.java │ │ │ ├── CppcheckBuildHealthEvaluatorTest.java │ │ │ └── CppcheckSummaryTest.java │ │ └── org │ │ └── jenkinsci │ │ └── plugins │ │ └── cppcheck │ │ └── CppcheckParserTest.java └── it │ ├── resources │ └── com │ │ └── thalesgroup │ │ └── hudson │ │ └── plugins │ │ └── cppcheck │ │ ├── testcppcheck1.xml │ │ └── testcppcheck2.xml │ └── java │ └── com │ └── thalesgroup │ └── hudson │ └── plugins │ └── cppcheck │ ├── MultiFileSCM.java │ └── CppcheckPublisherTest.java ├── .github ├── CODEOWNERS ├── release-drafter.yml ├── dependabot.yml └── workflows │ ├── release-drafter.yml │ └── jenkins-security-scan.yml ├── .mvn ├── maven.config └── extensions.xml ├── docs └── images │ └── 1.15_config.png ├── Jenkinsfile └── .gitignore /src/main/resources/util/taglib: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/resources/jelly/cppcheck/taglib: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @jenkinsci/cppcheck-plugin-developers 2 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -Pconsume-incrementals 2 | -Pmight-produce-incrementals 3 | -------------------------------------------------------------------------------- /docs/images/1.15_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/cppcheck-plugin/HEAD/docs/images/1.15_config.png -------------------------------------------------------------------------------- /src/main/resources/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource/index.properties: -------------------------------------------------------------------------------- 1 | sourcedetail.header=Content of file {0} -------------------------------------------------------------------------------- /src/main/webapp/icons/cppcheck-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/cppcheck-plugin/HEAD/src/main/webapp/icons/cppcheck-24.png -------------------------------------------------------------------------------- /src/main/webapp/icons/cppcheck-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/cppcheck-plugin/HEAD/src/main/webapp/icons/cppcheck-32.png -------------------------------------------------------------------------------- /src/main/webapp/icons/cppcheck-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/cppcheck-plugin/HEAD/src/main/webapp/icons/cppcheck-48.png -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc 2 | _extends: .github 3 | tag-template: cppcheck-$NEXT_MINOR_VERSION 4 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | buildPlugin(useContainerAgent: true, configurations: [ 2 | [ platform: 'linux', jdk: '8' ], 3 | [ platform: 'linux', jdk: '11' ], 4 | [ platform: 'windows', jdk: '11' ], 5 | ]) 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | 3 | # mvn hpi:run 4 | work 5 | 6 | # IntelliJ IDEA project files 7 | *.iml 8 | *.iws 9 | *.ipr 10 | .idea 11 | 12 | # Eclipse project files 13 | .settings 14 | .classpath 15 | .project 16 | -------------------------------------------------------------------------------- /src/main/resources/index.jelly: -------------------------------------------------------------------------------- 1 | 2 |
8 | ${%The current user must have the WORKSPACE permission for the job.} 9 |
10 |8 | ${%This plugin will not report Cppcheck result until there is at least one success or unstable build.} 9 |
10 |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 |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 | -------------------------------------------------------------------------------- /.github/workflows/jenkins-security-scan.yml: -------------------------------------------------------------------------------- 1 | # Jenkins Security Scan 2 | # For more information, see: https://www.jenkins.io/doc/developer/security/scan/ 3 | 4 | name: Jenkins Security Scan 5 | 6 | on: 7 | push: 8 | branches: 9 | - master 10 | pull_request: 11 | types: [opened, synchronize, reopened] 12 | workflow_dispatch: 13 | 14 | permissions: 15 | security-events: write 16 | contents: read 17 | actions: read 18 | 19 | jobs: 20 | security-scan: 21 | uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2 22 | with: 23 | java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate. 24 | # java-version: 21 # Optionally specify what version of Java to set up for the build, or remove to use a recent default. 25 | -------------------------------------------------------------------------------- /src/main/resources/jelly/cppcheck/format.jelly: -------------------------------------------------------------------------------- 1 | 2 |${stat.versions}
17 |32 | ${%The current user must have the WORKSPACE permission for the job.} 33 |
34 |32 | ${%This plugin will not report Cppcheck result until there is at least one success or unstable build.} 33 |
34 || ${%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 |
| Filename | 33 |LineNumber | 34 |CppCheckId | 35 |Severity | 36 |Message | 37 |
|
44 | |
53 |
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 |
${%The result set is empty.}
29 |${file.cppcheckFile.verboseHtml}
67 |
71 | ${it.getSourceCode(file)}
72 |
73 | 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/util/CppcheckBuildHealthEvaluator.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.util;
25 |
26 | import org.jenkinsci.plugins.cppcheck.Messages;
27 |
28 | import com.thalesgroup.hudson.plugins.cppcheck.CppcheckMetricUtil;
29 | import com.thalesgroup.hudson.plugins.cppcheck.config.CppcheckConfig;
30 |
31 | import hudson.model.HealthReport;
32 |
33 | public class CppcheckBuildHealthEvaluator {
34 |
35 | public HealthReport evaluatBuildHealth(CppcheckConfig cppcheckConfig, int nbErrorForSeverity) {
36 |
37 | if (cppcheckConfig == null) {
38 | // no thresholds => no report
39 | return null;
40 | }
41 |
42 | if (isHealthyReportEnabled(cppcheckConfig)) {
43 | int percentage;
44 |
45 | if (nbErrorForSeverity < CppcheckMetricUtil.convert(cppcheckConfig.getConfigSeverityEvaluation().getHealthy())) {
46 | percentage = 100;
47 | } else if (nbErrorForSeverity > CppcheckMetricUtil.convert(cppcheckConfig.getConfigSeverityEvaluation().getUnHealthy())) {
48 | percentage = 0;
49 | } else {
50 | percentage = 100 - ((nbErrorForSeverity - CppcheckMetricUtil.convert(cppcheckConfig.getConfigSeverityEvaluation().getHealthy())) * 100
51 | / (CppcheckMetricUtil.convert(cppcheckConfig.getConfigSeverityEvaluation().getUnHealthy()) - CppcheckMetricUtil.convert(cppcheckConfig.getConfigSeverityEvaluation().getHealthy())));
52 | }
53 |
54 | return new HealthReport(percentage, Messages.cppcheck_BuildHealthEvaluatorDescription(CppcheckMetricUtil.getMessageSelectedSeverties(cppcheckConfig)));
55 | }
56 | return null;
57 | }
58 |
59 |
60 | private boolean isHealthyReportEnabled(CppcheckConfig cppcheckconfig) {
61 | if (CppcheckMetricUtil.isValid(cppcheckconfig.getConfigSeverityEvaluation().getHealthy()) && CppcheckMetricUtil.isValid(cppcheckconfig.getConfigSeverityEvaluation().getUnHealthy())) {
62 | int healthyNumber = CppcheckMetricUtil.convert(cppcheckconfig.getConfigSeverityEvaluation().getHealthy());
63 | int unHealthyNumber = CppcheckMetricUtil.convert(cppcheckconfig.getConfigSeverityEvaluation().getUnHealthy());
64 | return unHealthyNumber > healthyNumber;
65 | }
66 | return false;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSummary.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 | public class CppcheckSummary {
27 |
28 | private CppcheckSummary() {
29 | }
30 |
31 |
32 | /**
33 | * Creates an HTML Cppcheck summary.
34 | *
35 | * @param result the cppcheck result object
36 | * @return the HTML fragment representing the cppcheck report summary
37 | */
38 | public static String createReportSummary(CppcheckResult result) {
39 |
40 | StringBuilder summary = new StringBuilder();
41 | int nbErrors = result.getReport().getNumberTotal();
42 |
43 | summary.append(Messages.cppcheck_Errors_ProjectAction_Name());
44 | summary.append(": ");
45 | if (nbErrors == 0) {
46 | summary.append(Messages.cppcheck_ResultAction_NoError());
47 | } else {
48 | summary.append("");
49 |
50 | if (nbErrors == 1) {
51 | summary.append(Messages.cppcheck_ResultAction_OneError());
52 | } else {
53 | summary.append(Messages.cppcheck_ResultAction_MultipleErrors(nbErrors));
54 | }
55 | summary.append("");
56 | }
57 | summary.append(".");
58 |
59 | return summary.toString();
60 | }
61 |
62 |
63 | /**
64 | * Creates an HTML Cppcheck detailed summary.
65 | *
66 | * @param result the cppcheck result object
67 | * @return the HTML fragment representing the cppcheck report details summary
68 | */
69 | public static String createReportSummaryDetails(CppcheckResult result) {
70 |
71 | StringBuilder builder = new StringBuilder();
72 | int nbNewErrors = result.getNumberNewErrorsFromPreviousBuild();
73 |
74 | builder.append("| 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 |
| ${%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 |