Perform thorough code reviews following Google's 5-step methodology. Use when reviewing pull requests, change lists, or any code changes to ensure quality, correctness, and maintainability.
A comprehensive code review methodology based on Google's engineering practices. Follow these 5 steps to perform effective and thorough code reviews.
Before diving into the code, perform a quick pre-screening:
Ask yourself:
If you're not the ideal reviewer but no one else is available, prepare to quickly learn about the unfamiliar aspects.
After pre-screening, focus on understanding the change from the author's perspective.
Ask: "Do I know the overall purpose of this CL?"
Ask: "Was I expecting this CL? Does it match my expectations?"
Consider:
Verify that important design decisions are:
Now verify the implementation matches the stated intent.
Verify relevant tests exist for:
| Category | What to Check |
|---|---|
| Design decisions | Tests that validate key architectural choices |
| Important defaults | Tests for default values and their behavior |
| Complex logic | Tests for intricate algorithms or business logic |
| Edge cases | Zero, null, empty, boundary conditions, if-statement edges |
Look for opportunities to improve the code's efficiency and maintainability.
Final pass for code style and conventions.
ā” Pre-screen
ā” Size reasonable (~300 lines)?
ā” Am I the right reviewer?
ā” Understand
ā” Purpose clear in description?
ā” Expected in current workflow?
ā” Design decisions documented?
ā” Verify
ā” Code matches description?
ā” Tests cover design decisions?
ā” Tests cover defaults and edge cases?
ā” Optimize
ā” Logic optimizable?
ā” Library choices optimal?
ā” Check
ā” Style guidelines followed?
Acknowledgment: This methodology is based on reflections from working at Google, with thanks to mentors and teammates who helped improve these code review skills.