|
Packit Service |
def718 |
In general:
|
|
Packit Service |
def718 |
For minor changes to a function, copy the existing formatting.
|
|
Packit Service |
def718 |
When changing the style, commit that separately from other changes.
|
|
Packit Service |
def718 |
For new code and major changes to a function, switch to the official json-c style.
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
Official json-c style:
|
|
Packit Service |
def718 |
Aim for readability, not strict conformance to fixed style rules.
|
|
Packit Service |
def718 |
These rules are not comprehensive. Look to existing code for guidelines.
|
|
Packit Service |
def718 |
Indentation is tab based, with continuations of long lines starting with tabs then spaces for alignment.
|
|
Packit Service |
def718 |
Try to line up components of continuation lines with corresponding part of the line above (i.e. "indent -lp" effect), but avoid excessive identation tha causes extra line wraps.
|
|
Packit Service |
def718 |
e.g. (T=tab, S=space):
|
|
Packit Service |
def718 |
TTTTsome_long_func_call(arg1, arg2,
|
|
Packit Service |
def718 |
TTTTSSSSSSSSSSSSSSSSSSSarg3, arg4);
|
|
Packit Service |
def718 |
TTTTsome_reallly_really_long_func_name(arg1,
|
|
Packit Service |
def718 |
TTTTTarg2, arg3, arg4);
|
|
Packit Service |
def718 |
There should be a space between "if"/"while" and the following parenthesis.
|
|
Packit Service |
def718 |
"case" lines are indented at the same level as the "switch" statement.
|
|
Packit Service |
def718 |
Commas are followed by a single space.
|
|
Packit Service |
def718 |
Include spaces around most non-unary, non-postfix operators, "=", "==', "&", "||", etc...
|
|
Packit Service |
def718 |
Function calls have no space between the name and the parenthesis.
|
|
Packit Service |
def718 |
Curly braces go on their own line.
|
|
Packit Service |
def718 |
Curly braces may be omitted.
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
Naming:
|
|
Packit Service |
def718 |
Words within function and variable names are separated with underscores. Avoid camel case.
|
|
Packit Service |
def718 |
Prefer longer, more descriptive names, but not excessively so. No single letter variable names.
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
Other:
|
|
Packit Service |
def718 |
Variables should be defined for the smallest scope needed.
|
|
Packit Service |
def718 |
Functions should be defined static when possible.
|
|
Packit Service |
def718 |
When possible, avoid exposing internals in the public API.
|