diff --git a/Code-Style-Guide.md b/Code-Style-Guide.md new file mode 100644 index 0000000..ff6bc1c --- /dev/null +++ b/Code-Style-Guide.md @@ -0,0 +1,56 @@ +These are the code style guidelines that should be followed when contributing to Zim. + +Indentation +----------- + +Indent = two spaces + +Not hard tabs. Not four spaces. Not however many spaces you feel like. + +2 spaces. + +Line Length +----------- + +Be reasonable. Keeping within 80 characters is recommended, 120 is the maximum. + +Variables +--------- + +Limit the scope of variables to `local` if within a function. + +Wrap your variables in `${curly}` `${braces}`. + +Use `${snake_case}` for your variables. +**NOT** `${camelCase}` or `${FuCk_you_iDoWhat_i_want}`. + +Use existing variables whenever possible. + +| Bad | Good | +| --- | ---- | +| `$(pwd)` | `${PWD}` | +| `$(whoami)` | `${USER}` | + +Flow Logic +---------- + +Place `; do` `; then` on the same line as `while`, `for`, and `if`. + +Functions +--------- + +Use POSIX syntax: +``` +foo() { + print 'bar' +} +``` + +NOTE: There *is* a difference between this and ksh style, but unless you know what it is and you're **sure** you need it, use POSIX. + +Misc +---- + +Do **NOT** use backticks ``` ` ``` to execute something in a subshell. This GRINDS MY GEARS. +`$(print "use parentheses")` +