Fuego wiki

Login or create account

Coding style

This page described the coding style conventions used in Fuego.

Please adhere to these conventions, so that the code has a more uniform style and it is easier to maintain. Not all code in Fuego adheres to these styles. As we work on code, we will convert it to the preferred style over time. New code should adhere to the preferred style.

Fuego code consists mostly of shell script and python code.

Indentation and line length [edit section]

We prefer indentation to be 4 spaces, with no tabs.

It is preferred to keep lines within 80 columns. However, this is not strict. If a string constant causes a line to run over 80 columns, that is OK.

Some command sequences passed to the 'report' function may be quite long and require that they be expressed on a single line. In that case, you can break them up onto multiple lines using shell continuation lines.

Trailing whitespace [edit section]

Lines should not end in trailing whitespace. That is: 'grep " $"' should always be empty.

Script files should not end in blank lines.

Shell features [edit section]

Shell scripts which run on the device-under-test (target board), SHOULD restrict themselves to POSIX shell features only. Do not assume you have any shell features on the target board outside of those supported by 'busybox ash'.

Try running 'checkbashisms' on your target-side code, to check for any non-POSIX constructs in the code.

The code in is guaranteed to run in bash, and may contain bashisms, if needed. If equivalent functionality is available using POSIX features, please use those instead. Please avoid esoteric or little-known bash features. (Or, if you use such features, please comment them.)

Another useful tool for checking your shell code is 'ShellCheck'. See Note that most distributions have a package for shellcheck.

Python style [edit section]

Python code (such as parser code, the overlay generator, ftc and other helper scripts), should be compliant with the PEP 8 Python style guide. As with shell code, there is a lot of legacy code in Fuego that is not currently compliant with PEP 8. We will convert legacy code to the correct style as changes are made over time.

Here are a few more conventions for Fuego code:

  • strings consisting of a single character should be declared use single-quotes
  • strings consisting of multiple characters should declared using double-quotes, unless the string contains a double-quote. In that case, single-quotes should be using for quoting, to avoid having to escape the double-quote.

Note that there is a fuego lint test (selftest), called Functional.fuego_lint. It only checks a few files at the moment, but the plan is to expand it to check additional code in the future.

TBWiki engine 1.8.2 by Tim Bird