CouchDB comes with code in a variety of different languages. While the core is written in Erlang, there are some parts written in C, others written in HTML, CSS, and Javascript, and then there are also shell scripts, Makefiles, et cetera.

First, some general rules:

  1. Always use spaces for indentation, not tabs, except in Makefiles.
  2. Use four spaces for indentation in Erlang and C code, two spaces in HTML, CSS, and Javascript.
  3. Try to keep lines shorter than 80 characters.
  4. When you edit a file, try to stick with the conventions used in the surrounding code.
  5. Avoid trailing spaces and newlines in your files. Good editors usually have a configuration option that prevents this from happening.
  6. Avoid mixing purely cosmetic changes (such as removing trailing white-space) with functional changes, as that makes review of the actual change (whether it’s a check-in or a patch) much more difficult.

For more detailed coding conventions for Erlang code, please see the Erlang Programming Rules and Conventions.