I clang-format a lot of my patches, and one common complaint recently has been clang-format's behavior to collapse short function bodies into one line.1) What's the best place to have discussion about clang-format feedback to get agreement on desired behavior? Is there (or should there be) a formal set of Chromium style owners?2) What should clang-format do with short inline bodies? The current options are "always on a single line" or "never on a single line". One reviewer suggested having a 'strict' compliance mode where clang-format only makes changes strictly necessary to bring something into style compliance
(e.g. indent, parameter alignment) but not other things (I assume examples of things that'd fall into this category are single-line ifs, etc). I don't know if the clang-format team would be willing to implement this though.3) What's the feasibility of just using clang-format everywhere so developers/reviewers can spend less time on these sort of things? There is still code it's unable to format well, but you can now disable/enable clang-format in a block by using// clang-format off/* hard to format code here ... */// clang-format onand outside of the feedback about collapsing inline bodies into one line, it seems like it's doing a pretty good job overall.Daniel
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
On Tue, Oct 28, 2014 at 4:45 PM, Daniel Cheng <dch...@chromium.org> wrote:I clang-format a lot of my patches, and one common complaint recently has been clang-format's behavior to collapse short function bodies into one line.1) What's the best place to have discussion about clang-format feedback to get agreement on desired behavior? Is there (or should there be) a formal set of Chromium style owners?2) What should clang-format do with short inline bodies? The current options are "always on a single line" or "never on a single line". One reviewer suggested having a 'strict' compliance mode where clang-format only makes changes strictly necessary to bring something into style complianceHow would you detect this, without using clang-format?
// clang-format off/* hard to format code here ... */// clang-format onand outside of the feedback about collapsing inline bodies into one line, it seems like it's doing a pretty good job overall.
Daniel
-- BR Maciej Pawlowski Opera Desktop Wroclaw
I clang-format a lot of my patches, and one common complaint recently has been clang-format's behavior to collapse short function bodies into one line.1) What's the best place to have discussion about clang-format feedback to get agreement on desired behavior? Is there (or should there be) a formal set of Chromium style owners?2) What should clang-format do with short inline bodies? The current options are "always on a single line" or "never on a single line".
1) What's the best place to have discussion about clang-format feedback to get agreement on desired behavior? Is there (or should there be) a formal set of Chromium style owners?
2) What should clang-format do with short inline bodies? The current options are "always on a single line" or "never on a single line".
3) What's the feasibility of just using clang-format everywhere so developers/reviewers can spend less time on these sort of things? There is still code it's unable to format well, but you can now disable/enable clang-format in a block by using// clang-format off/* hard to format code here ... */// clang-format onand outside of the feedback about collapsing inline bodies into one line, it seems like it's doing a pretty good job overall.
On Tue, Oct 28, 2014 at 4:45 PM, Daniel Cheng <dch...@chromium.org> wrote:1) What's the best place to have discussion about clang-format feedback to get agreement on desired behavior? Is there (or should there be) a formal set of Chromium style owners?If you need to engage people about Chromium style overall, I suggest at least roping in thakis, jam, and me, as all of us have contributed meaningfully to the Chromium style guide.2) What should clang-format do with short inline bodies? The current options are "always on a single line" or "never on a single line".I agree with Nico's mail: there is nothing in the Chromium style guide that objects to what clang-format is currently doing (always a single line where possible), it's reasonably common in the codebase already (even pre-clang-format), and it's seemingly allowed by the Google style guide, so I think it's fine. People should not be pushing back against it.3) What's the feasibility of just using clang-format everywhere so developers/reviewers can spend less time on these sort of things? There is still code it's unable to format well, but you can
now disable/enable clang-format in a block by using// clang-format off/* hard to format code here ... */// clang-format onand outside of the feedback about collapsing inline bodies into one line, it seems like it's doing a pretty good job overall.In general I've seen fewer pushbacks against people who've used clang-format recently. I think its use is already fairly widespread, although it doesn't seem like we'll ever do something as drastic as clang-formatting the whole codebase.My personal opinion of it has improved; at this point my only real axe to grind is that clang-format still formats ?: in a way that I read as violating the Chromium style guide, and never existed in the codebase before clang-format itself started introducing it everywhere; and despite (I thought) someone claiming ownership of this issue many months ago it's never been changed. Other than that, I think clang-format's behavior and my opinions of its behavior have both converged towards agreement that it's doing OK. I don't know what others think.PK
--
On Wed, Oct 29, 2014 at 3:38 PM, Peter Kasting <pkas...@chromium.org> wrote:On Tue, Oct 28, 2014 at 4:45 PM, Daniel Cheng <dch...@chromium.org> wrote:1) What's the best place to have discussion about clang-format feedback to get agreement on desired behavior? Is there (or should there be) a formal set of Chromium style owners?If you need to engage people about Chromium style overall, I suggest at least roping in thakis, jam, and me, as all of us have contributed meaningfully to the Chromium style guide.2) What should clang-format do with short inline bodies? The current options are "always on a single line" or "never on a single line".I agree with Nico's mail: there is nothing in the Chromium style guide that objects to what clang-format is currently doing (always a single line where possible), it's reasonably common in the codebase already (even pre-clang-format), and it's seemingly allowed by the Google style guide, so I think it's fine. People should not be pushing back against it.3) What's the feasibility of just using clang-format everywhere so developers/reviewers can spend less time on these sort of things? There is still code it's unable to format well, but you canI add it to PRESUBMITs where I work a lot because reviewing style is annoying, and I'd rather let a tool do it. I suggest everyone does the same.
On Wed, Oct 29, 2014 at 12:40 PM, Dana Jansens <dan...@chromium.org> wrote:On Wed, Oct 29, 2014 at 3:38 PM, Peter Kasting <pkas...@chromium.org> wrote:On Tue, Oct 28, 2014 at 4:45 PM, Daniel Cheng <dch...@chromium.org> wrote:1) What's the best place to have discussion about clang-format feedback to get agreement on desired behavior? Is there (or should there be) a formal set of Chromium style owners?If you need to engage people about Chromium style overall, I suggest at least roping in thakis, jam, and me, as all of us have contributed meaningfully to the Chromium style guide.2) What should clang-format do with short inline bodies? The current options are "always on a single line" or "never on a single line".I agree with Nico's mail: there is nothing in the Chromium style guide that objects to what clang-format is currently doing (always a single line where possible), it's reasonably common in the codebase already (even pre-clang-format), and it's seemingly allowed by the Google style guide, so I think it's fine. People should not be pushing back against it.3) What's the feasibility of just using clang-format everywhere so developers/reviewers can spend less time on these sort of things? There is still code it's unable to format well, but you canI add it to PRESUBMITs where I work a lot because reviewing style is annoying, and I'd rather let a tool do it. I suggest everyone does the same.FWIW, those PRESUBMIT checks have caused problems in my Windows checkout -- e.g. getting unreadable messages about "<function at offset 0xffed55ba> needs formatting" (I'm working from memory, the actual error may have been a different unreadable string than that) -- and they're more aggressive than they really should be (as Daniel mentioned, clang-format does more than is absolutely necessary, so sometimes you'll get "should be reformatted" messages about code that's perfectly legal per the Chromium style guide just because clang-format would have picked a different way).
On Wed, Oct 29, 2014 at 3:55 PM, Peter Kasting <pkas...@chromium.org> wrote:On Wed, Oct 29, 2014 at 12:40 PM, Dana Jansens <dan...@chromium.org> wrote:On Wed, Oct 29, 2014 at 3:38 PM, Peter Kasting <pkas...@chromium.org> wrote:On Tue, Oct 28, 2014 at 4:45 PM, Daniel Cheng <dch...@chromium.org> wrote:1) What's the best place to have discussion about clang-format feedback to get agreement on desired behavior? Is there (or should there be) a formal set of Chromium style owners?If you need to engage people about Chromium style overall, I suggest at least roping in thakis, jam, and me, as all of us have contributed meaningfully to the Chromium style guide.2) What should clang-format do with short inline bodies? The current options are "always on a single line" or "never on a single line".I agree with Nico's mail: there is nothing in the Chromium style guide that objects to what clang-format is currently doing (always a single line where possible), it's reasonably common in the codebase already (even pre-clang-format), and it's seemingly allowed by the Google style guide, so I think it's fine. People should not be pushing back against it.3) What's the feasibility of just using clang-format everywhere so developers/reviewers can spend less time on these sort of things? There is still code it's unable to format well, but you canI add it to PRESUBMITs where I work a lot because reviewing style is annoying, and I'd rather let a tool do it. I suggest everyone does the same.FWIW, those PRESUBMIT checks have caused problems in my Windows checkout -- e.g. getting unreadable messages about "<function at offset 0xffed55ba> needs formatting" (I'm working from memory, the actual error may have been a different unreadable string than that) -- and they're more aggressive than they really should be (as Daniel mentioned, clang-format does more than is absolutely necessary, so sometimes you'll get "should be reformatted" messages about code that's perfectly legal per the Chromium style guide just because clang-format would have picked a different way).From my POV, I don't really care if the code as-it-was was legal or not, I vastly prefer just not having to worry about it and nitpick over it as a reviewer.
And from that point on, the code formatting will remain stable.
I think the Google style is actually pretty stable. I could be wrong about this (I don't have any data to back this up), but I imagine many of the wider impact clang-format formatting changes have been driven by our feedback to the clang-format team about the bugs/specifics of Chromium style handling. I imagine this churn should go down over time.
On Tue, Oct 28, 2014 at 4:45 PM, Daniel Cheng <dch...@chromium.org> wrote:1) What's the best place to have discussion about clang-format feedback to get agreement on desired behavior? Is there (or should there be) a formal set of Chromium style owners?If you need to engage people about Chromium style overall, I suggest at least roping in thakis, jam, and me, as all of us have contributed meaningfully to the Chromium style guide.2) What should clang-format do with short inline bodies? The current options are "always on a single line" or "never on a single line".I agree with Nico's mail: there is nothing in the Chromium style guide that objects to what clang-format is currently doing (always a single line where possible), it's reasonably common in the codebase already (even pre-clang-format), and it's seemingly allowed by the Google style guide, so I think it's fine. People should not be pushing back against it.
3) What's the feasibility of just using clang-format everywhere so developers/reviewers can spend less time on these sort of things? There is still code it's unable to format well, but you can now disable/enable clang-format in a block by using// clang-format off/* hard to format code here ... */// clang-format onand outside of the feedback about collapsing inline bodies into one line, it seems like it's doing a pretty good job overall.In general I've seen fewer pushbacks against people who've used clang-format recently. I think its use is already fairly widespread, although it doesn't seem like we'll ever do something as drastic as clang-formatting the whole codebase.My personal opinion of it has improved; at this point my only real axe to grind is that clang-format still formats ?: in a way that I read as violating the Chromium style guide, and never existed in the codebase before clang-format itself started introducing it everywhere; and despite (I thought) someone claiming ownership of this issue many months ago it's never been changed. Other than that, I think clang-format's behavior and my opinions of its behavior have both converged towards agreement that it's doing OK. I don't know what others think.PK
--
2014-10-29 12:55 GMT-07:00 Peter Kasting <pkas...@chromium.org>:
> On Wed, Oct 29, 2014 at 12:40 PM, Dana Jansens <dan...@chromium.org> wrote:
>> I add it to PRESUBMITs where I work a lot because reviewing style is
>> annoying, and I'd rather let a tool do it. I suggest everyone does the same.
Strongly seconded. A PRESUBMIT is absolutely the right place for this
check to lessen review burden.
> FWIW, those PRESUBMIT checks have caused problems in my Windows checkout --
> e.g. getting unreadable messages about "<function at offset 0xffed55ba>
> needs formatting"
Fixed in https://codereview.chromium.org/665493002 last week.
> FWIW, those PRESUBMIT checks have caused problems in my Windows checkout --
> e.g. getting unreadable messages about "<function at offset 0xffed55ba>
> needs formatting"
Fixed in https://codereview.chromium.org/665493002 last week.
On Wed, Oct 29, 2014 at 1:22 PM, Daniel Cheng <dch...@chromium.org> wrote:I think the Google style is actually pretty stable. I could be wrong about this (I don't have any data to back this up), but I imagine many of the wider impact clang-format formatting changes have been driven by our feedback to the clang-format team about the bugs/specifics of Chromium style handling. I imagine this churn should go down over time.I suspect you're correct.Also recall that I've been one of the only advocates in the past for "let's go ahead and clang-format the whole codebase", so I could certainly live in a world where we did that sort of thing. The world in between nothing and everything is awkward, though.
Frankly, if we're really convinced clang-format is correct, I might prefer the tools just auto-clang-format my code than warning me about it in PRESUBMIT. Dunno.