We use clang-tidy to lint C++ code and aim to keep the repository warning-clean. The linter is configured in the .clang-tidy file.
In order to run the current CL through the linter (assuming the current directory is //peridot), run:
../scripts/git-file-tidy [--out-dir out/debug-x64]
In order to run the entire repository through the linter, add --all. You can also add --fix in order to automatically generate fixes for some (but not all) of the warnings.
Any warning can be suppressed by adding a // NOLINT comment on the line on which it occurs. It is also possible to disable the check entirely within Ledger repository by editing the .clang-tidy file.
This list tracks the reasons for which we disabled particular checks:
clang-analyzer-core.NullDereference, clang-analyzer-unix.Malloc - these checks are triggering memory access warnings at rapidjson callsites (despite the header filter regex) and we didn't find a more granular way to disable themclang-diagnostic-unused-command-line-argument - ninja-generated compilation database contains the linker argument which ends up unused and triggers this warning for every filemisc-noexcept* - Fuchsia doesn't use C++ exceptionsmodernize-deprecated-headers - Fuchsia uses old-style C headersmodernize-raw-string-literal - the check was suggesting to convert \xFF literals, which we'd rather keep in the escaped form.modernize-return-braced-init-list - concerns about readability of returning braced initialization list for constructor arguments, prefer to use a constructor explicitlymodernize-use-auto - not all flagged callsites seemed worth converting to automodernize-use-equals-delete - flagging all gtest TEST_Fmodernize-use-equals-default - Ledger chose not to impose a preference for “= default”performance-unnecessary-value-param - it was flagging view classes which we prefer to pass by valuereadability-implicit-bool-conversion - Fuchsia C++ code commonly uses implicit bool cast of pointers and numbers