From dbd0ab050b5e3b24c13856c17aab6e9603bdf1e2 Mon Sep 17 00:00:00 2001 From: deltax Date: Sun, 31 Dec 2017 17:13:21 +0100 Subject: [PATCH] Created Code style guide (markdown) --- Code-style-guide.md | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 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..eb0598e --- /dev/null +++ b/Code-style-guide.md @@ -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_ +
+
+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. +
+
+**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"` +
+Good: +`print "use parentheses"`