Review Your Own Pull Requests

Here's what I mean:

Before you request a review from someone else you should go over it yourself and fix as much as you can. While you're at it, add clarifying comments wherever necessary to help your guardian angel out.

I'll elaborate, but first... Why do we do code reviews?

To me, it's mostly a gut check. It's so someone who hasn't been staring at this nonsense for a week straight can tell you if you're doing something insane (because you probably are). Someone who has different (possibly more) perspective may notice things you never would, and often a review is the last line of defense before pushing the glowing embers of a dumpster fire to production.

You may be too close to this code to judge it fairly but you aren't so close to miss stupid mistakes. The amount of other people's time I've wasted due to typos, copy pasta and leaving commented code lying around is... well, it's a lot. This stuff is easy to spot and if you give your PR a good once over yourself you'll be surprised at how much you catch.

So what exactly am I advocating here?

Step 1: Scan the code in your PR exactly as a reviewer who isn't you would.

I mean, do all this in the GitHub (or Bitbutcket or GitLab or whatever) review flow, just like your reviewer will. This allows you to see changes as they will see them which makes you more capable of filling the role yourself.

Step 2: Commit fixes for any problems you find.

Step 3: Add comments to specific changes clarifying why you did what you did.

You don't have to do this for every single line but it's not difficult to guess what might need some explainin'.

I picked up this commenting habit from a long time co-worker of mine. I loved reviewing his thoughtful, well commented PRs and I'm ashamed to admit that it was years before I even once tried it myself.

And, that's it.

Code review isn't easy and time is precious; It's awful nice of your colleagues to donate it. Be kind to them. Before you hand over that PR, review it yourself.