Google CppLint

Google provides a python script to check for a variety of google guideline rules. The script and license has been copied to the Rialto directory.

To see how to run the script from the root of the rialto directory run: ./scripts/cpplint/cpplint.py --help

https://github.com/cpplint/cpplint


The python script can be modified under the license, any modifications are described here:

CategoryModification
Header Guard

Changed the format the script checks for to NAMESPACE_FILENAME_H_.

GetHeaderGuardCPPVariable will also return a list of possible header guards names based on the namespaces defined in the file.

Filename FormatNew function which is run on every file to check that the directories and file is named correctly.
Pragma OnceDo not allow pragma once instead of header guard.
Function Name FormatNew function which runs on ever line to detect a function implementation and check the function name format.
Class Name FormatNew function which runs on ever line to detect a class declaration and check the class name format.
Unnamed NamespaceChecks for namespace key work with no preceding characters. Google checked for '{' which is not possible in Rialto.
Namespace Name FormatCheck the namespace name format.

Clang Format

Clang format, formats the code in the rialto directory using a set of rules defined in ./clang-format.

https://clang.llvm.org/docs/ClangFormat.html


Clang-format v10 is the one we use in our repository. Some Ubuntu machines will automatically install v6.

To install:

  1. sudo apt-get install clang-format
  2. clang-format --version

If version is not v10:

  1. sudo apt install clang-format-10
  2. sudo update-alternatives --install /usr/bin/clang-format-6.0 clang-format-6.0 /usr/bin/clang-format-10 100
  3. sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-10 100
  4. clang-format --version