Page tree
Skip to end of metadata
Go to start of metadata

All languages:

  • All source files should include the standard Apache license header.
  • All lines should be limited to 90 characters in width
  • Remove trailing whitespace. To automate this, install pre-commit.sh into .git/hooks/pre-commit and make it executable.

C++

See the C++ Style Guide

Java

  • Currently undocumented - new code should follow existing style conventions.

Thrift

We don't have a formal style guide, but we do adhere to a few conventions:

  • Structs
    • Struct names begin with a "T", and use a capital letter for each new word, with no underscores.
    • All fields should be declared as either optional or required
    • Don't use semicolons after struct member declarations; they're optional, so we optimize for typing efficiency.
  • Functions
    • Function names start with a capital letter and have a capital letter for each new word, with no underscores.
    • Each function should take exactly one parameter, named FunctionNameParameter, and should return either void or FunctionNameResponse. This convention allows incremental updates.
  • Parameters
    • Parameter names use camel case (with no underscores).
  • Services
    • Service names should end in the word "Service"

Here's an example:

 

Python

When editing existing code, you should follow existing code style in the file you are editing. In general, our code tries to follow PEP8 style with some exceptions:

  • We wrap lines at 90 characters (instead of 80)
  • We use 2 spaces indent (instead of 4)
  • We use whitespace around {{ = }} signs
  • We sometimes use only one blank line where PEP8 suggests two

The following tools have been found useful by developers to scan and/or automatically fix formatting issues:

  • pycodestyle (formerly known as pep8) - A checker for PEP8 conformance
  • autopep8 - A tool that automatically formats code to conform with PEP8
  • vim-syntastic - A plugin for vim that can highlight style violations

All tools above can be used with the same configuration file. As a starting point, consider using this one:

 

 

 

  

  • No labels