This patch adds two new options, feedback welcome.
SpacesAroundConditions (bool)
If true, spaces will be inserted around if/for/while conditions.
SpacesAfterNot (bool)
If true, spaces will be inserted after '!'.
Differential D25171
clang-format: Add two new formatting options rsmmr on Oct 2 2016, 6:31 PM. Authored by
Details
This patch adds two new options, feedback welcome. SpacesAroundConditions (bool) If true, spaces will be inserted around if/for/while conditions. SpacesAfterNot (bool) If true, spaces will be inserted after '!'.
Diff Detail Event TimelineComment Actions Thought I'd take a look at the list of diffs and take a stab at a few (a few easy-looking and short ones :) ) to unblock some ppl, and unless @djasper has strong opinions about it I'd say why not. Looking at other rules "nearby" I see spaces inside and outside square-brackets and angle-brackets, so it makes sense to allow this for conditions, especially if someone thinks this helps make it more readable, and for not as well (I personally like that one, it's easy to eyeball right past that !. Also it appears to be off by default and I assume the unit tests work :) Comment Actions Could you read: http://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options Comment Actions Sure, I'm aiming to use clang-format on a couple of open-source code bases using this style, with the main one being the Bro network security monitor, see www.bro.org and github.com/bro/bro (note the stars and forks :-) Bro is also featured on GitHub's list of security show cases, https://github.com/showcases/security. Comment Actions Sorry, but that's actually not enough, at least at first sight. With 37 contributors total, bro is still quite small and only 12 of them have more than a handful of commits. And it doesn't have a real style guide. It has: https://www.bro.org/development/contribute.html#coding-guidelines, which basically says "adapt to the existing code structure" and "We don’t have many strict rules". Comment Actions Well, last time I counted it was more like 100 contributors---Bro existed before GitHub (and before git). The style-guide is lacking, yes ... what can I say. I don't really want to argue about importance of the project. We would like to use clang-format here and elsewhere, and I'd think these options could be useful to others as well, so I created a patch and submitted. If you guys don't like it, your call. Comment Actions It's not about whether or not we like the patch. It's whether adding these options is a good trade-off for clang-format overall. If we find that actually more people would find these styles desirable, we can reconsider. I have left some comments anyway in case you want to keep the patch around.
|
It's actually more than if/for/while.