Skip to content

Instantly share code, notes, and snippets.

@gbutt
Created February 11, 2020 04:23
Show Gist options
  • Save gbutt/23710a249c7d18fcdf9f6249cbe8915a to your computer and use it in GitHub Desktop.
Save gbutt/23710a249c7d18fcdf9f6249cbe8915a to your computer and use it in GitHub Desktop.
Uncrustify for Salesforce Apex
# Uncrustify-0.68_f
#
# General options
#
# The original size of tabs in the input.
input_tab_size = 8 # Default: 8
# The size of tabs in the output (only used if align_with_tabs=true).
output_tab_size = 8 # Default: 8
#
# Spacing options
#
# Add or remove space around non-assignment symbolic operators ('+', '/', '%', '<<', and so forth).
sp_arith = force
# Add or remove space around assignment operator '=', '+=', etc.
# sp_assign = force
sp_before_assign = force
sp_after_assign = ignore
# Add or remove space around boolean operators '&&' and '||'.
sp_bool = force
# Add or remove space around compare operator '<', '>', '==', etc.
# sp_compare = force
# Add or remove space before '<'.
sp_before_angle = remove
# Add or remove space inside '<' and '>'.
sp_inside_angle = remove
# Add or remove space between '>' and '(' as found in 'new List<byte>(foo);'.
sp_angle_paren = remove
# Add or remove space between '>' and '()' as found in 'new List<byte>();'.
sp_angle_paren_empty = remove
# Add or remove space between '>' and a word as in 'List<byte> m;' or 'template <typename T> static ...'.
sp_angle_word = force
# Add or remove space before '(' of control statements ('if', 'for', 'switch', 'while', etc.).
sp_before_sparen = force
# Add or remove space between ')' and '{' of of control statements.
sp_sparen_brace = force
# Add or remove space after ',', i.e. 'a,b' vs. 'a, b'.
sp_after_comma = force
# Add or remove space after C/D cast, i.e. 'cast(int)a' vs. 'cast(int) a' or '(int)a' vs. '(int) a'.
sp_after_cast = remove
# Add or remove space between return type and function name. A minimum of 1 is forced except for pointer return types.
sp_type_func = force
# Add or remove space between function name and '(' on function definition.
sp_func_def_paren = remove
# Add or remove space inside empty function '()'.
sp_inside_fparens = remove
# Add or remove space inside function '(' and ')'.
sp_inside_fparen = remove
# Add or remove space between ')' and '{' of function.
sp_fparen_brace = force
# Add or remove space between function name and '(' on function calls.
sp_func_call_paren = remove
# Add or remove space between 'else' and '{' if on the same line.
sp_else_brace = force
# Add or remove space between '}' and 'else' if on the same line.
sp_brace_else = force
# Add or remove space between '}' and 'catch' if on the same line.
sp_brace_catch = force
# Add or remove space between 'finally' and '{' if on the same line.
sp_finally_brace = force
# Add or remove space between '}' and 'finally' if on the same line.
sp_brace_finally = force
# Add or remove space between 'try' and '{' if on the same line.
sp_try_brace = force
# Add or remove space between get/set and '{' if on the same line.
sp_getset_brace = force
# Add or remove space before a trailing or embedded comment.
sp_before_tr_emb_cmt = force
# Number of spaces before a trailing or embedded comment.
sp_num_before_tr_emb_cmt = 2
# Add or remove space between the user function name and '(' on function
# calls. You need to set a keyword to be a user function in the config file,
# like:
# set func_call_user tr _ i18n
sp_func_call_user_paren = remove
set func_call_user assert # System.assert
#
# Indenting options
#
# The number of columns to indent per level. Usually 2, 3, 4, or 8.
indent_columns = 4 # Default: 8
# How to use tabs when indenting code.
# 0: Spaces only
# 1: Indent with tabs to brace level, align with spaces (default)
# 2: Indent and align with tabs, using spaces when not on a tabstop
indent_with_tabs = 0 # Default: 1
# Whether the 'class' body is indented.
indent_class = true
# Whether to align continued statements at the '='. If false or if the '=' is followed by a newline, the next line is indent one tab.
indent_align_assign = false # Default: true
# # How to indent a close parenthesis after a newline.
# # 0: Indent to body level (default)
# # 1: Align under the open parenthesis
# # 2: Indent to the brace level
indent_paren_close = 2
#
# Newline adding and removing options
#
# Don't split one-line braced assignments, as in 'foo_t f = { 1, 2 };'.
nl_assign_leave_one_liners = true
# Don't split one-line braced statements inside a 'class xx { }' body.
nl_class_leave_one_liners = true
# Don't split one-line get or set functions.
nl_getset_leave_one_liners = true
# Don't split one-line function definitions, as in 'int foo() { return 0; }'.
nl_func_leave_one_liners = true
# Add or remove newlines at the start of the file.
nl_start_of_file = remove
# Add or remove newline at the end of the file.
nl_end_of_file = remove
# Add or remove newline between 'enum' and '{'.
nl_enum_brace = remove
# Add or remove newline between 'if' and '{'.
nl_if_brace = remove
# Add or remove newline between '}' and 'else'.
nl_brace_else = remove
# Add or remove newline between 'else' and '{'.
nl_else_brace = remove
# Add or remove newline between 'else' and 'if'.
nl_else_if = remove
# Add or remove newline before 'if'/'else if' closing parenthesis.
nl_before_if_closing_paren = remove
# Add or remove newline between '}' and 'finally'.
nl_brace_finally = remove
# Add or remove newline between 'finally' and '{'.
nl_finally_brace = remove
# Add or remove newline between 'try' and '{'.
nl_try_brace = remove
# Add or remove newline between 'for' and '{'.
nl_for_brace = remove
# Add or remove newline before the '{' of a 'catch' statement, as in 'catch (decl) <here> {'.
nl_catch_brace = remove
# Add or remove newline between '}' and 'catch'.
nl_brace_catch = remove
# Add or remove newline between 'while' and '{'.
nl_while_brace = remove
# Add or remove newline between 'do' and '{'.
nl_do_brace = remove
# Add or remove newline between '}' and 'while' of 'do' statement.
nl_brace_while = remove
# Add or remove newline between 'switch' and '{'.
nl_switch_brace = remove
# Add or remove newline between 'class' and '{'.
nl_class_brace = remove
#
# Blank line options
#
# The maximum number of consecutive newlines (3 = 2 blank lines).
nl_max = 3
# The maximum number of consecutive newlines in a function.
nl_max_blank_in_func = 2
# Whether to remove blank lines after '{'.
eat_blanks_after_open_brace = true
# Whether to remove blank lines before '}'.
eat_blanks_before_close_brace = true
# (Java) Add or remove newline after an annotation statement. Only affects annotations that are after a newline.
nl_after_annotation = force
# nl_before_return = true
#
# Code modifying options (non-whitespace)
#
# Add or remove braces on a single-line 'do' statement.
mod_full_brace_do = force
# Add or remove braces on a single-line 'for' statement.
mod_full_brace_for = force
# (Pawn) Add or remove braces on a single-line function definition.
mod_full_brace_function = force
# Add or remove braces on a single-line 'if' statement. Braces will not be
# removed if the braced statement contains an 'else'.
mod_full_brace_if = force
# Add or remove braces on single-line 'while' statement.
mod_full_brace_while = force
# macro-open startTest
# macro-close stopTest
macro-open Test.startTest
macro-close Test.stopTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment