Check C/C++ files for coding-standard violations
check_filesRuns clang-tidy, cppcheck and Clang Static Analyzer on a C/C++ file or directory, mapping every finding to SEI CERT, MISRA or AUTOSAR rule IDs for whole-file audits.
Instructions
Run clang-tidy, the Clang Static Analyzer and cppcheck (plus Semgrep and Infer when installed, CodeQL on request; see tools) on a C/C++ file or a directory (recursive) and return every finding mapped to SEI CERT rule IDs, or to MISRA C:2012 / MISRA C++:2023 / AUTOSAR C++14 IDs when standards (or the profile) selects them; MISRA C adds the cppcheck MISRA addon on .c files. Use for whole-file or whole-tree audits; for a change set use check_diff, which keeps only changed lines. Runs the analyzers as local subprocesses (4 in parallel, 300 s timeout per file and tool) and writes no files. Takes under a second per small file but minutes for large trees. Pass compdb when the project has a compilation database; without it flags are guessed and project headers are often missing. A tools[].status of 'partial' or non-empty warnings means some files did not compile or timed out, so an empty result is not proof. With baseline_path, findings already in the baseline are hidden and baseline reports new, baselined and fixed counts.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>"
},
"name": "check_files"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lang | No | Analyse only .c files (c) or only C++ files (cpp). | any |
| path | Yes | Absolute path of a C/C++ file or a directory to scan recursively. Files are picked by the profile's extensions and exclude_paths. | |
| root | No | Absolute project root: adds root/src, root/include and similar as include paths, enables compdb auto-detection, and is the base for the profile's path globs. | |
| tools | No | Analyzers to run; omit for the default set: clang-tidy, clangsa and cppcheck plus semgrep and infer when installed. clang-tidy = cert-*/bugprone checks plus Clang Static Analyzer checks; clangsa = standalone `clang --analyze` (adds alpha checkers); cppcheck = cppcheck; semgrep = the bundled CERT pattern rules; infer = Infer (null, leak, use-after-free, overflow, race); codeql = the CodeQL CERT query packs, opt-in because each run builds a database (tens of seconds or more). A requested analyzer that is not installed is skipped and listed in `warnings`. | |
| compdb | No | Absolute path of the directory that contains compile_commands.json. Strongly recommended: without it files are compiled with guessed flags and often fail to parse. Omitted: auto-detected in root, root/build or root/build-clang. | |
| profile | No | Review profile: 'default' (plain SEI CERT), 'ceph' (Ceph severities, suppressions and idioms), 'misra' (MISRA C:2012 + MISRA C++:2023), 'autosar' (AUTOSAR C++14) or an absolute path to a profile .yaml file. | default |
| standards | No | Standards to map findings to, overriding the profile's `standards` (default profile: cert). misra-c-2012 applies to .c files (adds the cppcheck MISRA addon); misra-cpp-2023 and autosar-cpp14 to C++ files. Example: ["cert", "misra"]. | |
| baseline_path | No | Absolute path of a baseline JSON written by `cert-review baseline create`. Findings recorded there are left out and counted in `baseline`; file paths in it are relative to its directory. Matching uses rule, file and hashes of the code line and its neighbours, so line shifts do not resurface old findings. Omit to report everything. | |
| min_confidence | No | Drop findings below this confidence. Rule-specific checkers score 0.9, general checkers 0.3-0.65, +0.1 when two tools agree. 0.5 keeps most real hits. | |
| include_suppressed | No | Also return findings hidden by the profile or by `// cert-review: ignore <RULE>` comments, each with its suppression reason (for audits). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | Yes | Files analysed (absolute paths). | |
| notes | Yes | Engine notes, e.g. 'no C/C++ files selected'. | |
| tools | Yes | Per analyzer: tool, available, version, files, raw_findings, parse_errors, files_with_errors[], timed_out[], notes[], status ('ok' | 'partial' = some files did not compile or timed out | 'missing'). | |
| profile | Yes | Profile used. | |
| summary | Yes | total, by_severity {error, warning, note}, top_rules [[rule_id, count], ...]. Counts only findings left after the baseline filter. | |
| baseline | No | Present only with baseline_path: path, entries (in the file), new (findings returned), baselined (findings hidden because they match an entry), fixed (entries in analysed files with no matching finding; null for check_diff, which sees only changed lines), fixed_entries[] (up to 50 {rule_id, file, line, message}) and note. | |
| findings | Yes | Sorted by severity, priority, confidence. Each also has lang, col, priority, level, tool, checker, title, cert_severity, also_found_by[], note, url. | |
| warnings | Yes | One line per analyzer that could not fully analyse its input (compile errors or timeouts); non-empty means the result is incomplete. | |
| suppressed_count | Yes | Findings hidden by the profile or inline ignores. |