Skip to content

Commit

Permalink
Add an uncrustify configuration (code prettifier)
Browse files Browse the repository at this point in the history
The `uncrustify` tool is an extremely configurable code prettifier that
is actively maintained and has extensive options for debugging
formatting issues. See https://uncrustify.sourceforge.net/ for more
details.

Let's add a configuration that can help contributors auto-format their
code to allow them to focus on the actual goal of their improvements.

This requires uncrustify 0.78.0 or newer.

Co-authored-by: Johannes Schindelin <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
vdye and dscho committed Jan 31, 2024
1 parent 564d025 commit 92d748b
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions contrib/uncrustify/uncrustify.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# uncrustify config file for the Git project
#
# Run it in a git/git worktree like this:
#
# uncrustify -c contrib/uncrustify/uncrustify.cfg \
# --replace --no-backup --if-changed <file>
#
# Or run it on all source files:
#
# printf 'include Makefile\n\nsources:\n\t@echo $(COCCI_SOURCES)\n' |
# make -f - sources |
# xargs -r uncrustify -c contrib/uncrustify/uncrustify.cfg \
# --replace --no-backup --if-changed
#
# This configuration requires uncrustify 0.78.0 or newer.
#

align_keep_tabs = TRUE
align_with_tabs = TRUE
align_on_tabstop = FALSE

cmt_indent_multi = FALSE

align_right_cmt_span = 3
align_keep_extra_space = TRUE
indent_comment_align_thresh = 16
cmt_trailing_single_line_c_to_cpp = FALSE

indent_with_tabs = 2
indent_comment = FALSE
indent_align_string = TRUE
indent_align_assign = FALSE

pp_ignore_define_body = TRUE

sp_enum_colon = remove

# Add or remove space before a trailing comment.
sp_before_tr_cmt = ignore # ignore/add/remove/force/not_defined

# Number of spaces before a trailing comment.
sp_num_before_tr_cmt = 1 # unsigned number

sp_before_sparen = force
sp_func_call_paren = remove
sp_func_proto_paren = remove
sp_after_semi = remove

# Bit field colons should not be enclosed in spaces
sp_after_bit_colon = remove
sp_before_bit_colon = remove

0 comments on commit 92d748b

Please sign in to comment.