Code Review
What is Code Review?
Code review is the process where team members review each other's code before it's merged. It helps maintain code quality, share knowledge, and catch bugs early.
Code Review Workflow
1. Create a Pull Request
# Create feature branch
git checkout -b feature/new-feature
# Make changes and commit
git add .
git commit -m "Add new feature"
git push origin feature/new-feature
Then create a pull request on gityar.
2. Request Review
In the pull request:
- Click "Reviewers" on the right sidebar
- Select team members
- Optionally add a comment explaining what to focus on
3. Review the Code
Reviewers should:
- Read the code changes carefully
- Understand the purpose and context
- Check for bugs and edge cases
- Verify code follows standards
- Test the changes locally if needed
Review Features
Viewing Changes
Diff View:
- See all changes side-by-side
- Highlighted additions and deletions
- Syntax highlighting
- Split or unified diff
Commit History:
- View all commits in the PR
- See commit messages
- Track changes over time
Inline Comments
Leave comments on specific lines:
- Hover over a line number
- Click the "+" icon
- Write your comment
- Click "Add single comment" or "Start a review"
Review States
Comment:
- General feedback
- No approval or rejection
- Ask questions or suggest improvements
Approve:
- Code is ready to merge
- All concerns addressed
- Meets quality standards
Request Changes:
- Issues must be fixed before merging
- Specific feedback provided
- Author should address concerns
Best Practices
For Authors
Before Submitting:
- ✅ Self-review your code first
- ✅ Ensure code compiles and tests pass
- ✅ Write clear PR description
- ✅ Break large changes into smaller PRs
- ✅ Add comments for complex logic
- ✅ Include tests for new features
During Review:
- ✅ Respond to all comments
- ✅ Be respectful and professional
- ✅ Explain your reasoning
- ✅ Make requested changes promptly
- ✅ Push updates to the same branch
- ✅ Thank reviewers for their time
For Reviewers
Review Process:
- ✅ Review promptly (within 24 hours)
- ✅ Be constructive, not critical
- ✅ Explain why, not just what
- ✅ Suggest specific improvements
- ✅ Acknowledge good practices
- ✅ Test locally if changes are complex
Comment Types:
Questions:
"What happens if this receives an empty array?"
Suggestions:
"Consider using a map here for better performance"
Nitpicks:
"Nit: extra whitespace on line 42"
Blockers:
"This needs to handle the error case before we can merge"
Code Review Checklist
Functionality
Code Quality
Security
Performance
Testing
Documentation
Resolving Review Comments
Making Changes
# Make requested changes
# Edit files...
# Commit changes
git add .
git commit -m "Address review comments"
# Push to update PR
git push origin feature/new-feature
Marking as Resolved
- Address the comment in code or discussion
- Click "Resolve conversation" if you're the reviewer
- Ensure all requested changes are addressed
Follow-up Reviews
After changes are made:
- Reviewers re-review the updated code
- Approve if satisfied
- Request further changes if needed
- Merge when all concerns are addressed
Merging
When to Merge
- ✅ All requested changes addressed
- ✅ At least one approval (or required number)
- ✅ All CI checks passing
- ✅ No merge conflicts
- ✅ Team agrees it's ready
Merge Methods
Merge Commit:
- Preserves all commits
- Creates a merge commit
- Best for feature branches
Squash and Merge:
- Combines all commits into one
- Clean history
- Best for small PRs
Rebase and Merge:
- Rebases commits onto target branch
- Linear history
- Best for maintaining clean history
Next Steps