{"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":"en","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,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}