-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Code style guide
These are the code style guidelines that should be followed when contributing to fluxion.
Due to the fact the tab length may vary between systems and users, use two spaces instead of real tabs.
- No hard tabs (\t)
- Not four spaces
- Not however many spaces you feel like
- Two spaces ( )
Be reasonable. Keeping within 80 characters is recommended, 120 is the maximum.
- Use existing functions whenever possible to avoid pollution.
- Identify functions using snake-case.
- Prefix identifiers with the lowercased script name defining them.
For example, "fluxion_set_language"
This function is prefixed with "fluxion" to signify it belongs to the fluxion script. We use camel-case because identifiers look more like regular commands.
- Limit the scope of variables to local if within a function.
- Use existing variables whenever possible to avoid pollution.
- Identify variables using camel-case.
- Prefix identifiers with the capitalized script name defining them.
For example, the global "CaptivePortalHashPath"
This global is prefixed with "CaptivePortal" to signify it belongs to the captive portal attack script. Using camel-case makes it clear it's not a subroutine, which use snake-case.
- Limit the scope of constants to local if within a function.
- Use existing constants whenever possible to avoid pollution.
- Identify constants using camel-case.
- Prefix identifiers with the uppercased script name defining them.
For example, "FLUXIONVersion"
This global is prefixed with "FLUXION" to signify it belongs to the fluxion script. This makes it clear a constant was defined because it's uppercase-prefixed similar to old C constants.
Use built-in globals when possible to avoid having to create sub-shells and save resources.
Bad
$(pwd)
$(whoami)
Good
${USER}
${PWD}
$USER
$PWD
Place ; do ; then on the same line as while, for, and if.
Bad
while true
do ...
...
done
Good
while true; do
...
done
Use POSIX syntax:
foo() {
print 'bar'
}
NOTE: There are some exceptions but in general use POSIX standards.
Do NOT use backticks (`command`) to execute something in a subshell.
Bad:
now=`date`
Good:
now=$(date)
FLUXION WIKI