Skip to content
czengler edited this page Jul 20, 2012 · 4 revisions

All submitted code should respect the official Scala Style Guide.

There is a code formatter Scalariform which assures compliance with the Scala style guide. In the tools/code-formatting folder of Warthog you find a preference file for scalariform. Please format your code with this preference file before you submit a pull request.

In addition we have the following conventions:

  • Maximal line length: 120
  • There should be a ScalaDoc for everything public
  • Public functions should always declare an explicit return type (except Unit - use Scala's {...} Notation)
  • Avoid // comments inside functions (your code should be written in a style, that it need's no further commenting)
  • Stick to the "A function does one thing and does this right" principle.

Anatomy of a source file

In general a source file should have the following structure:

  1. Our FreeBSD license agreement
  2. Blank line
  3. Package declaration
  4. Blank line
  5. Import statements
  6. Blank line
  7. ScalaDoc for the current class/object/trait
  8. Begin of source code

There is no blank line between the ScalaDoc and the beginning of the class/object/trait definition. Each file should end with a new line.

Clone this wiki locally