Improve the format of CONTRIBUTING.md
parent
ab207db6f7
commit
22ea82b80c
|
@ -67,10 +67,10 @@ In short: The easier the code review is, the better the chance your pull request
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
1. ##### Use tabs instead of white-spaces (we usually set our editors to 4 white-spaces for 1 tab, but the choice is up to you).
|
2. ##### Use tabs instead of white-spaces (we usually set our editors to 4 white-spaces for 1 tab, but the choice is up to you).
|
||||||
|
|
||||||
|
|
||||||
1. ##### Always leave one space before and after binary and ternary operators.
|
3. ##### Always leave one space before and after binary and ternary operators.
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -82,7 +82,7 @@ In short: The easier the code review is, the better the chance your pull request
|
||||||
if (a==10&&b==42)
|
if (a==10&&b==42)
|
||||||
```
|
```
|
||||||
|
|
||||||
1. ##### Only leave one space after semi-colons in "for" statements.
|
4. ##### Only leave one space after semi-colons in "for" statements.
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -94,8 +94,7 @@ In short: The easier the code review is, the better the chance your pull request
|
||||||
for(int i=0;i<10;++i)
|
for(int i=0;i<10;++i)
|
||||||
```
|
```
|
||||||
|
|
||||||
1. <h5>Keywords are not function calls;<br>
|
5. ##### Function names are not separated from the first parenthesis.
|
||||||
Function names are not separated from the first parenthesis.</h5>
|
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -108,7 +107,7 @@ Function names are not separated from the first parenthesis.</h5>
|
||||||
foo ();
|
foo ();
|
||||||
```
|
```
|
||||||
|
|
||||||
1. ##### Keywords are separated from the first parenthesis by one space.
|
6. ##### Keywords are separated from the first parenthesis by one space.
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -121,7 +120,7 @@ Function names are not separated from the first parenthesis.</h5>
|
||||||
if(myCondition)
|
if(myCondition)
|
||||||
```
|
```
|
||||||
|
|
||||||
1. ##### Use the following indenting for "switch" statements:
|
7. ##### Use the following indenting for "switch" statements:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
switch (test)
|
switch (test)
|
||||||
|
@ -136,7 +135,7 @@ Function names are not separated from the first parenthesis.</h5>
|
||||||
} // No semi-colon here
|
} // No semi-colon here
|
||||||
```
|
```
|
||||||
|
|
||||||
1. ##### Avoid magic numbers.
|
8. ##### Avoid magic numbers.
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -150,9 +149,9 @@ Function names are not separated from the first parenthesis.</h5>
|
||||||
lifeTheUniverseAndEverything = buildMorePowerfulComputerForTheAnswer();
|
lifeTheUniverseAndEverything = buildMorePowerfulComputerForTheAnswer();
|
||||||
```
|
```
|
||||||
|
|
||||||
1. ##### Prefer enums for integer constants.
|
9. ##### Prefer enums for integer constants.
|
||||||
|
|
||||||
1. ##### Use initialization with curly braces.
|
10. ##### Use initialization with curly braces.
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -164,7 +163,7 @@ Function names are not separated from the first parenthesis.</h5>
|
||||||
MyClass instance(10.4);
|
MyClass instance(10.4);
|
||||||
```
|
```
|
||||||
|
|
||||||
1. ##### Always use `empty()` for testing if a string is empty or not.
|
11. ##### Always use `empty()` for testing if a string is empty or not.
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -179,7 +178,7 @@ Function names are not separated from the first parenthesis.</h5>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
1. ##### Always use `C++ conversion` instead of `C-Style cast`. Generally, all the conversion among types should be avoided. If you have no choice, use C++ conversion.
|
12. ##### Always use `C++ conversion` instead of `C-Style cast`. Generally, all the conversion among types should be avoided. If you have no choice, use C++ conversion.
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -194,7 +193,7 @@ Function names are not separated from the first parenthesis.</h5>
|
||||||
|
|
||||||
#### NAMING CONVENTIONS
|
#### NAMING CONVENTIONS
|
||||||
|
|
||||||
1. ##### Classes (camel case)
|
1. ##### Classes uses Pascal Case
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -204,21 +203,21 @@ Function names are not separated from the first parenthesis.</h5>
|
||||||
|
|
||||||
* ###### Bad:
|
* ###### Bad:
|
||||||
```cpp
|
```cpp
|
||||||
class iAmClass
|
class iAmAClass
|
||||||
{};
|
{};
|
||||||
class I_am_class
|
class I_am_a_class
|
||||||
{};
|
{};
|
||||||
```
|
```
|
||||||
|
|
||||||
1. <h5>methods (camel case + begins with a lower case)<br>
|
2. ##### Methods & method parameters use camel Case
|
||||||
method parameters (camel case + begins with a lower case)</h5>
|
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
void myMethod(uint myVeryLongParameter);
|
void myMethod(uint myVeryLongParameter);
|
||||||
```
|
```
|
||||||
|
|
||||||
1. <h5>member variables<br>
|
3. ##### Member variables
|
||||||
Any member variable name of class/struct should be preceded by an underscore.</h5>
|
|
||||||
|
Any member variable name of class/struct should be preceded by an underscore.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
public:
|
public:
|
||||||
|
@ -228,7 +227,7 @@ Any member variable name of class/struct should be preceded by an underscore.</h
|
||||||
float _pAccount;
|
float _pAccount;
|
||||||
```
|
```
|
||||||
|
|
||||||
1. ##### Always prefer a variable name that describes what the variable is used for.
|
4. ##### Always prefer a variable name that describes what the variable is used for.
|
||||||
|
|
||||||
* ###### Good:
|
* ###### Good:
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -263,9 +262,9 @@ Any member variable name of class/struct should be preceded by an underscore.</h
|
||||||
|
|
||||||
#### BEST PRACTICES
|
#### BEST PRACTICES
|
||||||
|
|
||||||
1. ##### Use C++11/14 whenever it is possible
|
1. ##### Use C++11/14/17 whenever it is possible
|
||||||
|
|
||||||
1. ##### Use C++11 member initialization feature whenever it is possible
|
2. ##### Use C++11 member initialization feature whenever it is possible
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
class Foo
|
class Foo
|
||||||
|
@ -274,7 +273,7 @@ Any member variable name of class/struct should be preceded by an underscore.</h
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
1. ##### Prefer this form:
|
3. ##### Prefer this form:
|
||||||
```cpp
|
```cpp
|
||||||
++i
|
++i
|
||||||
```
|
```
|
||||||
|
@ -285,12 +284,12 @@ Any member variable name of class/struct should be preceded by an underscore.</h
|
||||||
```
|
```
|
||||||
(It does not change anything for built-in types but it would bring consistency)
|
(It does not change anything for built-in types but it would bring consistency)
|
||||||
|
|
||||||
1. ##### Avoid using pointers. Prefer references. You might need the variable to be assigned a NULL value: in this case the NULL value has semantics and must be checked. Wherever possible, use a SmartPtr instead of old-school pointers.
|
4. ##### Avoid using pointers. Prefer references. You might need the variable to be assigned a NULL value: in this case the NULL value has semantics and must be checked. Wherever possible, use a SmartPtr instead of old-school pointers.
|
||||||
|
|
||||||
1. ##### Avoid using new if you can use automatic variable. However, avoid `shared_ptr` as much as possible. Prefer `unique_ptr` instead.
|
5. ##### Avoid using new if you can use automatic variable. However, avoid `shared_ptr` as much as possible. Prefer `unique_ptr` instead.
|
||||||
|
|
||||||
1. ##### Don't place any "using namespace" directives in headers.
|
6. ##### Don't place any "using namespace" directives in headers.
|
||||||
|
|
||||||
1. ##### Compile time is without incidence. Increasing compile time to reduce execution time is encouraged.
|
7. ##### Compile time is without incidence. Increasing compile time to reduce execution time is encouraged.
|
||||||
|
|
||||||
1. ##### Code legibility and length is less important than easy and fast end-user experience.
|
8. ##### Code legibility and length is less important than easy and fast end-user experience.
|
||||||
|
|
Loading…
Reference in New Issue