Skip to content

Coding guidelines

Paweł Kotiuk edited this page Apr 11, 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.

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:

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).
Thanks to this, we can avoid messy manual way of deleting other objects in destructors.