Skip to content

Coding guidelines

Paweł Kotiuk edited this page Aug 17, 2022 · 7 revisions

Documenting

Code documentation should be written using doxygen syntax.
It is recommended to document non-trivial methods, bigger classes (their purpose in two-three sentences) and some hacky solutions in code.

Class comments go in front of classes, method comments in front of method definitions in cpp files link for curious.

These comments are later used for building doxygen docummentation, which is hosted here: antimicrox.github.io/doxygen/
You can also build it by yourself if you want to have the latest changes included

Code style

Style of names:

  • ClassNames - UpperCamelCase
  • functionNames - camelCase
  • variable_names - underscore_style
  • m_class_members - m_underscore_with_m_letter_at_the_beginning

(I know these are not respected in many pieces of antimicrox code, but it would be good to at least to try to stick to them in newer parts)

Other aspects of formatting are handled by clang-format.
I recommend integrating autoformatter with IDE and enabling option format on save (to avoid followup commits fixing formatting).

Commits

Every direct commit to master should describe type of commit (check https://www.conventionalcommits.org/en/v1.0.0/ for more details)

Used types of commits: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test:

During implementation of bigger change consisting of multiple commits you don't have to describe them (only merge commit should, but I will handle this during merge).

Code

Allocating and freeing resources

It is recommended to use (and create new classes) based on QObject.
Preferable way of taking care about proper destroying objects is using parent objects (Parents always destroy their children in destructor). Object trees
Thanks to this, we can avoid messy manual way of deleting other objects in destructors.