{"id":5888,"library":"cpplint","title":"cpplint","description":"Cpplint is an actively maintained, open-source command-line tool for static analysis of C/C++ source files, primarily used to enforce adherence to Google's C++ style guide. Version 2.0.2 is the latest stable release, with frequent updates incorporating modern C++ standards and Python environment compatibility.","status":"active","version":"2.0.2","language":"python","source_language":"en","source_url":"https://github.com/cpplint/cpplint","tags":["linting","c++","style-guide","static-analysis"],"install":[{"cmd":"pip install cpplint","lang":"bash","label":"Install cpplint"}],"dependencies":[],"imports":[],"quickstart":{"code":"# Create a dummy C++ file for linting\nwith open(\"main.cpp\", \"w\") as f:\n    f.write(\"\"\"#include <iostream>\\n\\nint main() {\\n  std::cout << \"Hello, World!\" << std::endl;  // Missing space before '!'\\n  return 0;\\n}\\n\"\"\")\n\n# Run cpplint on the file\n# This is primarily a command-line tool, so we use subprocess\nimport subprocess\nimport os\n\ntry:\n    # cpplint usually exits with non-zero on errors, so capture output\n    # Using --filter to ignore common line_length warnings for this example\n    result = subprocess.run(\n        [\"cpplint\", \"--filter=-whitespace/line_length\", \"main.cpp\"],\n        capture_output=True,\n        text=True,\n        check=False  # Don't raise CalledProcessError for non-zero exit codes\n    )\n    print(\"cpplint output (stdout):\")\n    print(result.stdout)\n    print(\"\\ncpplint output (stderr):\")\n    print(result.stderr)\n    if result.returncode != 0:\n        print(\"\\nLinting found issues. Return code:\", result.returncode)\n    else:\n        print(\"\\nNo linting issues found (or filtered out).\")\nexcept FileNotFoundError:\n    print(\"Error: cpplint command not found. Ensure it's installed and in your PATH.\")\nfinally:\n    # Clean up the dummy file\n    if os.path.exists(\"main.cpp\"):\n        os.remove(\"main.cpp\")","lang":"python","description":"The primary way to use cpplint is as a command-line tool. This example creates a C++ file, runs `cpplint` on it with a common filter to ignore line length, and prints the output. Note that `cpplint` writes its findings to stderr. Configuration can also be managed via a `CPPLINT.cfg` file in the project directory."},"warnings":[{"fix":"Upgrade your Python environment to 3.8 or later. The current minimum requirement is Python 3.9.","message":"Python 2 and Python 3.7 are no longer supported. Users must upgrade to Python 3.8 or newer.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Remove any reliance on `python setup.py lint`. Instead, run `cpplint` directly from the command line with appropriate arguments.","message":"The `setup.py lint` subcommand was removed. Direct invocation of `cpplint` commands is now required.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"If your project requires strict checking for non-const references, you may need to explicitly enable a corresponding filter if one becomes available, or consider this change in your style enforcement.","message":"As of version 2.0.2, non-const references are no longer erred on by default. This changes previous behavior where they might have been flagged as style violations.","severity":"gotcha","affected_versions":">=2.0.2"},{"fix":"Customize linting rules using the `--filter` command-line option (e.g., `cpplint --filter=-whitespace/line_length`) or by creating a `CPPLINT.cfg` file in your project directory.","message":"cpplint strictly enforces Google's C++ Style Guide, which may not align with all project or team-specific style preferences.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `// NOLINT(category)` comments on specific lines to suppress known false positives for particular categories. For blocks of code, use `// NOLINTBEGIN(category)` and `// NOLINTEND`.","message":"cpplint is rules-based and uses heuristics, which can lead to occasional false positives or negatives. It is not a substitute for a comprehensive code review.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'2.0.2':33 'activ':5 'adher':25 'analysi':16,57 'c':29,44,51 'c/c':18 'command':11 'command-lin':10 'compat':49 'cpplint':1,2 'enforc':24 'environ':48 'file':20 'frequent':40 'googl':27 'guid':31,54 'incorpor':42 'latest':36 'line':12 'lint':50 'maintain':6 'modern':43 'open':8 'open-sourc':7 'primarili':21 'python':47 'releas':38 'sourc':9,19 'stabl':37 'standard':45 'static':15,56 'static-analysi':55 'style':30,53 'style-guid':52 'tool':13 'updat':41 'use':22 'version':32","created_at":"2026-04-14T18:32:48.293038+00:00","updated_at":"2026-04-17T14:58:38.629192+00:00","problems":[{"fix":"Add the directory where `cpplint` is installed to your system's PATH environment variable. For example, on Linux, add `export PATH=$PATH:~/.local/bin/` to your `~/.bashrc` or `~/.zshrc` file and then `source` it.","cause":"The `cpplint` executable is not in your system's PATH, often because it was installed with `pip install --user cpplint`, which places it in a user-specific binary directory (e.g., `~/.local/bin/` on Linux) that might not be automatically included in the PATH.","error":"cpplint: command not found"},{"fix":"Use a shell that performs wildcard expansion (like Git Bash or PowerShell) or explicitly list the files, or use a `for` loop in `cmd.exe`. For example, in PowerShell: `Get-ChildItem -Path . -Filter '*.cpp' -Recurse | ForEach-Object { cpplint $_.FullName }` or in `cmd.exe`: `for %f in (*.cpp) do cpplint %f`.","cause":"On Windows Command Prompt (cmd.exe), the wildcard `*` is not expanded by the shell into a list of files before being passed to `cpplint`. Instead, `cpplint` receives the literal string `*.cpp` and tries to open a file with that exact name.","error":"Skipping input '*.cpp': Can't open for reading"},{"fix":"Reorder your `#include` directives to match the specified order. If this specific check is problematic for your project's structure, you can disable it using the `--filter` option: `cpplint --filter=-build/include_order your_file.cpp`.","cause":"This error indicates that your header includes do not follow Google's C++ style guide, which specifies a particular order for different types of includes (e.g., project-specific headers, C system headers, C++ system headers, other library headers).","error":"Found C system header after other header. Should be: ..., c system, c++ system, other. [build/include_order]"},{"fix":"Configure the full path to the `cpplint` executable in your IDE's settings for the `cpplint` extension. For example, in VS Code, set `\"cpplint.cpplintPath\": \"/home/your_username/.local/bin/cpplint\"`.","cause":"This typically occurs when using `cpplint` through an IDE extension (e.g., in VS Code) where the IDE cannot locate the `cpplint` executable. This is similar to 'command not found' but specific to the IDE's environment.","error":"Cpplint could not find executable"},{"fix":"Run `pip install cpplint` in your terminal to install the package.","cause":"The 'cpplint' Python package has not been installed in the active Python environment.","error":"ModuleNotFoundError: No module named 'cpplint'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"cpplint","cli_version":"Cpplint fork (https://github.com/cpplint/cpplint)","type":"library","homepage":null,"github":"https://github.com/cpplint/cpplint","docs":null,"changelog":null,"pypi":"https://pypi.org/project/cpplint/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-04-14","next_check":"2026-07-13","install_tag":null}}