Skip to main content

cpplint-fix

The Google C++ Style Guide sets some conventions for how to write C++ code that have often been adopted as a good stylistic standard by C++ developers. As it happens, usually, when it comes to these styles, it's very convenient to have automated tools to detect or even fix any errors, which can then be made part of automated pipelines or pre-commit hooks to enforce the chosen style.

cpplint is a Python script that detects and enforces many of the rules in that style guide, especially surrounding things like spaces, comments, indents and so on. This is a useful tool when writing C++ code following the guide.

However, there is one thing cpplint does not do: it does not fix any of the problems.

cpplint-fix is meant as a script that builds on top of cpplint (plus a couple other very light dependencies) to fix some of the more trivial style problems detected, the ones that likely don't require any developer intervention and can be safely automated. You can find the list of currently supported codes here, though note that some code refer to multiple error types (like whitespace/indent) and in that case I don't guarantee that they're all covered. I mean to grow the functionality with time as I find new candidates to rules that are manageable, but I also provide a configuration file option to exclude rules or files for which this script just doesn't work within your specific codebase (or maybe that you selected to not enforce on purpose).

Either way, cpplint-fix should be a help keeping your C++ code clean and well formatted.

Installation

You can install cpplint-fix using pip directly from the Python Package Index:

pip intall cpplint-fix

Usage

Run cpplint-fix on a file or directory:

cpplint-fix <input>

Where <input> is a C++ source file or a directory containing source files.

Options

  • --output, -o Output directory for fixed files (optional)
  • --config, -c Path to a YAML configuration file (optional)
  • --dry-run Only print the changes without applying them

Example

# Fix all files in the src/ directory and write results to fixed/
cpplint-fix src/ --output fixed/

# Run in dry-run mode (no files are changed)
cpplint-fix src/ --dry-run

# Use a custom configuration file
cpplint-fix src/ --config config.yaml

Configuration

You can provide a YAML configuration file to customize which rules or files to exclude from automatic fixing. The configuration file is written in YAML and supports the following fields:

Configuration Fields

  • exclude_rules (list of strings):

    • A list of cpplint error codes (e.g., whitespace/indent, whitespace/blank_line) to exclude from fixing. If a rule is listed here, cpplint-fix will not attempt to fix errors of that type.
  • exclude_files (list of regex patterns as strings):

    • A list of regular expression patterns (as strings) that match file paths to exclude from fixing. Any file whose path matches one of these patterns will be skipped.

Example Configuration

exclude_rules:
	- whitespace/indent
	- whitespace/blank_line

exclude_files:
	- ".*test/.*"           # Exclude all files in any 'test' directory
	- ".*main.cpp$"         # Exclude files named 'main.cpp'

Field Details

  • exclude_rules: The list should contain cpplint error codes as strings. You can find the list of supported codes in CODES.md or by running python -m cpplint_fix.edits.

  • exclude_files: Each entry should be a valid Python regular expression string. The regex is matched against the full file path. For example, .*test/.* will match any file in a directory named test.

Notes

  • If the configuration file is missing or a field is omitted, the default is to not exclude any rules or files.
  • Extra fields in the YAML file are not allowed and will cause an error.

For more details, see the docstring in src/cpplint_fix/config.py.

License

See LICENSE.

Metadata

Release files for cpplint-fix 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cpplint-fix 0.1.0
File Size Uploaded
cpplint_fix-0.1.0.tar.gz 38.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cpplint-fix 0.1.0
File Interpreter ABI Platform
cpplint_fix-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.8 kB

Release files / cpplint_fix-0.1.0.tar.gz

Download URL cpplint_fix-0.1.0.tar.gz
Size 38.9 kB
Tags Source
SHA-256 checksum
How to use checksums
610bc4bb2c2e5fad5b8bc0fee76ffc88634a7fa309d36bdade2d1bddb00419f9
BLAKE2b-256 checksum
How to use checksums
74c75ae1a3f9ff0a9ef23c4d8d6805fd418f375910db9f1b9abda9a9b3f000a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 17, 2025.

Transparency log

Release files / cpplint_fix-0.1.0-py3-none-any.whl

Download URL cpplint_fix-0.1.0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3153e2efa652e1fcc14e20ee539b6f6683f60d728c29ba6846be775a35278cd
BLAKE2b-256 checksum
How to use checksums
7dd2891a04afb23d7e383be07b7eaa3bd0c9ca106b1fa1cb54e96af52a957beb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 17, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page