Skip to content
Per Djurner edited this page Feb 14, 2017 · 37 revisions

Current rules:

  • Always use curly braces on if / else statements even if they are just one-liners.
  • Avoid lines longer than 120 characters when feasible (one common exception are text strings).
  • Put opening curly brace on same line as function, e.g. public void function x() {.
  • Put else / else if on same line as curly braces, e.g. } else {.
  • local scope replaces the old var loc = {} usage.
  • Built-in CFML functions should be CapsCamelCase().
  • Use tabs, not spaces for indentation.
  • Add newline at end of file (Sublime: ensure_newline_at_eof_on_save": true).
  • Trim trailing white space (Sublime: "trim_trailing_white_space_on_save": true).
  • Internal functions should be public but start with $, e.g. public struct function $foobar
  • No indentation needed after <cfscript> tag.
  • For clarity, always have a blank line before a comment and after the block of code the comment refers to (this is the only place where we use blank lines).
  • Variable assignments should have spaces (e.g. something = x) but not function arguments.
  • Arguments with type any should still declare it even though it's the default if left out.
  • Do not wrap if / else statements to multiple lines, instead shorten it by assigning variables above it that can be used in the if statement instead (what we allow to wrap are function arguments and struct key / values).

Proposed Code Example

component {

  /**
  * A function hint on private functions
  */
  public struct function $foobar(
    required string foo,
    required string bar,  
    numeric number = 1
  ) {
    local.rv = Duplicate(arguments);
    return local.rv;
  }

}

Clone this wiki locally