-
Notifications
You must be signed in to change notification settings - Fork 5
Style Guide
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.
In general a source file should have the following structure:
- Our FreeBSD license agreement
- Blank line
- Package declaration
- Blank line
- Import statements
- Blank line
- ScalaDoc for the current class/object/trait
- 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.