[Development] Resolving coding style contentions

Eike Ziller Eike.Ziller at qt.io
Fri Nov 23 09:39:20 CET 2018



> On 22. Nov 2018, at 17:41, Matthew Woehlke <mwoehlke.floss at gmail.com> wrote:
> 
> On 22/11/2018 04.30, Frederik Gladhorn wrote:
>> Does Uncrustify support ranges so it will 
>> only re-format the parts of a file that were touched?
> 
> I don't think so, though if someone cared enough, it might be possible
> to add that. (Uncrustify tracks the original location of its tokens, so
> plausibly you could make it output only the selected range after
> reformatting.)
> 
> However... I think ranges are a crutch.

> If a file is correctly formatted
> to begin with,

That’s exactly the point. Forcing a codebase to be completely reformatted when adopting a style severely limits the options for introducing it.

> I don't see any value in only formatting a range.

It makes it possible to adopt a formatter without reformatting the whole code base.
It makes it possible for individuals to use a formatter while a generic consent is not reached (yet?),
since then the formatter can be used for only the part that was touched in a patch anyhow.
That also helps in creating style settings for the formatter in the first place, and testing what works well, what not so well, what might even be fixed in the tool upstream.
E.g. currently some Qt Creator developers use clang-format. Since the format is tweaked so it mostly represents what is already used the new code fits into the code base, but the rest of the code is not affected by the line breaking or unbreaking etc that clang-format would enforce on it.

> I'm
> also concerned there could be instances when trying to only format a
> given range could lead to errors. (Maybe the range is a "hint" which can
> be expanded until the formatted and original output have a line break at
> the same token?

AFAIK something like this is what clang-format does, it can affect a few lines above or below. (At least that is what happens in the Qt Creator integration.)

> But even this might result in screwy formatting...)
> 
> BTW, while there are hopefully few if any left, what does clang-format
> do to normalized SIGNAL/SLOT?

Is that a relevant question for the Qt 5 code base?

Br, Eike

-- 
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
eike.ziller at qt.io
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Development mailing list