Lesson 2: The Code Review
A Pull Request without a code review is like a pilot skipping the preflight checklist. Code reviews catch bugs, spread knowledge, and maintain code quality across the team.
What to Look For in a Code Review
1. Correctness
- Does the code actually do what it claims?
- Are there edge cases that aren't handled?
- Could it break existing functionality?
2. Security
- Are there hardcoded passwords or API keys?
- Is user input validated and sanitized?
- Are permissions checked properly?
3. Readability
- Can you understand the code without the author explaining it?
- Are variable names clear and descriptive?
- Are complex sections commented?
4. Performance
- Are there unnecessary database queries or API calls?
- Could loops be optimized?
- Are there memory leaks?
Git Commands for Reviewing
# See what changed between branches
git diff main..feature/user-profile
# List only the files that changed
git diff --name-only main..feature/user-profile
# See statistics (lines added/removed per file)
git diff --stat main..feature/user-profile
# Show a specific commit
git show abc123
Review Etiquette
As a Reviewer:
- 🟢 Be constructive, not critical. "Consider using X because..." not "This is wrong."
- 🟢 Explain why, not just what. "This could cause a memory leak because..."
- 🟢 Praise good code. "Nice abstraction here!" boosts morale.
- 🟢 Use suggestions, not demands. Most platforms have a "Suggest changes" feature.
As an Author:
- 🟢 Don't take it personally. Reviews improve the code, not judge you.
- 🟢 Respond to every comment. Even if it's just "Done!" or "Good point, fixed."
- 🟢 Push fixes as new commits. Makes it easy for the reviewer to see what changed.
Common Review Comments in DevOps
| Comment | Meaning | |---------|---------| | "LGTM" | "Looks Good To Me" — Approved! | | "nit:" | Minor suggestion, not a blocker | | "blocking:" | Must be fixed before merging | | "question:" | Need clarification, not necessarily a problem |
booting...
Mission Objective
Practice reviewing changes:
- Full diff: Run
git diff main..feature/user-profileto see all changes. - File list: Run
git diff --name-only main..feature/user-profileto see which files changed. - Quick stats: Run
git diff --stat main..feature/user-profileto see lines added/removed.
Pro Tip
Set up CI/CD checks to run automatically on every Pull Request. This way, tests, linting, and security scans happen before a human even looks at the code. It saves everyone's time.