home

Many options used by uncrustify take a Boolean value: false or true, and this is understood by any developer.
But there are also many options that are like enums where the possible values are { ignore, add, remove, force }.
These options are called 'iarf options'.

Definition

The definition of each value varies slightly if the option concerns spaces or another type of character.

ignore:
The option has no effect on the code. Nothing is added or removed.
add:
for spaces: make sure there is at least one space.
for others: add one element if it is missing.
remove:
for spaces: removes all spaces.
for others: removes the element if it is present.
force:
for spaces: makes sure there is exactly one space. This has the same effect as remove + add.
for others: behaves like 'add'.

Examples

Here the effects of the option sp_after_assign on various assignment:

Input code Output code
sp_after_assign=ignore sp_after_assign=add sp_after_assign=remove sp_after_assign force
Pi=3.14; Pi=3.14; Pi= 3.14; Pi=3.14;Pi= 3.14;
Pi= 3.14; Pi= 3.14; Pi= 3.14; Pi=3.14;Pi= 3.14;
Pi= 3.14; Pi= 3.14;Pi= 3.14;Pi=3.14;Pi= 3.14;

Default value

Most of the Boolean options default to ‘false’, and most of the iarf options default to ‘ignore’, but not all.
See this index of options with a default value that allow uncrustify to modify the code, even if the option is not explicitly set in the config file.
For example the default value for sp_before_comma is 'remove'. This means that, by default, uncrustify removes all spaces before a comma.


home