cornelius / kode

XML meta programming
http://www.lst.de/~cs/kode
21 stars 10 forks source link

Changes in the code formatting style? #34

Closed martonmiklos closed 4 years ago

martonmiklos commented 4 years ago

@cornelius @dfaure-kdab

How would it sounds to you if we would implement changes in the code formatting standard of the project?

My biggest concern is the spaces before the arguments and after the arguments. I use QtCreator and there is no such an option to setup this for the autocompleted codes, so I tend to write code which accidentally not consistent with the rest of the code.

Long term I think it would be useful leverage the Qt coding style, but if we could get rid from these spaces I think that would save more time (both on developer and reviewer side) than implementing this change.

At the moment I do not know any off the self tools for this task that other than astyle. If you happen to know a good/better tool for this task or you have any idea about how should we do this conversion please let me know!

Also if you happen to know about any drawbacks of such a change please let me know as well. The only thing what I am thinking about is the fact that the libkode is used in KDSoap and such a change would make cherry-picking difficult.

Thank you for your feedback in advance!

dfaure-kdab commented 4 years ago

I am 100% in favour of using the Qt coding style.

For consistency with most Qt code out there -- and for easier diffing with the fork in KDSoap which ended up being reformatted by mistake.

In terms of tooling I can recommend astyle-kdelibs or better, uncrustify-kf5, both from the kde-dev-scripts git repository. Even better would be clang-format but we don't have a finalized format file for it yet (well, in KDE. Maybe the Qt one is a solution). See https://code.qt.io/cgit/qt/qt5.git/tree/_clang-format and https://phabricator.kde.org/D24568 if you want to spend time on this. But uncrustify is easier for now, it will just work out of the box.

Anyhow, this is Cornelius' baby, it's up to him to decide.

martonmiklos commented 4 years ago

Many thanks for your feedback David!

BTW. I was wondering about what was the reason why you decided to copy paste the libkode to the KDSoap? (Instead of using it as a submodule)

dfaure-kdab commented 4 years ago

IIRC this all started in SVN times (no submodules back then), and then we had to make some changes in our copy, and then it got reformatted by accident, with more changes after that, and now it's a pain to reconciliate. If someone wants to do that, though, I'm all for it...

martonmiklos commented 4 years ago

Well I am using the libkode (copies from the kode) in different projects as well, and I think it could be beneficial for others as well having a separated off-the-shelf Qt based code generation library. But that's a different topic.

cornelius commented 4 years ago

I'm not attached to any particular coding style here. Using a standard such as the Qt one sounds great to me. Having clang-format or something like that to support that by automatic checks and formatting would be great. The more automatic it is, the better, from my point of view.

I also wouldn't object to a complete reformatting of the code if that makes it consistent with a well-defined coding-style and makes it possible to automatically check it. It would be good to isolate formatting changes in as few commits as possible in this case.

Are there any GitHub Actions which would help with enforcing a style on pull requests? Maybe by commenting on code which violates style rules or at least by a CI check which fails if there issues?

martonmiklos commented 4 years ago

Thanks for your answer Cornelius! I think we can agree on utilizing the Qt coding style in the future. Continous checks makes sense, I have found an off-the-shelf github action for clang-format code style checking: https://github.com/marketplace/actions/clang-format-lint I will test it and get it added to the project after we finished the code reformatting.