--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
I'm mostly in favor, but there are still cases, particularly with data tables, where hand-formatting is much clearer. For example, something like:[0, 0, 0, 0][0, 255, 0, 255][0, 0, 0, 0]where clang-format will collapse everything. If it's OK to // clang-format off things like that, where it's not a bug in clang-format but that external semantics make it suboptimal, I'd be on board.
AviOn Wed, Feb 8, 2017 at 1:48 PM, Brett Wilson <bre...@chromium.org> wrote:I used to be opposed to this but I've been worn down and have no opinion any more.
On Wed, Feb 8, 2017 at 10:54 AM, Avi Drissman <a...@chromium.org> wrote:I'm mostly in favor, but there are still cases, particularly with data tables, where hand-formatting is much clearer. For example, something like:[0, 0, 0, 0][0, 255, 0, 255][0, 0, 0, 0]where clang-format will collapse everything. If it's OK to // clang-format off things like that, where it's not a bug in clang-format but that external semantics make it suboptimal, I'd be on board.It's a presubmit check, so in cases like this I think it seems reasonable to undo the formatting.
+1
On Wed, Feb 8, 2017 at 10:55 AM, Dan Beam <db...@chromium.org> wrote:+1I highly recommend locally running clang-format and analyzing gaps before turning on checks (if at all feasible, maybe even just to understand what issues we'll hit).Backstory: I dropped the JS linter in favor of clang-format. In this process, I found some issues by running clang-format on many .js files in chrome (mainly ASI and GRIT's <if/include>). I consulted folks working on clang-format and ended up fixing some issues and tweaking the upstream clang-format -style=Chromium before turning on more checks. I just reallly didn't want these problems to come up one-by-one, likely caught by others, at possibly inopportune times. I skipped blink's layout tests, for example, got CC'd on a bug found there.
I don’t think that clang-format is ready for us to enforce in this way. I’m impressed with the progress that it’s made, and it’s much better than the last time I looked at it, but I still find myself fighting it fairly regularly. I don’t doubt that if they keep up with improvements, it’ll reach the point where we can start enforcing it more widely.I ran clang-format in Crashpad and found a number of things that it did that are no better and no worse than what was there before. It did a few things that were clearly better too, but I also found it doing some things that were obviously wrong. Some patterns of bad behavior recur frequently.I put these notes together with an eye toward providing constructive feedback on why I don’t think we can do this now. I’ve sorted these in mostly descending order of severity. Some of these problems may be specific to the local styles that we use in Crashpad. Running it over any other arbitrary directory may not highlight these quirks, and may reveal others.
This thing that it does with data tables just means that whenever someone comes along and wants to insert a new element in the middle, or change an existing element so that the column widths need to change, the whole table has to move around, along with blame. 1, 2, 3It’s also quirky inside macro definitions. It doesn’t seem to understand that a UTF-8 sequence should count as one column (here) and its lack of context makes it do strange
things gratuitously (here). It seems to enforce different style rules in macros than it does elsewhere (here and several other examples in that file, related to the bit-wise & operator, but oddly not on line 218).Other interactions with preprocessor #directives seem wrong. Here, it formats the preprocessor-free arrays at lines 309 and 316 with a +4 indent for elements. The array at line 325, which has some preprocessor stuff going on, is inconsistent in that its elements are given a +2 indent.Sometimes, I can’t tell why it’s doing what it’s doing. It seems to favor reducing the number of lines that code takes in many cases, so it’s puzzling here when it lumps as much as it can onto line 83 and then leaves lines 84 and 85 virtually empty by comparison (similar). It’s also puzzling in these cases (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) where it takes two style-legal lines and turns them into three (here’s a slightly different pattern: 1, 2, 3, 4, 5, 6).
Comments inline. I will say that it seems like a lot of the clearly wrong problems are due to preprocessor things… with the exception of indenting of comments before a preprocessor directive, I expect the other issues would be relatively rare in most of Chrome.
On Wed, Feb 8, 2017 at 6:26 PM Mark Mentovai <ma...@chromium.org> wrote:I don’t think that clang-format is ready for us to enforce in this way. I’m impressed with the progress that it’s made, and it’s much better than the last time I looked at it, but I still find myself fighting it fairly regularly. I don’t doubt that if they keep up with improvements, it’ll reach the point where we can start enforcing it more widely.I ran clang-format in Crashpad and found a number of things that it did that are no better and no worse than what was there before. It did a few things that were clearly better too, but I also found it doing some things that were obviously wrong. Some patterns of bad behavior recur frequently.I put these notes together with an eye toward providing constructive feedback on why I don’t think we can do this now. I’ve sorted these in mostly descending order of severity. Some of these problems may be specific to the local styles that we use in Crashpad. Running it over any other arbitrary directory may not highlight these quirks, and may reveal others.https://bugs.chromium.org/p/chromium/issues/detail?id=369454 is the bug that was filed for this. The heuristic clang-format uses is if there's a newline between the comment block and the preprocessor directive, the comment will remain indented; otherwise it gets aligned with the preprocessor directive. Personally, I'd find it to be odd to use a newline to get these semantics, so I'd encourage people to star/comment on the bug.
I'm not sure what's going on here. I pasted the snippet into a test.cc file and tried formatting, and the indentation on the comments was maintained. In fact, I'm pretty sure clang-format has some heuristic for maintaining end-of-line comments like this: after the Blink reformat, I saw a lot of end-of-line comments awkwardly squeezed into 20 columns over 4 lines. So… no clue, other than it works correctly for me
Daniel Cheng wrote:Comments inline. I will say that it seems like a lot of the clearly wrong problems are due to preprocessor things… with the exception of indenting of comments before a preprocessor directive, I expect the other issues would be relatively rare in most of Chrome.Thanks for the response and the bugs filed, Daniel.On Wed, Feb 8, 2017 at 6:26 PM Mark Mentovai <ma...@chromium.org> wrote:I don’t think that clang-format is ready for us to enforce in this way. I’m impressed with the progress that it’s made, and it’s much better than the last time I looked at it, but I still find myself fighting it fairly regularly. I don’t doubt that if they keep up with improvements, it’ll reach the point where we can start enforcing it more widely.I ran clang-format in Crashpad and found a number of things that it did that are no better and no worse than what was there before. It did a few things that were clearly better too, but I also found it doing some things that were obviously wrong. Some patterns of bad behavior recur frequently.I put these notes together with an eye toward providing constructive feedback on why I don’t think we can do this now. I’ve sorted these in mostly descending order of severity. Some of these problems may be specific to the local styles that we use in Crashpad. Running it over any other arbitrary directory may not highlight these quirks, and may reveal others.https://bugs.chromium.org/p/chromium/issues/detail?id=369454 is the bug that was filed for this. The heuristic clang-format uses is if there's a newline between the comment block and the preprocessor directive, the comment will remain indented; otherwise it gets aligned with the preprocessor directive. Personally, I'd find it to be odd to use a newline to get these semantics, so I'd encourage people to star/comment on the bug.
+1 to the wider presubmit in general but I have one huge pet peeve which I hope can be addressed (I think Mark already pointed this out, but I just hit it again today and it irked me): clang-format loves to reformat code even when it is currently not violating any style rules, e.g. it really wants to change:do_something_just_shy_of_80_chars(bar, baz, qux);todo_something_just_shy_of_80_chars(bar, baz,qux);I think this is a matter of personal style (right?) and I personally prefer the first one. If I try to format my code that way, clang-format rewrites it anyway. Sad!Can it be told to not change code that doesn't need to be changed?
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
I'mm all for turning on clang format for as much code as possible. But shouldn't you have waited more than ~6 hours before landing this after starting the discussion? Not much point in starting a discussion if you're not going to wait for people to give their opinion.
--
If the tool is going to be more tightly integrated into the source control, it would be nice if it at least remembered our preferences. If you ran the tool, and changed some lines back, it would be handy if it remembered that and didn't touch them again (until you changed them, or the preceding indent.)
(sorry, missed the replies yesterday)Mark: without going into details of the issues you point out, the reasoning was that we're already dealing with all these formatting issues through a) people running git cl format ., b) repo-wide changes running git cl format and c) a large part of the code was already using this. Since this is only an upload presubmit check, it can be ignored if you choose (and it doesn't affect other repos like crashpad).
On Fri, Feb 10, 2017 at 10:32 AM, John Abd-El-Malek <j...@chromium.org> wrote:(sorry, missed the replies yesterday)Mark: without going into details of the issues you point out, the reasoning was that we're already dealing with all these formatting issues through a) people running git cl format ., b) repo-wide changes running git cl format and c) a large part of the code was already using this. Since this is only an upload presubmit check, it can be ignored if you choose (and it doesn't affect other repos like crashpad).Hey John,In looking at your patch, I see a CheckPatchFormatted() in CheckChangeOnCommit() as well:This leads me to believe it'd stop a CQ. Is there something I'm missing here?When you say "Since this is only an upload presubmit check, it can be ignored if you choose", does this mean you're encouraging NOPRESUBMIT=true in CL descriptions to get around clang-format?
Presubmit warnings always seem to block the commit queue in my experience.
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/d4479d48-0349-451d-9d24-2f59358974bc%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAF3XrKrDvvu-qPxSMvPoxJqdpUysCJ2MoF-WdeBrRSgtu5NTqg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAMGbLiHXgTyLmQXd6fm4PD4S_LoF3vf%3DaYz_eN-4jKJenY%3DGXQ%40mail.gmail.com.
Having both on is silly, so I don't know if there's much point in making them match.If y'all don't consider clang-format good enough to be used for java code and prefer manually formatting your java code to match the presubmit thingy, we should disable clang-format. (And fix the issues that are considered blockers -- let me know which bugs these are.)Else we should disable the presubmit tool.So the bar shouldn't be "do they match" but "is clang-format good enough".