Code Review Templates#
Templates for writing code review results.
Template A: Full Review Result#
# Code Review: [PR title or filename]
## Summary
**Overall**: โญโญโญโญโ (4/5)
**Reviewer**: [name]
**Date**: [YYYY-MM-DD]
| Category | Score | Key Issues |
|----------|-------|------------|
| ๐๏ธ Architecture | โ
| - |
| ๐งฉ State Management | โ ๏ธ | BlocBuilder optimization needed |
| ๐ Security | โ
| - |
| โก Performance | โ ๏ธ | Image cache size not specified |
| ๐งช Testing | โ | UseCase tests missing |
| ๐ Readability | โ
| - |
| ๐ i18n | โ
| - |
| โฟ Accessibility | โ ๏ธ | Some semantic labels missing |
---
## ๐ด Critical Issues (must fix before merge)
### 1. [Security] API key hardcoded
- **File**: `lib/core/config.dart:15`
- **Problem**: API key directly included in source code
- **Impact**: Security vulnerability, key exposure risk
- **Fix**: Use environment variables via Envied
// Before const apiKey = 'sk-1234567890abcdef';
// After @Envied(path: '.env') abstract class AppConfig { @EnviedField(varName: 'API_KEY') static const String apiKey = _AppConfig.apiKey; }
### 2. [Testing] UseCase tests missing
- **File**: `test/domain/usecase/`
- **Problem**: No tests for core business logic
- **Impact**: Risk of regression bugs
- **Fix**: Add unit tests per UseCase
---
## ๐ก Improvements (recommended fixes)
### 1. [Performance] Image cache size needs to be specified
- **File**: `lib/presentation/widget/product_card.dart:42`
- **Current code**:
Image.network(product.imageUrl)
- **Recommended code**:
CachedNetworkImage( imageUrl: product.imageUrl, cacheWidth: 200, cacheHeight: 200, )
### 2. [State Management] BlocBuilder optimization
- **File**: `lib/presentation/page/home_page.dart:78`
- **Current code**:
BlocBuilder<HomeBloC, HomeState>( builder: (context, state) => UserWidget(state.user), )
- **Recommended code**:
BlocBuilder<HomeBloC, HomeState>( buildWhen: (previous, current) => previous.user != current.user, builder: (context, state) => UserWidget(state.user), )
---
## ๐ข Suggestions (optional improvements)
### 1. [Readability] Variable name improvement suggestion
- `data` โ `userProfile`
- `list` โ `productItems`
- `result` โ `authResult`
### 2. [Structure] Widget extraction suggestion
- `_buildHeader()` โ Extract to `HomeHeader` widget
- Improves reusability and testability
---
## โ Questions
1. `auth_bloc.dart:45` - What is the intent of this exception handling logic?
2. `user_repository.dart:89` - Is there a reason the cache expiration time is 5 minutes?
---
## Conclusion
Overall good code. Can merge after fixing 2 Critical Issues.
Template B: Quick Review Result#
# Quick Review: [filename]
**Result**: โ
Approved with comments
## Key Feedback
1. **[Performance]** Adding image cache size recommended
- `product_card.dart:42`
2. **[Readability]** Variable name `data` โ `userProfile` recommended
- `home_bloc.dart:25`
## Well Done ๐
- Clean Architecture pattern well followed
- Immutable state management using Freezed
- Proper error handling
Template C: Detailed Category Review#
# Detailed Review: [category name]
## ๐๏ธ Architecture Review
### Review Items
| Item | Status | Notes |
|------|--------|-------|
| Clean Architecture layer separation | โ
| |
| UseCase pattern usage | โ
| |
| Repository interface separation | โ ๏ธ | Partially missing |
| Feature module independence | โ
| |
### Detailed Feedback
#### Repository Interface Separation (โ ๏ธ)
**Current State**:
- `CartRepository` directly implemented without interface
**Recommended Change**:
1. Create `ICartRepository` interface
2. Place interface in Domain layer
3. Implement in Data layer
// domain/repository/i_cart_repository.dart abstract interface class ICartRepository { Future<Either<Failure, Cart>> getCart(); Future<Either<Failure, void>> addItem(CartItem item); }
// data/repository/cart_repository.dart @LazySingleton(as: ICartRepository) class CartRepository implements ICartRepository { // implementation }
Template D: PR Comments#
Required Fix (Blocking)#
๐ด **[Required]** Security vulnerability
**Location**: `lib/core/config.dart:15`
**Problem**: API key is hardcoded.
**Fix**:
// Use Envied @EnviedField(varName: 'API_KEY') static const String apiKey = _AppConfig.apiKey;
Cannot merge until this issue is resolved.
Improvement Request (Non-blocking)#
๐ก **[Improvement]** Performance optimization
**Location**: `lib/presentation/widget/product_card.dart:42`
**Current code**:
Image.network(product.imageUrl)
**Recommended code**:
CachedNetworkImage( imageUrl: product.imageUrl, cacheWidth: 200, )
Specifying image cache size reduces memory usage.
Suggestion/Question#
๐ข **[Suggestion]** Variable name improvement
**Location**: `lib/presentation/bloc/home_bloc.dart:25`
Changing variable name `data` to `userProfile` would improve readability.
---
โ **[Question]** Exception handling intent
**Location**: `lib/data/repository/auth_repository.dart:45`
Is there a reason this try-catch block ignores all exceptions?
Praise#
โจ **Nice!** Clean state management
**Location**: `lib/presentation/bloc/cart_bloc.dart`
State management using Freezed and Union Types is very clean.
The loading/error/success state separation is especially well done!
Template E: Review Checklist (Self-Review)#
# Self-Review Checklist
Self-check list before PR submission.
## Basics
- [ ] Code builds successfully
- [ ] All tests pass
- [ ] No lint errors
- [ ] Related issues are linked
## Architecture
- [ ] Clean Architecture layer separation followed
- [ ] No direct dependencies between feature modules
- [ ] New code follows existing patterns
## Security
- [ ] No hardcoded secrets
- [ ] No sensitive information in logs
- [ ] Input validation applied
## Performance
- [ ] const widgets used
- [ ] Image cache size specified
- [ ] Resources released in dispose
## Testing
- [ ] Tests added for new features
- [ ] Edge cases covered
## Internationalization
- [ ] No hardcoded strings
- [ ] Translation keys used
## Final Check
- [ ] Unnecessary console.log/print removed
- [ ] TODO comments resolved or issues filed
- [ ] Commit messages follow convention
Template F: Review Summary (Approve/Request Changes)#
Approve โ #
LGTM! ๐
All checklist items verified.
**Verified items**:
- โ
Build successful
- โ
Tests passing
- โ
No security issues
- โ
Code quality good
Great work!
Request Changes ๐#
Changes requested.
**Required fixes** (must resolve before merge):
1. Remove hardcoded API key (`config.dart:15`)
2. Add UseCase tests
**Recommended fixes** (optional):
1. Specify image cache size
2. BlocBuilder optimization
Please re-request review after fixing the required items.
Comment ๐ฌ#
Overall looks good. A few questions/suggestions.
**Questions**:
1. Curious about the caching strategy choice
**Suggestions**:
1. Please consider error message internationalization
Please respond after review.