Following up here, since it's been ~a month since these landed.
The clang-tidy checks we landed were:
- modernize-bind
- modernize-make-unique
- modernize-use-default-member-init
- modernize-use-emplace
- modernize-use-noexcept
The only two of these that've fired since they were enabled are `modernize-use-default-member-init` and `modernize-use-emplace`. The rest had a very low number of occurrences in Chromium to start with, so it's unsurprising that they've been quiet. I don't think the "not useful" rates are large enough to reconsider the addition of these checks.
More details:
`modernize-use-default-member-init` has appeared on 76 pieces of code, and has been marked "not useful" 6 times. So, we have a 7.8% not useful rate (drops to 1.3% if my guesses below are right).
- 4 of the 6 were on lines "fuzzed" by Tricium. i.e., lines outside of the diff, but which still receive "while you're super close, can we also..." linting complaints. I think Chromium's setting for clang-tidy is 1 line of fuzz distance, so these often looked like
```
bool old_member_; // clang-tidy: hey please add `= false;` here, too.
bool newly_added_member = false;
```
Given that members are often grouped like this, I'm unsurprised that fuzzing catches things semi-often here :)
- 1 of the 6 was not useful presumably because a CL reviewer saw tidy's comment and suggested a better pattern overall (which included marking the member in question `const`, which means clang-tidy's suggestion wasn't possible to follow)
- In the final one, there was already a strong local style of a default ctor init'ing tons of constants out-of-line, e.g.:
```
struct Foo {
Foo();
int m1, m2, m3, m4, m5;
};
Foo::Foo(): m1(0), m2(1), m3(2) /* ... */ {}
```
`modernize-use-emplace` has appeared on 15 pieces of code, and has been marked "not useful" 3 times. So, we have a low sample size 20% not-useful rate. Of these, 1 "not useful" wasn't addressed. So more like 6% maybe?
- On the first, the reviewer clicked "please fix", and it was fixed by the owner without complaint.
- The second was marked "Not useful" initially, then silently fixed in a later patch-set without prompting. Similar "not sure what happened there."
- The final one was the most interesting. The dev got two of these diagnostics in the same CL, and proceeded to fix one of them && mark the other "Not useful":
Not fixed:
foo.push_back(Bar{}); // suggested: foo.emplace_back();
Fixed:
foo.push_back({std::move(a), std::move(b)}); // suggested: foo.emplace_back(std::move(a), std::move(b));
I assume the complaint is `foo.emplace_back();` is too implicit about the construction of a `Bar{}`. I agree that visually, `foo.emplace_back();` is less pronounced than `foo.push_back(Bar{});`, but enough to warrant a special case? ¯\_(ツ)_/¯
Again, these rates don't seem highly problematic to me. Unless anyone feels differently, I'm happy to consider these landed now.
Thanks,
George