Definition of Done
Definition of Done –> DoD
DoD concerns only code for production
- Source code respects Security Rules
- Source code respects Coding Rules
- Run
cpplint
andkwstyle
for Naming Rules Compliance.
- Run
- Source code respects C++ Core Guidelines
- Source code does not throw exception (but uses Tredzone messages)
- Doxygen comments are used when relevant (except for setters/getters…)
- No remaining FIXME
- No compiler warnings
- Unit-Tests must respect TDD or GUTS guidelines
- All Unit-Tests passed OK
- Check code coverage by tests (unit tests, integration tests…)
- No 80% threshold because “When a measure becomes a target, it ceases to be a good measure.” (Goodhart’s law)
- Read also Alberto’s anecdote about “How Much Unit Test Coverage Do You Need?”
- And Jon’s anecdote about “What is a reasonable code coverage % for unit tests?”
- Check what is not covered/tested (can be code lines, code branches, input data…)
- If the untested/uncovered part is not relevant => Unit-Test can be considered as OK.
- But if something is missing => Add tests to cover this part.
- No dead code
- Check Valgrind
- Check CppCheck
- Check AddressSanitizer using build options
-fsanitize=*
(clang and gcc) - Check clang-check (static code analyzer, detects code patterns that most probably are bugs and inspects control flow graph and do path-based analysis)
- Check clang-tidy (linter, checks coding style and address readability, and can fix C++ source code)
Code coverage before git commit
Developers can check code coverage on their local environment before pushing to GitLab remote.
Install at least one coverage repport-maker
gcovr
is one python script presented on http://gcovr.com/lcov
is more powerfull but more complex (see website and github)
In both cases, the CMake script make easy to produce Coverage report
-
Generate build files for Coverage build type
# Recommanded way $ ./prepare.sh --cov # Alternative $ ( mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Coverage .. )
-
Build and run your test
# Recommanded way $ ./build-and-test.sh # Alternative $ make -C build all test
-
Generate coverage report
# If gcovr is present $ make -C build gcovr # If lcov and genhtml are present $ make -C build lcov # Note: lcov removes the *.gcda and *.gcdo files # containing coverage data
-
Read the generated HTML report
Below<build>
is the folder where CMake has generated build scripts.- The HTML report generated by
gcovr
is<build>/gcovr.html
- The HTML report generated by
lcov
has many files, the entry point is<build>/lcov/index.html
You can search within the standard output of the build process to find the absolute path of the generated HTML report.
- The HTML report generated by