Skip to content

Cpp Style Guidelines

joka921 edited this page Jun 6, 2022 · 4 revisions

C++ Style Guidelines for QLever

All C++ code that is added to QLever should obey to the following guidelines. The main goal of these guidelines are:

  • Reducing noise in code reviews
  • Making the QLever codebase more consistent
  • Incorporating generally approved best practices for C++ programming by default.

Note: We are aware that a lot of old code in QLever currently does not (yet) follow these guidelines. You are highly encouraged to refactor this code such that it follows the guidelines.

Programmatically enforced guidelines

The following guidelines are automatically checked by the CI via Github actions. Please make sure that your pull requests pass all the actions before marking it ready for review.

C++ Standard

  • QLever is implemented in ISO C++20
  • QLever compiles without warnings with the -Wall -Wextra flags on the following compilers: G++11, G++12, clang++13
  • All language features that are supported by all of these compilers can be used in principle, as long as no other guidelines are violated.
  • TODO Include sanitizers into the CI pipeline.
  • TODO Make a CI using libstdc++ and talk about which standard libraries should be supported.

Code Formatting

  • All C++ sources of QLever (in the directories src and test) must be formatted using clang-format-11
  • TODO Update clang-format, version 11 does not really understand C++20 concepts.

Manually enforced guidelines

The compliance with the following guidelines has to be checked during code review. Please make sure that your code is compliant with the guidelines before having it reviewed. Clearly mark all deliberate violations of the guidelines with an explanation.

TODO Continue here, and add as we go.