Code reviews are a great way to improve code quality, catch bugs, and keep your whole team in sync with the latest changes. My favorite tool for doing a code review is still Github’s Pull Request feature, because of the easily-accessible diffs, inline comments, and commit-level and PR-level views of the file changes.
So, how do we make the code review process effective? I offer the following tips:
- Actually review PR’s; telling an author to “just ship it” is detrimental.
- Senior developers want you to review their code; don’t be scared.
- Close PR’s that don’t have specs
- If spec coverage is sparse, discuss it with the author (nicely).
- Spec descriptions should accurately reflect the behavior of the module/method they describe.
- Ask questions instead of making statements; the author likely put more thought into the code than you are aware of, and they’ve already solved the problem once.
- Look for design problems:
- Does this change solve a real problem? is it worth solving?
- Given the constraints, is the overall approach correct and reasonable?
- Look for code smells and suggest refactorings.
- Ask for help with reviewing code that is outside your area of expertise.