Created Code style guide (markdown)
parent
5aa969c4a5
commit
dbd0ab050b
|
@ -0,0 +1,58 @@
|
|||
# Code Style Guide
|
||||
|
||||
These are the code style guidelines that should be followed when contributing to fluxion.
|
||||
|
||||
## Indentation
|
||||
_Indent = two spaces_
|
||||
<br>
|
||||
<br>
|
||||
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**
|
||||
```
|
||||
$(pwd)
|
||||
$(whoami)
|
||||
```
|
||||
**Good**
|
||||
```
|
||||
${USER}
|
||||
${PWD}
|
||||
```
|
||||
## Flow Logic
|
||||
Place ; do ; then on the same line as while, for, and if.
|
||||
<br>
|
||||
<br>
|
||||
**Bad**
|
||||
```
|
||||
while true
|
||||
do
|
||||
```
|
||||
**Good**
|
||||
```
|
||||
while true;do
|
||||
```
|
||||
## Functions
|
||||
**Use POSIX syntax:**
|
||||
```
|
||||
foo() {
|
||||
print 'bar'
|
||||
}
|
||||
```
|
||||
NOTE: There are some exceptions but in general use POSIX.
|
||||
|
||||
## Misc
|
||||
Do NOT use backticks $() to execute something in a subshell.
|
||||
Bad:
|
||||
`print "use parentheses"`
|
||||
<br>
|
||||
Good:
|
||||
`print "use parentheses"`
|
Loading…
Reference in New Issue