[Tracker] Formatting code automatically with Uncrustify



Hi all,

I've been looking at whether we can automatically reformat Tracker's
source code using 'uncrustify'. This tool is already used by Nautilus.

The motivation is that I don't like giving minor style feedback in
merge requests, I'd prefer to focus on the actual content and
functionality. But I also don't want inconsistent code formatting. So
it would be ideal if we could say 'run this tool to fix your
formatting'.

Uncrustify is very configurable. I made a configuration file for
Tracker which tries to match our current coding style[2].

The main difficulty is in variable definition alignment in functions
and structs. We're currently quite inconsitent about whether we do this
or not, and Uncrustify doesn't have an option to ignore alignment --
either you enable it, and it reformats everything to be aligned, or you
disable it and it reformats everything to be unaligned.

You can see the results here:

  https://gitlab.gnome.org/GNOME/tracker/merge_requests/87

This commit makes a lot of changes all over the code, but it would mean
that we could tell future patch submitters to run
`utils/run-uncrustify.sh` to fix their formattting, rather than
expecting them to read the whole of [2].

What do you think? Are the benefits worth the cost? Is the new style
nice enough to look at?

Sam

1. https://github.com/uncrustify/uncrustify
2. https://wiki.gnome.org/Projects/Tracker/Documentation/CodingStyle



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]