Closed
Bug 1508281
Opened 6 years ago
Closed 6 years ago
See if we need to turn off clang-format anywhere in toolkit/components/telemetry
Categories
(Toolkit :: Telemetry, enhancement, P1)
Toolkit
Telemetry
Tracking
()
RESOLVED
FIXED
mozilla65
Tracking | Status | |
---|---|---|
firefox65 | --- | fixed |
People
(Reporter: chutten, Assigned: janerik)
References
Details
Attachments
(1 file)
As mentioned on dcamp-all the style for whitespace is changing and will be enforced using clang-format. We should see what this looks like for our C++ code and if we need to code some exemptions.
Of particular note may be our generated source files. They shouldn't be checked, but we should verify/ask Ehsan about it.
Reporter | ||
Updated•6 years ago
|
Summary: Assess fallout from style change → See if we need to turn off clang-format anywhere in toolkit/components/telemetry
Comment 1•6 years ago
|
||
Generated source files shouldn't be checked, no. If they are, that's a bug. :-)
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → jrediger
Points: --- → 1
Priority: -- → P1
Reporter | ||
Comment 2•6 years ago
|
||
This repo has clang-format applied https://github.com/sylvestre/gecko-dev/blob/master/toolkit/components/telemetry/core/
Assignee | ||
Comment 3•6 years ago
|
||
I've gone through core/ipc, geckoview/, other/ and tests/gtest so far.
Some notable things:
* `private:`, `public:`, etc. are indented by one space, which feels odd.
* the 80-character limit is causing quite a bit of churn (I would have preferred 100 chars, but consistency over personal preference!)
* a lot of actual indentation fixes and repositioning of `&` and `*` (close to the type, not the name) (Yey!)
Given that we can also use clang-format in the future to keep it all that way, nothing of that blocks the reformatting.
Next: our core code.
Assignee | ||
Comment 4•6 years ago
|
||
One more thing: our mode lines are now broken into 2 lines:
this:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
becomes this:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*-
*/
I haven't checked myself, but seen it elsewhere in the code that it wasn't broken off when the line started with `/**` (two stars). (Switching that everywhere now is too much effort IMO for little gain.)
Assignee | ||
Comment 5•6 years ago
|
||
For core/:
* Some nicely manually aligned things are now (auto-)unaligned. IMO that is fine and not too distracting.
* sorted `using` lines. Hooray!
* I still don't like that the 80-char limit pushed a lot of our log messages to a new line
Some things I am not happy about:
1. This is weird formatting (https://github.com/sylvestre/gecko-dev/commit/b071d70cefcbf29193b1ad945dfb27ce503988a4#diff-22609026e88184f2cd2fd52da58a8d45R1796):
TelemetryScalar::Add(mozilla::Telemetry::ScalarID::
TELEMETRY_ACCUMULATE_UNKNOWN_HISTOGRAM_KEYS,
NS_ConvertASCIItoUTF16(gHistogramInfos[id].name()), 1);
2. Our nicely manually formatted huge static_assert got messed up as well:
https://github.com/sylvestre/gecko-dev/commit/b071d70cefcbf29193b1ad945dfb27ce503988a4#diff-22609026e88184f2cd2fd52da58a8d45R1997
3. Doc strings over multiple lines have their leading whitespace removed (only including one example here, there are more):
https://github.com/sylvestre/gecko-dev/commit/b071d70cefcbf29193b1ad945dfb27ce503988a4#diff-f0ef017ddb34a0abd2ef6bf4e0592409R1483
4. Our example of the returned JSON got split across lines:
https://github.com/sylvestre/gecko-dev/commit/b071d70cefcbf29193b1ad945dfb27ce503988a4#diff-f0ef017ddb34a0abd2ef6bf4e0592409R2853
5. Our example of the returned JSON got concatenated to the previous line (because no empty line in between?):
https://github.com/sylvestre/gecko-dev/commit/b071d70cefcbf29193b1ad945dfb27ce503988a4#diff-f0ef017ddb34a0abd2ef6bf4e0592409R2940
Assignee | ||
Comment 6•6 years ago
|
||
Nothing of the above (or anything I didn't mention) changes any semantics and IMO it's mostly an improvement.
Should we do anything about the above?
Flags: needinfo?(gfritzsche)
Flags: needinfo?(chutten)
Flags: needinfo?(alessio.placitelli)
Comment 7•6 years ago
|
||
One note about mode-lines and mis-formatted comments: I'm spending time in bug 1508472 to go across the entire tree and do a best effort attempt at preserving as much of the comment formatting as I humanly can. :-) (I have yet to get to toolkit/). If you'd like to assist with the telemetry part, that would be a huge help!
Also about cases where clang-format misformats things like carefully lined up static_assert's and what not, you should feel free to use // clang-format off/on blocks around such code to preserve the formatting where it makes sense. If you use dxr/searchfox to search for existing occurrences you can find a lot of examples already. (I'd be happy to help review such patches if needed!)
Assignee | ||
Comment 8•6 years ago
|
||
4 + 5 can be ignored, those lines are actually gone in m-c (documentation resides in nsITelemetry.idl)
I will add the clang-format off for the static_assert (number 2 from above list).
That leaves 1 and 3.
Reporter | ||
Comment 9•6 years ago
|
||
(In reply to Jan-Erik Rediger [:janerik] from comment #5)
> For core/:
>
> * Some nicely manually aligned things are now (auto-)unaligned. IMO that is
> fine and not too distracting.
> * sorted `using` lines. Hooray!
> * I still don't like that the 80-char limit pushed a lot of our log messages
> to a new line
>
>
> Some things I am not happy about:
>
> 1. This is weird formatting
> (https://github.com/sylvestre/gecko-dev/commit/
> b071d70cefcbf29193b1ad945dfb27ce503988a4#diff-
> 22609026e88184f2cd2fd52da58a8d45R1796):
>
> TelemetryScalar::Add(mozilla::Telemetry::ScalarID::
> TELEMETRY_ACCUMULATE_UNKNOWN_HISTOGRAM_KEYS,
> NS_ConvertASCIItoUTF16(gHistogramInfos[id].name()),
> 1);
My biggest problem with this one is that it indents by four spaces instead of two.
I wonder if there are many conforming formats here... whether we could adjust the formatting ourselves ahead of time to avoid this.
> 3. Doc strings over multiple lines have their leading whitespace removed
> (only including one example here, there are more):
> https://github.com/sylvestre/gecko-dev/commit/
> b071d70cefcbf29193b1ad945dfb27ce503988a4#diff-
> f0ef017ddb34a0abd2ef6bf4e0592409R1483
Ugh. Ehsan, any hints/tips/tricks for this?
Flags: needinfo?(chutten)
Comment 10•6 years ago
|
||
(In reply to Chris H-C :chutten from comment #9)
> > 3. Doc strings over multiple lines have their leading whitespace removed
> > (only including one example here, there are more):
> > https://github.com/sylvestre/gecko-dev/commit/
> > b071d70cefcbf29193b1ad945dfb27ce503988a4#diff-
> > f0ef017ddb34a0abd2ef6bf4e0592409R1483
>
> Ugh. Ehsan, any hints/tips/tricks for this?
I preemptively answered in comment 7. Does that help?
Reporter | ||
Comment 11•6 years ago
|
||
I didn't quite understand what part of comment 7 would help us here. Waiting for you to slog through the rest of comment-land seemed like the least scalable answer :)
Comment 12•6 years ago
|
||
(In reply to Chris H-C :chutten from comment #11)
> I didn't quite understand what part of comment 7 would help us here. Waiting
> for you to slog through the rest of comment-land seemed like the least
> scalable answer :)
To rephrase, what I was trying to say was: there is no automated tooling here that can automatically format arbitrary comments including various ASCII art and whitespace alignments. If you don't do anything in particular here I will get to the occurrences of issues like number 3 in bug 1508472 (not because that's a scalable way to solve this problem, but because going through a ~4MB diff is a soul crushing task that nobody else was really in a rush to volunteer to do!). I'm trying to do my best to ensure that I catch all of the instances of issues like number 3 in that bug (you can have a look at the patches that have landed there already.)
In case you'd be willing to lend a hand and help going through toolkit/components/telemetry and take care of misformatted comments similar to how I've been doing that there, I would highly appreciate that. If you'd like to do that, you can download attachment 9027674 [details] and find the changes to toolkit/components/telemetry there and see what comments have been misformatted in that diff and fix them on m-c before Friday. In that case, please do let me know so that we don't duplicate work. :-) (If you need help please ping me on IRC/slack.) Thanks!
Comment 13•6 years ago
|
||
OK, I'm now starting to look at the toolkit/components/telemetry portions of the comments diff in bug 1508472. :-) I'll post the results on the bug in a few hours.
Assignee | ||
Comment 14•6 years ago
|
||
Comment 15•6 years ago
|
||
(In reply to Jan-Erik Rediger [:janerik] from comment #6)
> Should we do anything about the above?
I'd vote for disabling messing with the static_asserts, as you suggested :)
Flags: needinfo?(alessio.placitelli)
Comment 16•6 years ago
|
||
Pushed by jrediger@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/15fb49ca9d9f
Don't reformat long static_assert r=chutten
Assignee | ||
Comment 17•6 years ago
|
||
With the limited time remaining, I will land the static_assert fix only. If :ehsan was able to go through the comment parts even better, if not we should fix the then-misaligned comments after the merge.
Comment 18•6 years ago
|
||
(In reply to Jan-Erik Rediger [:janerik] from comment #17)
> With the limited time remaining, I will land the static_assert fix only. If
> :ehsan was able to go through the comment parts even better, if not we
> should fix the then-misaligned comments after the merge.
I did, it's fixed as part of https://hg.mozilla.org/mozilla-central/rev/04f0bbf40bf3.
Comment 19•6 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 6 years ago
status-firefox65:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Assignee | ||
Updated•6 years ago
|
Flags: needinfo?(gfritzsche)
You need to log in
before you can comment on or make changes to this bug.
Description
•