aboutsummaryrefslogtreecommitdiff
path: root/source/1.0/doc
diff options
context:
space:
mode:
authorkate.ward <kate.ward@forestent.com>2008-11-12 20:15:30 +0000
committerkate.ward <kate.ward@forestent.com>2008-11-12 20:15:30 +0000
commitbcd68392a588b01caf7d672c0b620e449f247182 (patch)
tree044a7c0a29057336fa41c886f807cf5d2471b0b9 /source/1.0/doc
parentdf46be90ee170865d3bf888d7440a7fa91fcbaa1 (diff)
downloadshflags-bcd68392a588b01caf7d672c0b620e449f247182.tar.gz
added coding standards
Diffstat (limited to 'source/1.0/doc')
-rw-r--r--source/1.0/doc/coding_standards.txt73
1 files changed, 73 insertions, 0 deletions
diff --git a/source/1.0/doc/coding_standards.txt b/source/1.0/doc/coding_standards.txt
new file mode 100644
index 0000000..9733b40
--- /dev/null
+++ b/source/1.0/doc/coding_standards.txt
@@ -0,0 +1,73 @@
+Coding Standards
+================
+
+Variable and Function Names
+---------------------------
+
+All shUnit2 specific constants, variables, and functions will be prefixed
+appropriately with 'shunit'. This is to distinguish usage in the shUnit2 code
+from users own scripts so that the shell name space remains predictable to
+users. The exceptions here are the standard ``assertEquals``, etc. functions.
+
+All non-builtin constants and variables will be surrouned with squiggle
+brackets, e.g. '${shunit_someVariable}' to improve code readability.
+
+Due to some shells not supporting local variables in functions, care in the
+naming and use of variables, both public and private, is very important.
+Accidental overriding of the variables can occur easily if care is not taken as
+all variables are technically global variables in some shells.
+
++----------------------------------+---------------------------+
+| *type* | *sample* |
++==================================+===========================+
+| global public constant | ``SHUNIT_TRUE`` |
++----------------------------------+---------------------------+
+| global private constant | ``__SHUNIT_SHELL_FLAGS`` |
++----------------------------------+---------------------------+
+| global public variable | not used |
++----------------------------------+---------------------------+
+| global private variable | ``__shunit_someVariable`` |
++----------------------------------+---------------------------+
+| global macro | ``_SHUNIT_SOME_MACRO_`` |
++----------------------------------+---------------------------+
+| public function | ``assertEquals`` |
++----------------------------------+---------------------------+
+| public function, local variable | ``shunit_someVariable_`` |
++----------------------------------+---------------------------+
+| private function | ``_shunit_someFunction`` |
++----------------------------------+---------------------------+
+| private function, local variable | ``_shunit_someVariable_`` |
++----------------------------------+---------------------------+
+
+Where it makes sense, variables can have the first letter of the second and
+later words capitalized. For example, the local variable name for the total
+number of test cases seen might be ``shunit_totalTestsSeen_``.
+
+Local Variable Cleanup
+----------------------
+
+As many shells do not support local variables, no support for cleanup of
+variables is present either. As such, all variables local to a function must be
+cleared up with the ``unset`` command at the end of each function.
+
+Indentation
+-----------
+
+Code block indentation is two (2) spaces, and tabs may not be used. ::
+
+ if [ -z 'some string' ]; then
+ someFunction
+ fi
+
+Lines of code should be no longer than 80 characters unless absolutely
+necessary. When lines are wrapped using the backslash character '\', subsequent
+lines should be indented with four (4) spaces so as to differentiate from the
+standard spacing of two characters, and tabs may not be used. ::
+
+ for x in some set of very long set of arguments that make for a very long \
+ that extends much too long for one line
+ do
+ echo ${x}
+ done
+
+.. $Revision: 233 $