Update CONTRIBUTING.md

Make brace position more explicit in both .cpp & .h.
This commit is contained in:
Don HO 2022-02-17 14:02:00 +01:00 committed by GitHub
parent 47481c76e8
commit 010ce6f0f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -55,17 +55,22 @@ In short: The easier the code review is, the better the chance your pull request
* ###### Good: * ###### Good:
```cpp ```cpp
if () void MyClass::method1()
{
if (aCondition)
{ {
// Do something // Do something
} }
}
``` ```
* ###### Bad: * ###### Bad:
```cpp ```cpp
if () { void MyClass::method1() {
if (aCondition) {
// Do something // Do something
} }
}
``` ```
However, the method definition could be defined in a header file (.h), if there's one line code only. In this case, Java-like braces should be used. However, the method definition could be defined in a header file (.h), if there's one line code only. In this case, Java-like braces should be used.
* ###### Good: * ###### Good:
@ -76,7 +81,8 @@ In short: The easier the code review is, the better the chance your pull request
void method1(); void method1();
int method2() { int method2() {
return _x; // only one line code can be placed in .h as method definition return _x; // only one line code can be placed in .h as method definition
} };
private: private:
int _x; int _x;
} }