kdelibs coding style

Urs Wolfer uwolfer at kde.org
Mon Feb 12 22:45:47 GMT 2007


First of all, I'm aware of the age of this thread. But nothing has changed 
since then. That's why I'm writing again about this issue.

The opinion of a lot of the developers who have commented this thread has 
been that there should be at least coding formation conventions at least for 
kdelibs. The "older" files of kdelibs are quite messy in formatting.

Zack proposed to do no mass formatting of kdelibs. He proposed to format the 
files, which are edited in any way by a developer. But to be honest: Who has 
done that? People change some lines, but nobody cares about the formating.

IMHO we should act now. My proposal:
* update the Library Code Policy [1] with the example by Zack. The example is 
the Trolltech Qt Coding Style. That means we follow at least in kdelibs our 
underlying library in formatting.
* run astyle [2] over kdelibs trunk. I have tested that [3] and the result is 
quite good and follows the style described above. Try it!

Problems:
* branches: we have problem to merge them back (->conflicts)
solution: run over astyle as described above before merging
* local modifications: same solution as branches
* svn blame: reformated lines don't show the "right" revision and author. BUT: 
the same would happen when we format every single file when we edit it 
anyways. If we would like to have "nicer" code, there is no way around that 
issue.

I would be volunteer to do the steps described above.

Bye
urs

[1] http://developernew.kde.org/Policies/Library_Code_Policy
[2] http://astyle.sourceforge.net/
[3] 
astyle --indent=spaces=4 --brackets=linux --indent-labels --pad=oper --unpad=paren --one-line=keep-statements --convert-tabs --indent-preprocessor 
`find -type f -name '*.cpp'` `find -type f -name '*.h'`

On Thursday 01 January 1970, Zack Rusin wrote: 
> With much love from Russia comes temperature checker (prediction: it's
> hot! flaming hot!) in the form of a proposal for a common coding style
> in kdelibs.
>
> It's something we talked about during the KDE Four meeting. The reason
> for it is that it's a pain in a butt to read through kdelibs code.
> Indention differs within files which makes a lot of them unreadable
> (oh, and btw shoutouts to George and Lubos for having indention styles
> that make grown may cry and baby jesus swear). Since KDE uses this
> thing called Qt, which also happens to be a library, it was agreed that
> it makes natural sense to adopt the style used in Qt. Attached is a
> file which describes Qt coding style. The idea is that it would be
> adopted for kdelibs.
>
> To make it clear, no mass reindenting would take place.. For already
> existing code the indention would be changed when a person would be
> editting it. So if you fix a bug in already existing code, you simply
> indent your code with the standard indention. This way history won't be
> messed up and we'll end up with consistant style in all files by the
> time KDE4 is out. The style is obviously mandatory for all new files.
>
> No exceptions. Either everything or nothing.
>
> Well, the only exception are libraries that are not maintained in the
> KDE SVN (for example, if it ever happens, integrated KHTML/WebKit would
> be maintained outside KDE SVN and the coding style that applies to it
> is one chosen for this project - interestingly enough WebKit coding
> style is basically exactly like Qt coding style so that's not going to
> be an issue).
>
> Oh, and this is of course only for kdelibs, in your apps/modules you can
> still use the 2.3 tabs indention or whatever your sick mind desires.
>
> with not a whole lot love but a lot of perseverance
> your boy toy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070212/c963c868/attachment.sig>


More information about the kde-core-devel mailing list