-
Notifications
You must be signed in to change notification settings - Fork 117
Code style
Oleksandr Frei edited this page Jul 27, 2017
·
1 revision
We follow google code style with few modifications:
- Exceptions are allowed
- Indentation must be 2 spaces. Tabs are not allowed.
- No lines should exceed 120 characters.
- use float as floating point type everywhere, where you can do it. Each usage of double type should have reasons (we don't use long instead of int everywhere, yes?)
- each new header should have
#pragma once
in the begining - Use const qualifier where it is possible, especially in range-based for
- body of every if-for-while statement should be bordered with brackets
{ }
, no matter the body contains one line or more. - Empty
{}
should be written with space (e.g.{ }
) - we use
Constructor() : param_(param)
only in case of single parameter or short list of parameters with empty initialisation (: a_(), b_()). In other cases type
Constructor()
: param_(param)
, param2_(param2_)
the indention is 4 spaces before :
and ,
- Try to write 'f' suffix when using float numbers (e.g.
1.0f
)
All .h and .cpp files under $(BIGARTM_ROOT)/src/artm/ must be verified for code style with cpplint.py script. Files, generated by protobuf compiler, are the only exceptions from this rule. To run the script you need some version of Python installed on your machine. Then execute the script like this:
python cpplint.py --linelength=120 <filename>
On Windows you may run this master-script to check all required files:
$(BIGARTM_ROOT/utils/cpplint_all.bat.