Difference between revisions of "InkBox project code contributing guidelines"
(Add fork notes) |
(Add build artifacts note) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category:InkBox]]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: <b>consistency</b>. | [[Category:InkBox]]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: <b>consistency</b>. | ||
== Before starting == | == Before starting and/or pushing to a repository == | ||
If the repository you are working on is a <b>fork</b>, please <b>ensure that it is up-to-date with upstream</b> before making changes. | * If the repository you are working on is a <b>fork</b>, please <b>ensure that it is up-to-date with upstream</b> before making changes. | ||
* Make sure that <b>no build artifacts</b> are staged for a commit it before it's too late. <code>.gitignore</code> is your friend. | |||
== Language-independent == | == Language-independent == | ||
=== Indentation === | |||
One indent must be equivalent to 4 spaces or one tabulation. | |||
=== Newline at end of file === | === 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 | 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 |
Latest revision as of 16:25, 6 January 2023
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.
Before starting and/or pushing to a repository
- If the repository you are working on is a fork, please ensure that it is up-to-date with upstream before making changes.
- Make sure that no build artifacts are staged for a commit it before it's too late.
.gitignore
is your friend.
Language-independent
Indentation
One indent must be equivalent to 4 spaces or one tabulation.
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 period.
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"
. For integer variables, they must be declared like this:var=0
. - Variables must be accessed like this:
echo "${var}"
. For integer variables, they may be accessed like this:echo ${var}
. - Files names in variables must be put in double quotes, like this:
if [ -f "${file}" ]; then
if
conditions
if [ "${var}" == "test" ]; then do_thing else do_other_thing fi
JSON
Properties names
Use PascalCase
.