-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add clang-format configuration #1585
base: develop
Are you sure you want to change the base?
Conversation
@IvanSavenko please, consider this differences:
|
@rilian-la-te
|
@rilian-la-te
|
About 'BreakConstructorInitializersBeforeComma' - for new clang-format it is deprecated and replaced by BreakConstructorInitializers. I strongly prefer AfterColon style, it just looks more natural for me. |
About SplitEmptyFunction - it seems than old code uses True. |
my personal preferences on the differences: AllowShortFunctionsOnASingleLine: Empty BreakBeforeInheritanceComma: no idea as not in docs. Based on the name it's about class A : public B, public C {};
// for consistency we may use same as BreakConstructorInitializers
class A : public B
, public C
{
};
// or even
class A
: public B
, public C
{
}; but at the same time multiple inheritance is a rather rare thing (and adding new parent is even rarer) and would be fine to just have all parents on a single line. |
Second attempt at clang-format, slightly improved & corrected version compared to previous PR.
It is still not perfect, but I've been using it recently with quite good results. So proposing to add it to our repo and use it as guideline for formatting.
I do not think that clang-format is good enough for automatic usage, e.g. in that git+clang-format tool but only as a base guideline. Meaning, code still needs basic readability pass by a developer, however with clang-format you can forget about "basic" stuff like spacing.
Example of such usage is my PR #1581, for example these two files:
https://github.com/IvanSavenko/vcmi/blob/map_render_rewrite/client/adventureMap/MapRenderer.cpp
https://github.com/IvanSavenko/vcmi/blob/map_render_rewrite/client/adventureMap/MapRenderer.h
I think at this point we can add it to repo, let everyone else try it and do any further changes based on everyone's opinion.