Skip to content

A wrapper script around clang-format, suitable for linting multiple files and to use for continuous integration

License

Notifications You must be signed in to change notification settings

renato-yuzup/run-clang-format

 
 

Repository files navigation

run-clang-format.py

Lint files and directories with clang-format

A wrapper script around clang-format, suitable for linting multiple files and to use for continuous integration.

This is an alternative API for the clang-format command line. It runs over multiple files and directories in parallel. A diff output is produced and a sensible exit code is returned.

screenshot.png

Copy run-clang-format.py in your project, then run it recursively on directories, or specific files:

./run-clang-format.py -r src include foo.cpp

It's possible to exclude paths from the recursive search:

./run-clang-format.py -r \
    --exclude src/third_party \
    --exclude '*_test.cpp' \
    src include foo.cpp

These exclude rules can be put in a .clang-format-ignore file, which also supports comments.

An example configuration is available in this repo:

$ cat .clang-format-ignore
# ignore third_party code from clang-format checks
src/third_party/*

Check .travis.yml.

For an example of failure in logs, click the badge (build is broken on purpose):

https://travis-ci.org/Sarcasm/run-clang-format.svg?branch=master

Yes. You can run against staged files in the current git repository by running this script without arguments:

./run-clang-format.py

You don't get all the flavors for recursivity and exclusion list, however.

About

A wrapper script around clang-format, suitable for linting multiple files and to use for continuous integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.0%
  • C++ 1.0%