I integrate cppcheck
analysis with CMake by specifying this command line:
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_CPPCHECK="cppcheck;--enable=all;--suppress=missingIncludeSystem;--inline-suppr;--std=c++17;--error-exitcode=1"
and works well.
After upgrading my Ubuntu, with cppcheck
version 2.13.0, I started seeing this extra message/warning:
...
[89/108] Building CXX object include/boost/multi/adaptors/fftw/test/CMakeFiles/combinations.cpp.x.dir/combinations.cpp.o
Checking /home/user/boost-multi/include/boost/multi/adaptors/fftw/test/combinations.cpp ...
nofile:0:0: information: Active checkers: 4/592 (use --checkers-report=<filename> to see details) [checkersReport]
...
For every target!
What is the meaning of this message "Active checkers: 4/592"? Why 4
?
The help says,
$ cppcheck --help
...
--checkers-report=<file>
Write a report of all the active checkers to the given file.
...
But it doesn't help me understand.
When I add the option --checkers-report=cppcheck.report
, I get the following file
$ cat ./.build.g++.plus/cppcheck.report
Critical errors
---------------
No critical errors, all files were checked.
Important: Analysis is still not guaranteed to be 'complete' it is possible there are false negatives.
Open source checkers
--------------------
No Check64BitPortability::pointerassignment require:portability
No CheckAssert::assertWithSideEffects require:warning
No CheckAutoVariables::assignFunctionArg require:style,warning
No CheckAutoVariables::autoVariables
No CheckAutoVariables::checkVarLifetime
No CheckBool::checkAssignBoolToFloat require:style,c++
No CheckBool::checkAssignBoolToPointer
No CheckBool::checkBitwiseOnBoolean require:style,inconclusive
No CheckBool::checkComparisonOfBoolExpressionWithInt require:warning
No CheckBool::checkComparisonOfBoolWithBool require:style,c++
No CheckBool::checkComparisonOfBoolWithInt require:warning,c++
No CheckBool::checkComparisonOfFuncReturningBool require:style,c++
No CheckBool::checkIncrementBoolean require:style
No CheckBool::pointerArithBool
No CheckBool::returnValueOfFunctionReturningBool require:style
No CheckBoost::checkBoostForeachModification
Yes CheckBufferOverrun::analyseWholeProgram
No CheckBufferOverrun::argumentSize require:warning
No CheckBufferOverrun::arrayIndex
No CheckBufferOverrun::arrayIndexThenCheck
No CheckBufferOverrun::bufferOverflow
No CheckBufferOverrun::negativeArraySize
No CheckBufferOverrun::objectIndex
No CheckBufferOverrun::pointerArithmetic require:portability
No CheckBufferOverrun::stringNotZeroTerminated require:warning,inconclusive
Yes CheckClass::analyseWholeProgram
No CheckClass::checkConst require:style,inconclusive
No CheckClass::checkConstructors require:style,warning
No CheckClass::checkCopyConstructors require:warning
No CheckClass::checkDuplInheritedMembers require:warning
No CheckClass::checkExplicitConstructors require:style
No CheckClass::checkMemset
No CheckClass::checkMissingOverride require:style,c++03
No CheckClass::checkSelfInitialization
No CheckClass::checkThisUseAfterFree require:warning
No CheckClass::checkUnsafeClassRefMember require:warning,safeChecks
No CheckClass::checkUselessOverride require:style
No CheckClass::checkVirtualFunctionCallInConstructor require:warning
No CheckClass::initializationListUsage require:performance
No CheckClass::initializerListOrder require:style,inconclusive
No CheckClass::operatorEqRetRefThis require:style
No CheckClass::operatorEqToSelf require:warning
No CheckClass::privateFunctions require:style
No CheckClass::thisSubtraction require:warning
No CheckClass::virtualDestructor
No CheckCondition::alwaysTrueFalse require:style
No CheckCondition::assignIf require:style
No CheckCondition::checkAssignmentInCondition require:style
No CheckCondition::checkBadBitmaskCheck require:style
No CheckCondition::checkCompareValueOutOfTypeRange require:style,platform
No CheckCondition::checkDuplicateConditionalAssign require:style
No CheckCondition::checkIncorrectLogicOperator require:style,warning
No CheckCondition::checkInvalidTestForOverflow require:warning
No CheckCondition::checkModuloAlwaysTrueFalse require:warning
No CheckCondition::checkPointerAdditionResultNotNull require:warning
No CheckCondition::clarifyCondition require:style
No CheckCondition::comparison require:style
No CheckCondition::duplicateCondition require:style
No CheckCondition::multiCondition require:style
No CheckCondition::multiCondition2 require:warning
No CheckExceptionSafety::checkCatchExceptionByValue require:style
No CheckExceptionSafety::checkRethrowCopy require:style
No CheckExceptionSafety::deallocThrow require:warning
No CheckExceptionSafety::destructors require:warning
No CheckExceptionSafety::nothrowThrows
No CheckExceptionSafety::rethrowNoCurrentException
No CheckExceptionSafety::unhandledExceptionSpecification require:style,inconclusive
No CheckFunctions::checkIgnoredReturnValue require:style,warning
No CheckFunctions::checkMathFunctions require:style,warning,c99,c++11
No CheckFunctions::checkMissingReturn
No CheckFunctions::checkProhibitedFunctions
No CheckFunctions::invalidFunctionUsage
No CheckFunctions::memsetInvalid2ndParam require:warning,portability
No CheckFunctions::memsetZeroBytes require:warning
No CheckFunctions::returnLocalStdMove require:performance,c++11
No CheckFunctions::useStandardLibrary require:style
No CheckIO::checkCoutCerrMisusage require:c
No CheckIO::checkFileUsage
No CheckIO::checkWrongPrintfScanfArguments
No CheckLeakAutoVar::check require:notclang
No CheckMemoryLeakInClass::check
No CheckMemoryLeakInFunction::checkReallocUsage
No CheckMemoryLeakNoVar::check
No CheckMemoryLeakStructMember::check
Yes CheckNullPointer::analyseWholeProgram
No CheckNullPointer::arithmetic
No CheckNullPointer::nullConstantDereference
No CheckNullPointer::nullPointer
No CheckOther::checkAccessOfMovedVariable require:c++11,warning
No CheckOther::checkCastIntToCharAndBack require:warning
No CheckOther::checkCharVariable require:warning,portability
No CheckOther::checkComparePointers
No CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse require:warning
No CheckOther::checkConstPointer require:style
No CheckOther::checkDuplicateBranch require:style,inconclusive
No CheckOther::checkDuplicateExpression require:style,warning
No CheckOther::checkEvaluationOrder require:C/C++03
No CheckOther::checkFuncArgNamesDifferent require:style,warning,inconclusive
No CheckOther::checkIncompleteArrayFill require:warning,portability,inconclusive
No CheckOther::checkIncompleteStatement require:warning
No CheckOther::checkInterlockedDecrement require:windows-platform
No CheckOther::checkInvalidFree
No CheckOther::checkKnownArgument require:style
No CheckOther::checkKnownPointerToBool require:style
No CheckOther::checkMisusedScopedObject require:style,c++
No CheckOther::checkModuloOfOne require:style
No CheckOther::checkNanInArithmeticExpression require:style
No CheckOther::checkNegativeBitwiseShift
No CheckOther::checkOverlappingWrite
No CheckOther::checkPassByReference require:performance,c++
No CheckOther::checkRedundantAssignment require:style
No CheckOther::checkRedundantCopy require:c++,performance,inconclusive
No CheckOther::checkRedundantPointerOp require:style
No CheckOther::checkShadowVariables require:style
No CheckOther::checkSignOfUnsignedVariable require:style
No CheckOther::checkSuspiciousCaseInSwitch require:warning,inconclusive
No CheckOther::checkSuspiciousSemicolon require:warning,inconclusive
No CheckOther::checkUnreachableCode require:style
No CheckOther::checkUnusedLabel require:style,warning
No CheckOther::checkVarFuncNullUB require:portability
No CheckOther::checkVariableScope require:style,notclang
No CheckOther::checkZeroDivision
No CheckOther::clarifyCalculation require:style
No CheckOther::clarifyStatement require:warning
No CheckOther::invalidPointerCast require:portability
No CheckOther::redundantBitwiseOperationInSwitch require:warning
No CheckOther::warningOldStylePointerCast require:style,c++
No CheckPostfixOperator::postfixOperator require:performance
No CheckSizeof::checkSizeofForArrayParameter require:warning
No CheckSizeof::checkSizeofForNumericParameter require:warning
No CheckSizeof::checkSizeofForPointerSize require:warning
No CheckSizeof::sizeofCalculation require:warning
No CheckSizeof::sizeofFunction require:warning
No CheckSizeof::sizeofVoid require:portability
No CheckSizeof::sizeofsizeof require:warning
No CheckSizeof::suspiciousSizeofCalculation require:warning,inconclusive
No CheckStl::checkDereferenceInvalidIterator require:warning
No CheckStl::checkDereferenceInvalidIterator2
No CheckStl::checkFindInsert require:performance
No CheckStl::checkMutexes require:warning
No CheckStl::erase
No CheckStl::if_find require:warning,performance
No CheckStl::invalidContainer
No CheckStl::iterators
No CheckStl::knownEmptyContainer require:style
No CheckStl::misMatchingContainerIterator
No CheckStl::misMatchingContainers
No CheckStl::missingComparison require:warning
No CheckStl::negativeIndex
No CheckStl::outOfBounds
No CheckStl::outOfBoundsIndexExpression
No CheckStl::redundantCondition require:style
No CheckStl::size require:performance,c++03
No CheckStl::stlBoundaries
No CheckStl::stlOutOfBounds
No CheckStl::string_c_str
No CheckStl::useStlAlgorithm require:style
No CheckStl::uselessCalls require:performance,warning
No CheckString::checkAlwaysTrueOrFalseStringCompare require:warning
No CheckString::checkIncorrectStringCompare require:warning
No CheckString::checkSuspiciousStringCompare require:warning
No CheckString::overlappingStrcmp require:warning
No CheckString::sprintfOverlappingData
No CheckString::strPlusChar
No CheckString::stringLiteralWrite
No CheckType::checkFloatToIntegerOverflow
No CheckType::checkIntegerOverflow require:platform
No CheckType::checkLongCast require:style
No CheckType::checkSignConversion require:warning
No CheckType::checkTooBigBitwiseShift require:platform
No CheckUninitVar::check
No CheckUninitVar::valueFlowUninit
Yes CheckUnusedFunctions::analyseWholeProgram
No CheckUnusedVar::checkFunctionVariableUsage require:style
No CheckUnusedVar::checkStructMemberUsage require:style
No CheckVaarg::va_list_usage require:notclang
No CheckVaarg::va_start_argument
Premium checkers
----------------
Not available, Cppcheck Premium is not used
Autosar
-------
Not available, Cppcheck Premium is not used
Cert C
------
Not available, Cppcheck Premium is not used
Cert C++
--------
Not available, Cppcheck Premium is not used
Misra C
-------
Misra is not enabled
Misra C++ 2008
--------------
Not available, Cppcheck Premium is not used
EDIT August 2024:
When I run cppcheck separately
$ cmake -G Ninja .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
$ cmake --build . --parallel
$ cppcheck --project=compile_commands.json --enable=all --suppress=missingIncludeSystem --checkers-report=cppcheck.report --suppress=checkersReport --inline-suppr --std=c++17 --error-exitcode=1 -j 40
I get this (mostly yes):
$ cat cppcheck.report
Critical errors
---------------
No critical errors, all files were checked.
Important: Analysis is still not guaranteed to be 'complete' it is possible there are false negatives.
Open source checkers
--------------------
Yes Check64BitPortability::pointerassignment
Yes CheckAssert::assertWithSideEffects
Yes CheckAutoVariables::assignFunctionArg
Yes CheckAutoVariables::autoVariables
Yes CheckAutoVariables::checkVarLifetime
Yes CheckBool::checkAssignBoolToFloat
Yes CheckBool::checkAssignBoolToPointer
No CheckBool::checkBitwiseOnBoolean require:style,inconclusive
Yes CheckBool::checkComparisonOfBoolExpressionWithInt
Yes CheckBool::checkComparisonOfBoolWithBool
Yes CheckBool::checkComparisonOfBoolWithInt
Yes CheckBool::checkComparisonOfFuncReturningBool
Yes CheckBool::checkIncrementBoolean
Yes CheckBool::pointerArithBool
Yes CheckBool::returnValueOfFunctionReturningBool
Yes CheckBoost::checkBoostForeachModification
No CheckBufferOverrun::analyseWholeProgram
Yes CheckBufferOverrun::argumentSize
Yes CheckBufferOverrun::arrayIndex
Yes CheckBufferOverrun::arrayIndexThenCheck
Yes CheckBufferOverrun::bufferOverflow
Yes CheckBufferOverrun::negativeArraySize
Yes CheckBufferOverrun::objectIndex
Yes CheckBufferOverrun::pointerArithmetic
No CheckBufferOverrun::stringNotZeroTerminated require:warning,inconclusive
No CheckClass::analyseWholeProgram
No CheckClass::checkConst require:style,inconclusive
Yes CheckClass::checkConstructors
Yes CheckClass::checkCopyConstructors
Yes CheckClass::checkDuplInheritedMembers
Yes CheckClass::checkExplicitConstructors
Yes CheckClass::checkMemset
Yes CheckClass::checkMissingOverride
Yes CheckClass::checkReturnByReference
Yes CheckClass::checkSelfInitialization
Yes CheckClass::checkThisUseAfterFree
No CheckClass::checkUnsafeClassRefMember require:warning,safeChecks
Yes CheckClass::checkUselessOverride
Yes CheckClass::checkVirtualFunctionCallInConstructor
Yes CheckClass::initializationListUsage
No CheckClass::initializerListOrder require:style,inconclusive
Yes CheckClass::operatorEqRetRefThis
Yes CheckClass::operatorEqToSelf
Yes CheckClass::privateFunctions
Yes CheckClass::thisSubtraction
Yes CheckClass::virtualDestructor
Yes CheckCondition::alwaysTrueFalse
Yes CheckCondition::assignIf
Yes CheckCondition::checkAssignmentInCondition
Yes CheckCondition::checkBadBitmaskCheck
No CheckCondition::checkCompareValueOutOfTypeRange require:style,platform
Yes CheckCondition::checkDuplicateConditionalAssign
Yes CheckCondition::checkIncorrectLogicOperator
Yes CheckCondition::checkInvalidTestForOverflow
Yes CheckCondition::checkModuloAlwaysTrueFalse
Yes CheckCondition::checkPointerAdditionResultNotNull
Yes CheckCondition::clarifyCondition
Yes CheckCondition::comparison
Yes CheckCondition::duplicateCondition
Yes CheckCondition::multiCondition
Yes CheckCondition::multiCondition2
Yes CheckExceptionSafety::checkCatchExceptionByValue
Yes CheckExceptionSafety::checkRethrowCopy
Yes CheckExceptionSafety::deallocThrow
Yes CheckExceptionSafety::destructors
Yes CheckExceptionSafety::nothrowThrows
Yes CheckExceptionSafety::rethrowNoCurrentException
No CheckExceptionSafety::unhandledExceptionSpecification require:style,inconclusive
Yes CheckFunctions::checkIgnoredReturnValue
Yes CheckFunctions::checkMathFunctions
Yes CheckFunctions::checkMissingReturn
Yes CheckFunctions::checkProhibitedFunctions
Yes CheckFunctions::invalidFunctionUsage
Yes CheckFunctions::memsetInvalid2ndParam
Yes CheckFunctions::memsetZeroBytes
Yes CheckFunctions::returnLocalStdMove
Yes CheckFunctions::useStandardLibrary
Yes CheckIO::checkCoutCerrMisusage
Yes CheckIO::checkFileUsage
Yes CheckIO::checkWrongPrintfScanfArguments
Yes CheckIO::invalidScanf
Yes CheckLeakAutoVar::check
Yes CheckMemoryLeakInClass::check
Yes CheckMemoryLeakInFunction::checkReallocUsage
Yes CheckMemoryLeakNoVar::check
No CheckMemoryLeakNoVar::checkForUnsafeArgAlloc
Yes CheckMemoryLeakStructMember::check
No CheckNullPointer::analyseWholeProgram require:unusedfunctions
Yes CheckNullPointer::arithmetic
Yes CheckNullPointer::nullConstantDereference
Yes CheckNullPointer::nullPointer
Yes CheckOther::checkAccessOfMovedVariable
Yes CheckOther::checkCastIntToCharAndBack
Yes CheckOther::checkCharVariable
Yes CheckOther::checkComparePointers
Yes CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse
Yes CheckOther::checkConstPointer
Yes CheckOther::checkConstVariable
No CheckOther::checkDuplicateBranch require:style,inconclusive
Yes CheckOther::checkDuplicateExpression
Yes CheckOther::checkEvaluationOrder
Yes CheckOther::checkFuncArgNamesDifferent
No CheckOther::checkIncompleteArrayFill require:warning,portability,inconclusive
Yes CheckOther::checkIncompleteStatement
No CheckOther::checkInterlockedDecrement require:windows-platform
Yes CheckOther::checkInvalidFree
Yes CheckOther::checkKnownArgument
Yes CheckOther::checkKnownPointerToBool
Yes CheckOther::checkMisusedScopedObject
Yes CheckOther::checkModuloOfOne
Yes CheckOther::checkNanInArithmeticExpression
Yes CheckOther::checkNegativeBitwiseShift
Yes CheckOther::checkOverlappingWrite
Yes CheckOther::checkPassByReference
Yes CheckOther::checkRedundantAssignment
No CheckOther::checkRedundantCopy require:c++,performance,inconclusive
Yes CheckOther::checkRedundantPointerOp
Yes CheckOther::checkShadowVariables
Yes CheckOther::checkSignOfUnsignedVariable
No CheckOther::checkSuspiciousCaseInSwitch require:warning,inconclusive
No CheckOther::checkSuspiciousSemicolon require:warning,inconclusive
Yes CheckOther::checkUnreachableCode
Yes CheckOther::checkUnusedLabel
Yes CheckOther::checkVarFuncNullUB
Yes CheckOther::checkVariableScope
Yes CheckOther::checkZeroDivision
Yes CheckOther::clarifyCalculation
Yes CheckOther::clarifyStatement
Yes CheckOther::invalidPointerCast
Yes CheckOther::redundantBitwiseOperationInSwitch
Yes CheckOther::warningOldStylePointerCast
Yes CheckPostfixOperator::postfixOperator
Yes CheckSizeof::checkSizeofForArrayParameter
Yes CheckSizeof::checkSizeofForNumericParameter
Yes CheckSizeof::checkSizeofForPointerSize
Yes CheckSizeof::sizeofCalculation
Yes CheckSizeof::sizeofFunction
Yes CheckSizeof::sizeofVoid
Yes CheckSizeof::sizeofsizeof
No CheckSizeof::suspiciousSizeofCalculation require:warning,inconclusive
Yes CheckStl::checkDereferenceInvalidIterator
Yes CheckStl::checkDereferenceInvalidIterator2
Yes CheckStl::checkFindInsert
Yes CheckStl::checkMutexes
Yes CheckStl::erase
Yes CheckStl::eraseIteratorOutOfBounds
Yes CheckStl::if_find
Yes CheckStl::invalidContainer
Yes CheckStl::iterators
Yes CheckStl::knownEmptyContainer
Yes CheckStl::misMatchingContainerIterator
Yes CheckStl::misMatchingContainers
Yes CheckStl::missingComparison
Yes CheckStl::negativeIndex
Yes CheckStl::outOfBounds
Yes CheckStl::outOfBoundsIndexExpression
Yes CheckStl::redundantCondition
No CheckStl::size require:performance,c++03
Yes CheckStl::stlBoundaries
Yes CheckStl::stlOutOfBounds
Yes CheckStl::string_c_str
Yes CheckStl::useStlAlgorithm
Yes CheckStl::uselessCalls
Yes CheckString::checkAlwaysTrueOrFalseStringCompare
Yes CheckString::checkIncorrectStringCompare
Yes CheckString::checkSuspiciousStringCompare
Yes CheckString::overlappingStrcmp
Yes CheckString::sprintfOverlappingData
Yes CheckString::strPlusChar
Yes CheckString::stringLiteralWrite
Yes CheckType::checkFloatToIntegerOverflow
Yes CheckType::checkIntegerOverflow
Yes CheckType::checkLongCast
Yes CheckType::checkSignConversion
Yes CheckType::checkTooBigBitwiseShift
Yes CheckUninitVar::check
Yes CheckUninitVar::valueFlowUninit
No CheckUnusedFunctions::check require:unusedFunction
Yes CheckUnusedVar::checkFunctionVariableUsage
Yes CheckUnusedVar::checkStructMemberUsage
Yes CheckVaarg::va_list_usage
Yes CheckVaarg::va_start_argument
Premium checkers
----------------
Not available, Cppcheck Premium is not used
Autosar
-------
Not available, Cppcheck Premium is not used
Cert C
------
Not available, Cppcheck Premium is not used
Cert C++
--------
Not available, Cppcheck Premium is not used
Misra C
-------
Misra is not enabled
Misra C++ 2008
--------------
Not available, Cppcheck Premium is not used
Misra C++ 2023
--------------
Not available, Cppcheck Premium is not used
I am not an expert on Cppcheck, but I do use it regularly.
Your report file cppcheck.report
suggests certain checks were not enabled with the --enable=
flag. For example, you have a lot of require:style or require:warning checkers that you did not enable, like this one here No CheckStl::checkMutexes require:warning
.
From looking at the source code at https://cppcheck.sourceforge.io/devinfo/doxyoutput/cppcheckexecutor_8cpp_source.html
on line 344
is the message that gets printed out in this situation. The function creates the list of checkers you enable and generates a report.
Now, some of the issues are related to the premium version (e.g. checkers for MIRSA, Cert C & C++), so I guess it's their way to push the premium version of cppcheck. At the same time, there are checks like inconclusive
, which at least on my side causes my C++ compiler to complain about specific situations related to my code. The man pages for cppcheck also suggest that the --inconclusive flag can cause false positives. Therefore, I believe that this error is there to make us aware of all the features we are not using in cppcheck and that we as users need to verify whether or not we need those features.
One way to remove the error is to add checkersReport
to the --suppress=
flag so that it can be suppressed. I would advise you to keep the report file though so that you can manually scan it to ensure that all the checkers you wanted to use, have been used.