SourceStyle

Source Style

In order to keep the code nice and clean we have a few requirements you'll need to stick to in order to get your patches accepted.

General Rules

  • All text files should use Unix-style text format
  • All text files should use UTF-8 as charset
  • All code files should use the .rb extension
  • All existing copyright notices must be retained. You can add your own if necessary

Coding Style

It can be a little annoying to change your coding style if you're used to something else, but we need to use only one style to allow people to read the code and understand it easily.

  • Use 2-space tabs for indentation and expand tabs to spaces (if you use VIM, set ts=2 and set et). Don't use tabs at all.
  • Join words of class names by capitalizing the first letter of each word (CamelCase)
  • Join words of method names and variables with underscores
  • Constants should always be in uppercase and should have words separated by undescores
  • Use plural names for arrays, hashes, ...
  • Methods and functions should always have sensible defaults if possible
  • Strings should be defined using double quotes where possible
  • Space should be used liberally - don't be afraid to spread things out a little to gain some clarity. Generally, there should be one space between brackets and normal statements, but no space between brackets and variables, methods or functions
  • For code blocks, use { ... } when they can be written into a single line, otherwise use do ... end
  • When setting properties of objects, always use foo= instead of set_foo
  • When a method returns a boolean, always use foo?
  • Comment your code using RDoc style

Patches

  • Always provide patches in unified form (diff -u) and with a ChangeLog entry
  • Always provide Unit Test for all the functionnalities you've added

If you think that your patch sticks these requirements you can send it using the ticket system and tag your ticket as *patch*

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.