Cppcheck
$ cppcheck Community Low RiskOffline static analyzer for C and C++ codebases targeting undefined behavior, null dereferences, memory leaks, and out-of-bounds access. Supports --enable=all, --project=compile_commands.json, and --xml structured diagnostics.
brew install cppcheck Runs local C/C++ dataflow analysis directly against workspace sources or compile_commands.json.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Supports --xml --xml-version=2, --quiet, and --error-exitcode, but lacks native JSON and writes XML to stderr.
--xml-version=2emits structured XML to stderr rather than stdout JSON- Requires
--error-exitcode=1to fail on findings
Strictly read-only static analyzer; never compiles or executes inspected C/C++ code.
- Zero source modification and zero code execution
Available via Homebrew, Linux distro packages, and Windows installers, though accurate C++ scans rely on compile_commands.json.
- Cross-platform native binary via
brewand OS package managers
Catches real UB and resource leaks in C/C++, though --enable=all can be noisy without suppressions.
- Supports
--project=compile_commands.jsonand targeted check categories
Long-lived community open-source project (cppcheck-opensource/cppcheck) with steady releases.
- Maintained at
cppcheck-opensource/cppcheckunder GPL-3.0
Functional manual at cppcheck.sourceforge.io and detailed --help output.
- Official HTML manual and CLI
--help
Security, Auth & Guardrails
Offline local static analyzer; no credentials stored or required.
GPL-3.0 open-source CLI; free to run locally.
# Cppcheck Agent Rules - Always pass `--quiet` and `--error-exitcode=1` when gating builds. - Prefer `--project=compile_commands.json` over raw folder scans to minimize missing-include false positives.
Agent-Ready Command Recipes
Safe Read-Only Queries
cppcheck --project=build/compile_commands.json --enable=warning,performance,portability --xml --xml-version=2 2> cppcheck.xml
Analyzes translation units using exact compiler flags and writes structured XML v2 diagnostics.
cppcheck --enable=warning,style --error-exitcode=1 --quiet src/
Suppresses progress noise with --quiet and fails with exit code 1 when issues are found.
Strengths for Agents
- + 100% read-only C/C++ UB, memory-leak, and bounds analysis without executing target code.
- +
--project=compile_commands.jsonreuses exact build flags for higher precision.
Caveats & Pitfalls
- ! No native
--jsonflag;--xmlwrites diagnostics to stderr instead of stdout. - ! Running
--enable=allwithout suppressions produces verbose style and missingInclude noise.