igmpproxy
igmpproxy copied to clipboard
Introduce default format for code base.
The first commit introduces a new goal: make reformat based on clang-reformat (at least version 3.9 should be used).
This target is optional.
The second commit contains all changes after the execution of this command.
In the future committers can normalize their code by simply using the make goal.
It is a good idea to have just one consistent coding style in whole project, but I dislike your proposed code style where are too many spaces around parenthesis. E.g. spaces around void in
static void debugQueue( void );
Actually I don't mind which formatting style is to be used. For me it's only important that there is one and that formatting is consistent all over the code base.
There are even some defaults styles (LLVM, Google, Chromium, Mozilla, WebKit) which could used:
http://releases.llvm.org/3.9.0/tools/clang/docs/ClangFormatStyleOptions.html
Just choose a style and we can stick to it.
Try something like this?
BasedOnStyle: LLVM
Language: Cpp
IndentWidth: 4
ColumnLimit: 120
AllowShortFunctionsOnASingleLine: Empty
AlwaysBreakBeforeMultilineStrings: true
AFAIK AllowShortFunctionsOnASingleLine should be either true or false.
I would suggest having UseTab: Never as one of the mandatory options as the mixture of tabs and whitespaces really messes diffs up.
Having also MaxEmptyLinesToKeep: 1 or MaxEmptyLinesToKeep: 2 might be useful, too.
BTW I already pushed another version of reformatted source code settings (based on the initial format settings) when writting https://github.com/pali/igmpproxy/pull/19#issuecomment-299673664 , so you might want to check, if you like it more.
AFAIK
AllowShortFunctionsOnASingleLineshould be eithertrueorfalse
According to http://releases.llvm.org/3.9.0/tools/clang/docs/ClangFormatStyleOptions.html possible values are: None, Empty, Inline, All
I would suggest having
UseTab: Never
Already part of BasedOnStyle: LLVM
Having also
MaxEmptyLinesToKeep: 1
Also part of BasedOnStyle: LLVM
or
MaxEmptyLinesToKeep: 2might be useful, too.
BasedOnStyle: LLVM set it to 1, but 2 seems to be better value.
AFAIK
AllowShortFunctionsOnASingleLineshould be eithertrueorfalse
According to http://releases.llvm.org/3.9.0/tools/clang/docs/ClangFormatStyleOptions.html possible values are:
None,Empty,Inline,All
You are right. (saw the boolean option here https://clangformat.com/)
I would suggest having
UseTab: Never
Already part of
BasedOnStyle: LLVM
It was more meant to be explicit.
I update the PR using these settings:
BasedOnStyle: LLVM
Language: Cpp
IndentWidth: 4
ContinuationIndentWidth: 8
ColumnLimit: 120
MaxEmptyLinesToKeep: 2
AllowShortFunctionsOnASingleLine: Empty
AlwaysBreakBeforeMultilineStrings: true
Changed the mentioned part manually so that future calls of make reformat should work there nicely.
@ViToni seems that auto-reformat by robot/machine for everything does not work as expected. After automatic reformat it needs some manual work to fix some parts. So I do not think that "make reformat" target is a good idea.
But, this is really an improvement for the code... so are you going to fix needed parts manually and finish this work in this pull request?