summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-11-07 14:04:58 +0700
committerhathach <[email protected]>2025-11-07 16:17:13 +0700
commit9fac6dd49d9cd681ed9140c124d3001b6d1491be (patch)
tree6975bedf03fc66361b10f843811064a54c9b4ff9 /.github
parent86a4990b96eafb5904f946fa061b310f155a7d51 (diff)
fix more alerts found by pvs-studio
Diffstat (limited to '.github')
-rw-r--r--.github/copilot-instructions.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
index 9982583cd..9f9ab7e72 100644
--- a/.github/copilot-instructions.md
+++ b/.github/copilot-instructions.md
@@ -88,6 +88,30 @@ python3 tools/build.py -b BOARD_NAME
- Check spelling: `pip install codespell && codespell` (uses `.codespellrc` config)
- Pre-commit hooks validate unit tests and code quality automatically
+### Static Analysis with PVS-Studio
+- **Analyze whole project**:
+ ```bash
+ pvs-studio-analyzer analyze -f examples/cmake-build-raspberry_pi_pico/compile_commands.json -R .PVS-Studio/.pvsconfig -o pvs-report.log -j12 --dump-files --misra-cpp-version 2008 --misra-c-version 2023 --use-old-parser
+ ```
+- **Analyze specific source files**:
+ ```bash
+ pvs-studio-analyzer analyze -f examples/cmake-build-raspberry_pi_pico/compile_commands.json -R .PVS-Studio/.pvsconfig -S path/to/file.c -o pvs-report.log -j12 --dump-files --misra-cpp-version 2008 --misra-c-version 2023 --use-old-parser
+ ```
+- **Multiple specific files**:
+ ```bash
+ pvs-studio-analyzer analyze -f examples/cmake-build-raspberry_pi_pico/compile_commands.json -R .PVS-Studio/.pvsconfig -S src/file1.c -S src/file2.c -o pvs-report.log -j12 --dump-files --misra-cpp-version 2008 --misra-c-version 2023 --use-old-parser
+ ```
+- Requires `compile_commands.json` in the build directory (generated by CMake with `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON`)
+- Use `-f` option to specify path to `compile_commands.json`
+- Use `-R .PVS-Studio/.pvsconfig` to specify rule configuration file
+- Use `-j12` for parallel analysis with 12 threads
+- `--dump-files` saves preprocessed files for debugging
+- `--misra-c-version 2023` enables MISRA C:2023 checks
+- `--misra-cpp-version 2008` enables MISRA C++:2008 checks
+- `--use-old-parser` uses legacy parser for compatibility
+- Analysis takes ~10-30 seconds depending on project size. Set timeout to 5+ minutes.
+- View results: `plog-converter -a GA:1,2 -t errorfile pvs-report.log` or open in PVS-Studio GUI
+
## Validation
### ALWAYS Run These After Making Changes