1
0
Fork 0
mirror of synced 2024-11-15 04:28:58 -05:00

Update Indentation and Flow Logic sections

Eric Nielsen 2018-04-24 19:46:47 -05:00
parent ef9c24d8f0
commit b724a02cb5

@ -1,4 +1,4 @@
These are the code style guidelines that should be followed when contributing to Zim. These are the code style guidelines that should be followed when contributing to zim.
Indentation Indentation
----------- -----------
@ -9,6 +9,15 @@ Not hard tabs. Not four spaces. Not however many spaces you feel like.
2 spaces. 2 spaces.
When using line continuations, indent with 2 extra spaces:
```
for x in a very very very very \
very very very long line; do
print ${x}
done
```
Line Length Line Length
----------- -----------
@ -19,22 +28,23 @@ Variables
Limit the scope of variables to `local` if within a function. Limit the scope of variables to `local` if within a function.
Wrap your variables in `${curly}` `${braces}`. Wrap your variables in `${curly} ${braces}`.
Use `${snake_case}` for your variables. Use `${snake_case}` for your variables.
**NOT** `${camelCase}` or `${FuCk_you_iDoWhat_i_want}`. **NOT** `${camelCase}` or `${FuCk_you_iDoWhat_i_want}`.
Use existing variables whenever possible. Use existing variables whenever possible:
* Good: `${PWD}` `${USER}`
| Bad | Good | * Bad: `$(pwd)` `$(whoami)`
| --- | ---- |
| `$(pwd)` | `${PWD}` |
| `$(whoami)` | `${USER}` |
Flow Logic Flow Logic
---------- ----------
Place `; do` `; then` on the same line as `while`, `for`, and `if`. For short single commands, prefer one-liners:
* `for` with the zsh syntax: `for x (foo bar) print ${x}`
* `&&` instead of if: `(( ! ${+FOO} )) && FOO='bar'`
Otherwise just place `; do` `; then` on the same line as `while`, `for ... in`, and `if`.
Functions Functions
--------- ---------