Code Style

Last modified by Vincent Massol on 2026/09/15 13:02

Here are the code style rules that apply to every language used in the XWiki project. The rules specific to one language are on that language's own page, listed at the end.

Formatting

  • Lines are at most 120 characters long. For Java this is enforced by Checkstyle, see Java Code Style.

Comments

  • A comment must be self-explanatory: it explains the problem the code solves and why the code is written that way, and it has to stay understandable when everything it points to is gone.
  • In addition, and optionally, a comment may link to an external site (JIRA, GitHub, a forum thread, etc.) holding a more detailed explanation. Such a link is a complement, never the explanation itself: an issue title states a symptom, it does not explain the code. When quoting an issue, include the issue ID and the issue title, so that much remains informative even if the external link or issue tracker is down or decommissioned. Example:
    // The parser keeps the newline that closes a macro block and the serializer emits its own, so a
    // page saved twice grows a blank line. Drop it here until the parser stops producing it.
    // More details: XWIKI-1234 "Blank line added when saving a page twice"

Code style per language

Get Connected