-
-
Notifications
You must be signed in to change notification settings - Fork 106
Code Style Guide
Per Djurner edited this page Aug 25, 2016
·
37 revisions
Current rules:
- Avoid lines longer than 120 characters when possible.
- 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 {. -
localscope replacesloc. - 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).
New suggestions for discussion:
- No indentation needed after
<cfscript>tag. - Blank line before comment when it's not at the start of a block.
- Default arguments should have spaces, e.g.:
string action = "" - Functions with more than 2 arguments should be on separate lines
- Arguments with type
anyshould still declare it even though it's the default if left out
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;
}
}