Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Code Style

greatman edited this page Sep 11, 2014 · 9 revisions

This page documents code style guidelines. For general contributing guidelines, see CONTRIBUTING.md.

  • Generally, follow Oracle's formatting standards (alt link).
  • No tabs - use 4 spaces instead.
  • All submitted code must follow [Java Conventions].
  • The indentation should solely consist of 4 spaces instead of tabs.
  • No trailing whitespaces for code lines, comments or configuration files.
  • No CRLF line endings, only LF is allowed.
  • For Windows-based machines, you can configure Git to do this for your by running git config --global core.autocrlf true.
  • If you're running a Linux or Mac OSX, you should run git config --global core.autocrlf input instead.
  • For more information about line feeds. See this this article.
  • No 80 character line limit or 'weird' midstatement newlines.
  • Avoid nested code structures.
  • All files must end with a new line.
  • In the Codec networking files. Each get must be in it's variable. Example: int health = buffer.getInt()

Javadoc guidelines (not completely strict):

  • @Override methods should not have docs. They inherit their parent's docs.
  • Public and protected methods on public classes should have docs.
  • Private methods should have docs when their function is non-obvious.
  • Public classes except protocol internals should have docs.
  • Fields on classes that are not simple data structures should have docs.
  • When in doubt, docs.