Tools for Code Style Compliance

This section provides a list of tools that some have found useful for ensuring their code abides by Drake’s coding style. The list is by no means comprehensive. If your favorite tools or methodologies are not listed, we would be delighted to learn about them. Please document your trick and submit a pull request!

Automated style checks

Code style tests are run by default during bazel test and the results are cached so that only edited files are re-checked. In other words, no special action is required by a developer.

However, you may still invoke code style checks directly if desired, as follows:

cd /path/to/drake-distro
bazel test --config lint //...               # Only run style checks; don't build or test anything else.
bazel test --config lint //drake/common/...  # Check common/ and its child subdirectories.

User manuals for the style-checking tools are as follows:

Manual style fixups

C/C++: Clang-Format

The Mandatory platform specific instructions already install clang-format. On Ubuntu, you may wish to create an alias (assuming $HOME/bin is already on your $PATH):

ln -s /usr/bin/clang-format-3.9 $HOME/bin/clang-format

You can check whether you’ve installed it correctly by executing:

clang-format --help

To run clang-format:

clang-format -i -style=file [file name]