Difference between revisions of "InkBox project code contributing guidelines"

From InkBox
Jump to navigation Jump to search
Line 5: Line 5:
=== English ===
=== English ===
Check your spelling before committing.
Check your spelling before committing.
* <b>Pro tip:</b> Never commit your code without testing and/or reviewing it (whichever comes first).
* <b>Pro tip:</b> Never commit your code without testing and reviewing it (whichever comes first).
* <b>Pro tip:</b> In English, sentences start with a capital letter and finish with a dot.
* <b>Pro tip:</b> In English, sentences start with a capital letter and finish with a dot.
=== Comments ===
=== Comments ===

Revision as of 11:37, 28 July 2022

This page contains code contributing guidelines one must follow for their code to be merged in one of the source repositories of the InkBox project. When writing code, you shall remember one word: consistency.

Language-independent

Newline at end of file

Files must contain an empty newline at the end. If you are using Visual Studio Code, enable this: https://stackoverflow.com/questions/44704968/visual-studio-code-insert-newline-at-the-end-of-files/44704969#44704969

English

Check your spelling before committing.

  • Pro tip: Never commit your code without testing and reviewing it (whichever comes first).
  • Pro tip: In English, sentences start with a capital letter and finish with a dot.

Comments

Comments must start with a capital letter.

clang-format

Do NOT use clang-format.

C/C++

  • No unnecessary includes
  • One-line comments:
// Hi, this is a comment
  • Multi-line comments:
/*
    Hi, this is a
    multi-line comment
*/

C

Variables and function names

Use snake_case when programming in C. This doesn't apply if you are inserting C code into a C++ project. In this case, follow only the C++ guidelines.

if conditions

if(thing) {
    do_thing();
}
else {
    do_other_thing();
}

C++

Variables and function names

Use camelCase in C++. This applies also if you are inserting C into C++ code.

if conditions

if(thing) {
    doThing();
}
else {
    doOtherThing();
}

Bourne-Again SHell (bash) and similar

Variables and function names

Use snake_case or CAPITAL_SNAKE_CASE.

  • Variables must be declared like this: var="test"
  • Variables must be accessed like this: echo "${var}"

if conditions

if [ "${var}" == "test" ]; then
    do_thing
else
    do_other_thing
fi