---
title: "Code Review"
description: "Code review guidelines and best practices"
keywords: [code review, review, pull requests, quality]
---

# Code Review

Guidelines for conducting effective code reviews in TraceRTM.

## Review Checklist

### Code Quality

- [ ] Code follows style guide
- [ ] No obvious bugs or errors
- [ ] Error handling is appropriate
- [ ] Edge cases are handled
- [ ] Code is well-documented

### Testing

- [ ] Tests are included for new features
- [ ] Existing tests still pass
- [ ] Test coverage is maintained
- [ ] Edge cases are tested

### Documentation

- [ ] Code comments are clear
- [ ] Docstrings are updated
- [ ] README/docs updated if needed
- [ ] API documentation updated

## Review Process

### For Reviewers

1. **Read the PR description** - Understand the change
2. **Review code changes** - Check implementation
3. **Test locally** (if possible) - Verify it works
4. **Provide feedback** - Be constructive and specific
5. **Approve or request changes** - Clear action required

### For Authors

1. **Self-review first** - Review your own code
2. **Address all comments** - Fix or discuss
3. **Update PR** - Push fixes
4. **Mark resolved** - Mark conversations as resolved

## Review Guidelines

### Be Constructive

```markdown
# Good feedback
The error handling here could be more specific. Consider catching 
DatabaseError separately from ValidationError to provide better 
error messages to users.

# Bad feedback
This is wrong.
```

### Be Specific

```markdown
# Good feedback
Line 45: Consider using `async with` for the database session 
to ensure proper cleanup.

# Bad feedback
This could be better.
```

### Explain Why

```markdown
# Good feedback
This approach might cause performance issues with large datasets. 
Consider using pagination or a cursor-based approach instead.

# Bad feedback
This won't scale.
```

## Common Review Points

### Security

- Check for SQL injection risks
- Verify authentication/authorization
- Check for sensitive data exposure
- Validate input sanitization

### Performance

- Check for N+1 queries
- Verify database indexes
- Check for memory leaks
- Review algorithm complexity

### Maintainability

- Code is readable
- Functions are focused
- No code duplication
- Proper error handling

## Approval Criteria

### Ready to Merge

- ✅ All tests pass
- ✅ Code review approved
- ✅ No blocking issues
- ✅ Documentation updated
- ✅ CI checks pass

## Related Documentation

- [PR Process](./03a-pr-process) - Pull request workflow
- [Code Style](./01-code-style) - Coding standards
