From 392533d0ca0f6e6eff92ff465b3b2496c1017963 Mon Sep 17 00:00:00 2001 From: Matt Hamilton Date: Tue, 29 Dec 2015 11:59:03 -0500 Subject: [PATCH] more will be added later --- Code-Style-Guide.md | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Code-Style-Guide.md 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")` +