-
Notifications
You must be signed in to change notification settings - Fork 189
Code review
This page explains how code review is carried out in this repository.
Automated checks start when a PR is opened. The same checks will be triggered for every push to the branch associated to the PR.
The PR is pulled to a GitLab mirror and tested with GitLab-CI. There are three main stages:
- style stage: checks that the code is correctly formatted and that the Doxygen documentation compiles
- build stage: compile ESPResSo on various Linux operating systems and run the testsuite
- additional checks stage: build and check the Sphinx documentation, test the binaries built in the previous stage without a GPU and with a different number of MPI ranks
Builds ESPResSo and runs the testsuite on a macOS runner.
Code coverage generated by the runners in the GitLab-CI pipeline are sent to codecov to generate a report. It can take time for the runners to execute the testsuite, therefore the percentages shown in the first 30 min can be ignored, as they are based on incomplete data.
The codecov/patch — 96% of diff hit (target 94%) line is the most important one. When adding a new feature to ESPResSo, the corresponding code must be fully covered by tests.
This is the merge bot. Its status indicates what is missing for the PR to be merged.
Once the automated checks have passed, members of the ESPResSo team will start reviewing the code. Only a review by a core team member will count towards mergeability. Sometimes, review can be delegated to a non-core team member, in which case the review will appear as a check mark in a a grey circle until a core team member confirms the review.
Reviewers will assess the code and make suggestions for improvement. Below is a non-exhaustive list of common style recommendations.
C++:
- no use of malloc/free, instead use STL containers or new/delete
- no use of const_cast, except when interfacing with C libraries
- no use of C-style casts (unsafe: risk of reinterpret_cast or const_cast), instead use static_cast<T>()
- everything that can be const should be
- prefer "East const" in new code
- avoid bare owning pointers in favor of smart pointers
- avoid bare loops in favor of STL algorithms and Boost Range algorithms
- avoid MPI primitives in favor of boost::mpi collectives
- avoid macros
- don't introduce new global variables; existing ones are being progressively removed
- avoid using existing global variables, instead pass them by reference
- avoid mixing signed and unsigned types, e.g. passing an int to a function that takes a std::size_t
- CamelCase vs. snake_case: see the dedicated page on Naming conventions and folder structure
- see also the C++ Core Guidelines; although we do not enforce them, they are an excellent source of good coding practices with detailed explanations
- no wildcard imports, e.g. from espressomd.lb import *
- avoid importing without a namespace, e.g. from espressomd import lb (prefer import espressomd.lb)
- no use of eval()