Code reviews: what we owe each other

How do you think code reviews and pull requests should work?

A notification for a new pull request to review pops up. You open it up, you don't really know what it is about, but you see that there is no documentation, and tests are missing. You just know that this is not acceptable for quality code, so you ask for docs and tests in a comment, and make a mental note to come back to the PR once the developer has done it. No need to review closely for now.

Later, you check the reviews for one of your own pull requests. There is a lot of code, so you know it will take some time to review, but this is an important change, so you decided to make it nearly perfect before opening it and asking for reviews. You feel disheartened when you see low engagement on it, and only for a few nitpicks here and there.

You look at the rest of the work in progress. One change is still blocked because the multithreading expert pointed a bug, but is not available to help, due to their own workload. There is a pull request that was approved within 15mn of its opening, you know it's not enough for a good review, but the bugfix is urgently needed, the developer spent 2 weeks on it in isolation, and the release is cut this afternoon, so what can you do? And There is also a new feature that is nearly ready and highly anticipated. It got good feedback from the team at first, but after a few iterations, people stopped engaging and the developer stopped asking for reviews. There's jut a bit of cosmetics to do on it, 30mn tops, and it's been in that state for a month.

As software developers, we have all seen variations of these situations unfold. And I have to ask, why do we do that to ourselves?

I have seen this happening in many different contexts, mall companies, large companies, open source projects, among friends. Even high velocity teams can fall into this trap. It can begin innocently, when teams start requiring reviews as a gatekeeping measure. Sure, they won't call it that way, but maybe there's been that one huge incident that destroyed a lot of trust? Or we are getting hammered by support calls due to a lot of small bugs encountered in production? Or you just feel that overall quality is slipping. It is easy then to mandate reviews before merging code, thinking that it will increase quality and reduce issues. And it could not be more wrong.

Once code reviews are required, it demands intention and effort to avoid the following pitfalls:

If any of these thoughts ever crossed your mind, take a moment to ask yourself how you ended up there.

You can have a team full of reasonable and experienced people, and still end up in that situation. When you start replacing trust and collaboration with process, you lose what makes a team. That can come from a lot of different triggers, but code reviews are such an easy one.

So if you ever encountered this, here is a way to look at it differently. Code reviews are not a gatekeeping tool, they are a teamwork platform.

The goals of reviewing pull requests are:

What a review should not be:

If you start to see reviews as a collaboration tool, suddenly your mindset shifts. A code change or pull request is not the work of one person that others look at and judge. Every change is everybody's responsibility. Software development is a team effort.

To that end, you need to change the way you approach reviews.

This takes effort and intent, and will slow things down at first, but the payoff is worth it. You want people to work more closely together, share knowledge, and jump to help each other. Be wary of any policy change that could break this attitude, and instead use every opportunity to build trust and shared understanding.