Mistakes I see engineers making in their code reviews

38 points by untitaker


seabre

The author seems to take Google's senior principle out of context a little bit. Here is the full quote from their guidelines:

In general, reviewers should favor approving a CL once it is in a state where it definitely improves the overall code health of the system being worked on, even if the CL isn’t perfect.

That is the senior principle among all of the code review guidelines.

I think "favor approvals once the overall code improves the general health of the system" and "bias toward favoring approvals" is very different with the former being very reasonable to me.

david_chisnall

Some good advice, but a few things I disagree with:

What do you do when there are twenty places in the diff that you’d like to see updated - for instance, twenty instances of camelCase variables instead of snake_case?

Code review should not have these comments, they are mechanically checkable. Formatting things should not be part of code review. Run your language’s equivalent of clang-format and clang-tidy in CI.

The kinds of naming convention things that should be in code review are rules about making methods verbs, noun-adjective naming order for types, avoiding abbreviations, and so on that can’t be mechanically checked.

Don’t review with a “how would I write it?” filter

I think this advice can lead to losing some of the benefits of code review. Asking how I would write it first leads to a few positive things:

Review with a “will this work” filter, not with a “is this exactly how I would have done it” filter

I really dislike when code review is expected to catch the ‘will this work?’ bit. That’s what tests are for. The code review then focuses on which test cases are missing. Some things (subtle concurrency issues, for example) may be too hard to test and then ‘will it work?’ reviews are unavoidable, but they shouldn’t be the norm. The code review is about ‘can we maintain this long term?’ or ‘does this introduce subtle problems for something else that we are planning to add?’.