Style guidelines - OSURoboticsClub/underwater GitHub Wiki

###All languages

  • Use Unix line endings (NL).
  • Be professional. Avoid profanity.

###C

  • Follow K&R style.

  • Use four spaces per indentation level.

  • Keep the contents of header and source files in the following order, so that feature test macro definitions are at the top of every translation unit:

    1. feature test macro definitions
    2. local includes
    3. system includes
    4. other macro definitions
    5. code
  • goto is not forbidden, but consider other options first.

  • If a function can fail, always check for failure unless the program is about to terminate uncleanly anyway. "I'll fix it later" is not an excuse. You will forget to fix it. Get it right the first time.

  • Indent switch statements like this:

    switch (x) {
    case A:
        thing1();
    case B:
        thing2();
        break;
    default:
        thing3();
    }
    

###Python 2

  • Follow PEP8.
  • Use four spaces per indentation level.
  • Use the type of quotes that requires the fewest backslashes.
    • 'a "b" c', not "a \"b\" c".
    • "d 'e' f", not 'd \'e\' f'.
  • All else being equal, use single quotes.
  • Use from __future__ import unicode_literals. Use str or bytearray objects to store bytestrings and unicode objects to store regular strings. If you don't know what this means, find out. It's important.

###Git

  • A branch name should look like "drkitty-bugfix", where "drkitty" is your username and "bugfix" is the topic or purpose of your branch.
  • Commit messages should be 50 chars or shorter. This is not a hard limit.
  • A merge commit message should look like "Merge drkitty-bugfix" or "Merge drkitty-bugfix (#13)" where "drkitty-bugfix" is the branch name and 13 is the pull request number.