@codacy/tools-cppcheck-2
v0.2.1
Published
Cppcheck adapter — CLI-mode C/C++ static analyzer
Readme
@codacy/tools-cppcheck-2
Table of Contents
Overview
C/C++ static analyzer using the Cppcheck binary. Uses the CLI execution strategy — spawns cppcheck via spawnTool() and parses its XML output.
| Property | Value |
|----------|-------|
| Tool ID | cppcheck |
| Codacy UUID | 02eb6a1c-757f-4324-81bf-094835a1578b |
| Strategy | CLI |
| Languages | C, C++ |
| Binary | cppcheck |
| File patterns | **/*.c, **/*.cpp, **/*.cc, **/*.cxx, **/*.h, **/*.hpp, **/*.hh |
| Pattern count | ~420 |
| Extra dependency | fast-xml-parser (for XML output parsing) |
Updating patterns
# Re-fetch pattern metadata from the Codacy API
pnpm prefetch
# Commit the result
git add src/patterns.jsonPattern IDs follow the format cppcheck_nullPointer, cppcheck_unusedVariable, etc.
Updating the Cppcheck version
- Update
preferredVersioninsrc/adapter.ts - Run
pnpm prefetchto check for new/removed rules - Run
pnpm testto verify compatibility - If the major version changes, create a new adapter package (
cppcheck-3/)
Development
pnpm build # Build with tsup
pnpm test # Run tests (requires cppcheck in PATH)Cppcheck must be installed manually — the adapter's install() returns NotSupported. Install via your system package manager:
# macOS
brew install cppcheck
# Ubuntu/Debian
apt-get install cppcheck
# Fedora
dnf install cppcheckNotes for maintainers
- Cppcheck outputs XML to stderr (not stdout). The adapter captures stderr and parses it with
fast-xml-parser. - The
--xmlflag enables XML output;--enable=allactivates all checkers. --error-exitcode=0prevents non-zero exit codes on findings.--inline-supprrespects inline suppression comments.--forcechecks all configurations even if#ifdefbranches are present.unusedFunctionis suppressed via--suppress=unusedFunction(too noisy for single-file analysis).- Automated installation is not supported — Cppcheck doesn't provide pre-built binaries for all platforms on GitHub releases.
