cppclean

raw JSON →
0.13 verified Fri May 01 auth: no python

cppclean is a command-line tool to find problems in C++ source code that slow development of large code bases. It identifies issues such as unused variables, uninitialized variables, complex control flow, and more. Version 0.13 is the latest stable release; the project is in maintenance mode with infrequent updates.

pip install cppclean
error ModuleNotFoundError: No module named 'cppclean'
cause Trying to import cppclean in Python.
fix
Do NOT import cppclean; it is a CLI tool. Use subprocess.run(['cppclean', 'file.cpp']) instead.
error cppclean: error: unrecognized arguments: --some-option
cause Using an option that does not exist (e.g., --output).
fix
Run 'cppclean --help' to see valid arguments. Common options: --verbose, --std=c++11.
gotcha cppclean is NOT a Python importable library; it is a command-line tool. Attempting 'import cppclean' will fail. It must be invoked via subprocess or shell.
fix Use subprocess.run(['cppclean', 'file.cpp']) or equivalent.
gotcha The tool does not support all C++ standards and may report false positives for modern C++ features (e.g., move semantics, smart pointers).
fix Review warnings manually; consider using cppclean as a complement to other tools like clang-tidy.
deprecated The project is in maintenance mode. No active development; may not keep pace with C++ evolution.
fix Evaluate if it meets your needs; consider alternative tools like clang-tidy or cppcheck for active support.

Run cppclean from Python using subprocess (cppclean is not importable as a module, it's a CLI tool).

import subprocess
result = subprocess.run(['cppclean', 'myfile.cpp'], capture_output=True, text=True)
print(result.stdout)