C++ Code Modernization Guidelines¶
Whenever editing code, try to follow the “Boy Scout Rule”, i.e., leave code surrounding your in a better state than before. For Mantid in particular, pay attention to the following:
Do not pass
shared_ptrunless you are passing ownership. Just pass
const MyClass &or
Replace uses of
std::make_unique, where possible.
Split large functions/methods into smaller functions/methods. Consider using free functions since that facilitates unit testing and code reuse.
Remove trivial or obvious comments. If a comment can be changed into a better variable name, do so.
Where it makes sense, replace boolean or integer flags by
enum class. Even better: Avoid them entirely, e.g., by moving code into two separate free functions.
autoto capture complex return types such as
If you encounter unit tests that look incomplete, such as not verifying that algorithm output, either fix it (if possible in reasonable time), or add a note to https://github.com/mantidproject/mantid/issues/25461.