[
https://issues.apache.org/jira/browse/MESOS-1291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14006307#comment-14006307
]
Dominic Hamon commented on MESOS-1291:
--------------------------------------
using clang-format-3.5 the following should get us very close:
{code}
---
BasedOnStyle: Chromium
AccessModifierOffset: -2
AllowShortBlocksOnASingleLine: false # unrecognised in nightly
AllowShortFunctionsOnASingleLine: false
BinPackParameters: false
BreakBeforeBraces: Linux
ConstructorInitializerIndentWidth: 2
DerivePointerBinding: false
ForEachMacros: [foreach, foreachkey, foreachpair, foreachvalue] # unrecognised
in nightly
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
SpacesBeforeTrailingComments: 1
...
{code}
However I have been unable to get {{ForEachMacros}} to work. Given this is the
development version I'm not surprised.
We can approach this a couple of different ways, and I'd like to get input:
1. integrate clang-format as a precommit hook and update {{.clang-format}} as
new versions become available.
2. wait for clang-format-3.5 to become stable and then integrate it.
1 will mean that there'd be churn in the format as new features become
available, but it means we can stop caring about format issues in reviews right
now.
2 will mean waiting before we make any changes until we have something
approaching our current style guide, though it still won't match perfectly.
I prefer 1 as, even though the style we see won't exactly match what we'd like
the ultimate version to be, we can move away from caring about it and focus on
tweaking the format configuration instead of reviewing style nits.
In both cases we should find a balance between formatting changes to code as
its written (ie, only run the precommit on the lines changed) and updating the
format of older code.
> Use clang-format to automatically format code to style
> ------------------------------------------------------
>
> Key: MESOS-1291
> URL: https://issues.apache.org/jira/browse/MESOS-1291
> Project: Mesos
> Issue Type: Improvement
> Reporter: Dominic Hamon
> Labels: style
>
> Instead of relying on a script to check and report style errors, we should
> move to a workflow that allows people to write code how they feel comfortable
> and then automatically format it to conform to our style guide.
> The Chromium style from clang-format
> (http://clang.llvm.org/docs/ClangFormat.html) is very close to our style
> except for the dropped braces on class, struct, and function definitions, and
> two lines of whitespace between method definitions outside a class. As such,
> we should consider adopting clang-format and patching it to include a Mesos
> style variant.
> It can be run as part of post-reviews or as a git commit hook, or manually
> from within editors.
--
This message was sent by Atlassian JIRA
(v6.2#6252)