Need help with run-clang-format?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

Sarcasm
172 Stars 47 Forks MIT License 45 Commits 9 Opened issues

Description

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

Services available

!
?

Need anything else?

Contributors list

# 73,228
C
Windows
c-plus-...
compila...
37 commits
# 157,459
C
Shell
Lua
clang-f...
2 commits
# 79
Python
tpu
algorit...
sorting...
1 commit
# 132,928
Vue.js
vue-cli
vuejs
cpluspl...
1 commit
# 341
Node.js
Electro...
C++
React
1 commit
# 43,171
cypress
fulltex...
tailwin...
resume-...
1 commit

=====================

run-clang-format.py


Lint files and directories with clang-format

.. contents:: :local:

Introduction

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.

.. image:: screenshot.png

How to use?

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/thirdparty \ --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 thirdparty code from clang-format checks src/thirdparty/*

Continuous integration

Check

.travis.yml <.travis.yml>
_.

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

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

FAQ

Can I check only changed files?

No, and this is what this repository was initially about. However, once working around a few shortcommings of

git clang-format
, I opted to try an alternative strategy which expects the whole project to be correctly formatted.

It would make sense to support this feature as well, so that the coding style does not need to be enforced but merely suggested.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.