========================
If you wish to submit a pull request to Serious Sam Evolution then please take a look at the sections below about our coding and styling standards before making said pull request.
========================
Following our coding standards is absolutely essential to have your pull request approved. While we may not close your pull request if it doesn't follow these coding standards, we most likely will delay merging it until compliant.
- Avoid doing large commits. I prefer to have a single commit for a tiny fix/addition rather than bundled up commits.
- Always make sure all files contain the GNU GPL-2.0 license at the beginning of every file containing buildable source code.
- ALWAYS should be space between operator keyword and round brackets!
- ALWAYS should be space between operator round braces and block braces.
// WRONG
if(a > b){
// Your code here.
}
// WRONG
if(a > b) {
// Your code here.
}
// WRONG
if (a > b){
// Your code here.
}
// WRONG
while(true) {
// Your code here.
}
// WRONG
while (true){
// Your code here.
}
// WRONG
while(true){
// Your code here.
}
// WRONG
for(int i = 0; i < 10; i++){
// Your code here.
}
// WRONG
for(int i = 0; i < 10; i++) {
// Your code here.
}
// WRONG
for (int i = 0; i < 10; i++){
// Your code here.
}
// RIGHT
if (a > b) {
// Your code here.
}
// RIGHT
while (true) {
// Your code here.
}
// RIGHT
for (int i = 0; i < 10; i++) {
// Your code here.
}- Method body braces should ALWAYS be on the separate line!
// WRONG
void SomeFunc() {
// Your code here.
}
// RIGHT
void SomeFunc()
{
// Your code here.
}- Everytning under the access modifiers (public/protected/private/) sections should be ALWAYS moved a bit to the right.
// WRONG
class CSomeClass
{
public:
void SomeFunc1();
protected:
void InternalCalc();
private:
int m_iStuff;
bool m_bFlag;
};
// WRONG
class CSomeClass
{
public:
void SomeFunc1();
protected:
void InternalCalc();
private:
int m_iStuff;
bool m_bFlag;
};
// RIGHT
class CSomeClass
{
public:
void SomeFunc1();
protected:
void InternalCalc();
private:
int m_iStuff;
bool m_bFlag;
};- NEVER use tabs! Always use 2 spaces instead of tabs.
// WRONG
void SomeFunc()
{
if (m_bSomeFlag) {
m_iSomeVar = 3;
}
}
// RIGHT
void SomeFunc()
{
if (m_bSomeFlag) {
m_iSomeVar = 3;
}
}- NEVER write switch statement without having tabs for every section.
// WRONG
switch (iSomeVar)
{
case 0: {
...
} break;
case 3: {
...
} break;
default: break;
}
// RIGHT
switch (iSomeVar)
{
case 0: {
...
} break;
case 3: {
...
} break;
default: break;
}- If you have colon and brace at the same line then ALWAYS put space between them!
// WRONG
switch (iSomeVar)
{
case 0:{
...
} break;
case 3:{
...
} break;
default: break;
}
// RIGHT
switch (iSomeVar)
{
case 0: {
...
} break;
case 3: {
...
} break;
default: break;
}========================
These styling guidelines represent the way I prefer to have all the things styled. Ignoring these guidelines will not affect my decision on approving your pull request.
- Avoid using opeators without braces.
// WRONG
if (bSomeFlag) return;
// WRONG
if (condition)
return;
// RIGHT
if (condition) {
return;
}- Avoid putting more than one empty line at any time.
// WRONG
void SomeFunc(condition)
{
if (condition) {
...
}
if (condition) {
...
}
}
// RIGHT
void SomeFunc()
{
if (condition) {
...
}
if (condition) {
...
}
}