Skip to content

cppcheck: use file list, add -j option, and handle build dir#1

Draft
mdeweerd wants to merge 1 commit into
masterfrom
vibe/cppcheck-filelist-c62b93
Draft

cppcheck: use file list, add -j option, and handle build dir#1
mdeweerd wants to merge 1 commit into
masterfrom
vibe/cppcheck-filelist-c62b93

Conversation

@mdeweerd

@mdeweerd mdeweerd commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Why

In CI, I enabled cppcheck caching by adding the --cppcheck-build-dir option, but that did not work as every file was analysed in a separate cppcheck call.

The changes avoids splitting the analysis in multiple batches, and has all the files analysed in a single cppcheck call (which itself creates multiple subprocesses).

Summary of the changes

  • Use --file-list option to pass multiple files to cppcheck in a single invocation
  • Automatically add -j option with number of available processors for parallel analysis
  • Add --cppcheck-build-dir when using -j > 1 to enable unusedFunction check compatibility
  • Always suppress unusedFunction warnings (now safe due to --cppcheck-build-dir handling)
  • Use truly unique temporary directories with tempfile.mkdtemp()
  • Properly clean up temporary directories with shutil.rmtree() even on interruption

Changes

  • Modified hooks/cppcheck.py to use --file-list option instead of running cppcheck once per file
  • Added automatic -j N option with CPU count (only on multi-core systems)
  • Added automatic --cppcheck-build-dir creation when using -j > 1
  • Simplified suppression logic: always add --suppress=unusedFunction (previously conditional)
  • Added proper cleanup of temporary build directories using shutil.rmtree()
  • Updated test filters in tests/test_hooks.py to handle cppcheck warning messages

Extra Info

--suppress=unusedFunction is no longer needed

As we add the --cppcheck-build-dir when missing if -j is > 1, there is no longer an issue with the analysis.

Verification

  • All existing tests pass - except on macos which is unrelated to these changes
  • New behavior properly handles parallel analysis
  • Temporary directories are cleaned up even on interruption
  • No warning messages about -j and unusedFunction conflicts
  • Test on actual project.

@mdeweerd
mdeweerd force-pushed the vibe/cppcheck-filelist-c62b93 branch 2 times, most recently from e4720ff to 4314db3 Compare July 12, 2026 15:02
@mdeweerd
mdeweerd changed the base branch from main to master July 12, 2026 15:45
@mdeweerd mdeweerd changed the title cppcheck: use file list and add -j option with available processors cppcheck: use file list, add -j option, and handle build dir Jul 12, 2026
@mdeweerd
mdeweerd force-pushed the vibe/cppcheck-filelist-c62b93 branch 4 times, most recently from fddd8b8 to 1b4abb7 Compare July 20, 2026 14:00
- Add parallel processing support with -j option (defaults to # processors)
- Implement temporary build directory for parallel processing (when -j > 1)
- Update default arguments for cppcheck (unusedFunction check disabled, no need ot ignore)
- Improve error handling and cleanup (cppcheck)
- Update tests to verify parallel processing functionality
@mdeweerd
mdeweerd force-pushed the vibe/cppcheck-filelist-c62b93 branch from 1b4abb7 to 126c17f Compare July 21, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant