Jenkins common plug-in Cppcheck Plugin

Source: Internet
Author: User

Introduction to Tools

Cppcheck is a static code checking tool that supports C/s + + code, and as a supplement to the compiler, Cppcheck performs the following checks primarily on the source code:
1. Automatic variable checking
2. Bounds checking of arrays
3. Class Check
4. Expired function, obsolete function call check
5. Abnormal memory usage, release check
6. Memory leak check, mainly through memory reference pointers
7. Operating system Resource release check, interrupt, file descriptor, etc.
8. Exception STL function Use check
9. Code format error, and performance factor check

Basic use

Check individual files: Cppcheck file.c
Check folder: Cppcheck FilePath
Exclude a file or folder: Cppcheck-i src/file.c src

The following are the specific steps that the plugin uses in Jenkins:

First step: Cppcheck related software download and installation

    • Download the Cppcheck online
    • Download the Cppcheck plugin plugin online, download the file for CPPCHECK.HPI
    • Installing the Cppcheck tool
      1, into the/usr/local, decompression: TAR–ZXVF cppcheck-1.73.tar.gz
      2, enter/usr/local/cppcheck 1.73, compile: Make Cfgdir=/usr/local/cppcheck 1.73/cfg/
      3. Installation: Make install
      4, the configuration cppcheck environment variable, modifies/etc/profile as follows:
      New Cppcheck_home=/usr/local/cppcheck 1.73
      Append after path:$cppcheck_home
      Append after classpath: $CPPCHECK _home
      Run the Source/etc/profile command to make the new environment variable effective
    • Install Cppcheck plugin plugin in Jenkins, System Management –> plug-in management –> advanced upload CPPCHECK.HPI for installation

Step two: Specific configuration of the project

Cppcheck using examples

# minimum Set parameter settingCppcheck --XML --XML-version=2 source_directory 2>Cppcheck.XML# Check AllCppcheck --Enable=all --Inconclusive --XML --XML-version=2 source_directory 2>Cppcheck.XML# multithreaded Parallel parsing codeCppcheck -J 4 --Enable=all --Inconclusive --XML --XML-version=2 source_directory 2>Cppcheck.XML

Cppcheck Setup Instructions

problems encountered in the use
Question 1:cppcheck:failed to the load library configuration file ' std.cfg '. File not find
Detailed error message: Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled without cfgdir set. Either the STD.CFG should is available in CFG or the Cfgdir should is configured.
Cause: Cfgdir not specified at compile time
Workaround: Specify cfgdir at compile time, such as: Make Cfgdir=/usr/local/cppcheck 1.73/cfg/

Jenkins common plug-in Cppcheck Plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.