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