more will be added later
parent
7e9ea82ef9
commit
392533d0ca
1 changed files with 56 additions and 0 deletions
56
Code-Style-Guide.md
Normal file
56
Code-Style-Guide.md
Normal file
|
@ -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")`
|
||||
|
Loading…
Reference in a new issue