Code Review Automation: Quality Sistemica
Fonte: Capitolo 6 - Settore Developer & Tech
Categoria: Domini Specialistici
Livello: Avanzato
URL: prmpt.onl/202
Quando usarlo
Per code review sistematici che garantiscono quality standards, security compliance e knowledge transfer. Trasforma review process da bottleneck a learning e quality amplification opportunity.
Ideale per:
- Code review prima di merge nei branch principali
- Onboarding di nuovi developer con mentoring
- Legacy code improvement e technical debt reduction
- Security e performance optimization reviews
💡 PERCHÉ QUESTO TEMPLATE È IN INGLESE I code review seguono convenzioni internazionali standardizzate. Error messages, coding standards e best practices sono documentati in inglese. Mantenere la lingua tecnica originale facilita la collaborazione con team globali e l’accesso a risorse di documentazione.
Template
SENIOR CODE REVIEWER
Code context: [language, framework, project type]
Review scope: [new feature/bug fix/refactoring/performance]
Team context: [junior/mixed/senior developers]
Standards: [company coding standards, security requirements]
REVIEW FRAMEWORK:
## 1. FUNCTIONALITY ASSESSMENT
- Does the code solve the intended problem correctly?
- Are all requirements and acceptance criteria met?
- Are edge cases and error scenarios handled appropriately?
- Is the business logic clear and correctly implemented?
## 2. CODE QUALITY EVALUATION
- Readability: Clear variable names, logical structure, appropriate comments
- Maintainability: DRY principle, SOLID principles, modular design
- Performance: Algorithm efficiency, memory usage, database queries
- Security: Input validation, authentication, authorization, data protection
## 3. TECHNICAL STANDARDS COMPLIANCE
- Coding style and conventions consistency
- Architecture pattern adherence (MVC, microservices, etc.)
- Testing coverage and quality (unit, integration, e2e)
- Documentation completeness (README, API docs, inline comments)
## 4. CONSTRUCTIVE FEEDBACK DELIVERY
- Highlight positive aspects and good practices
- Provide specific, actionable improvement suggestions
- Include code examples for recommended changes
- Prioritize feedback: critical/important/nice-to-have
- Offer learning resources for skill development
## 5. COLLABORATION & MENTORING
- Ask clarifying questions about design decisions
- Suggest alternative approaches with trade-off analysis
- Share relevant experience and best practices
- Encourage discussion and knowledge sharing
REVIEW OUTPUT:
- Approval status: Approve/Request Changes/Reject
- Categorized feedback with priority levels
- Suggested improvements with code examples
- Learning opportunities and resources
- Follow-up discussion points
Focus on being thorough but constructive, educational but efficient.
Varianti
Per Security-Critical Code
Aggiungi: “Include OWASP Top 10 security check, vulnerability assessment, authentication/authorization validation, e data encryption verification.”
Per Performance-Critical Systems
Aggiungi: “Focus su algorithmic complexity analysis, memory profiling, database query optimization, e load testing considerations.”
Per Junior Developer Mentoring
Aggiungi: “Provide educational explanations for feedback, include learning resources, celebrate good practices, e offer pairing session opportunities.”
Esempio di risultato
Input: “Review React component for user authentication form with validation”
Output AI (estratto):
CODE REVIEW: User Authentication Component
## FUNCTIONALITY ASSESSMENT ✅ APPROVED
**POSITIVE ASPECTS:**
- Form validation logic correctly implemented
- Error states properly handled and displayed to user
- Loading states prevent double submission
- Success/failure flows work as expected
**REQUIREMENTS COVERAGE:** ✅ Complete
- Username/password fields with validation
- "Remember me" functionality implemented
- Forgot password link integration
- Responsive design for mobile compatibility
## CODE QUALITY EVALUATION ⚠️ IMPROVEMENTS NEEDED
### HIGH PRIORITY ISSUES:
**1. Security Vulnerability - Password Handling**
```javascript
// CURRENT (ISSUE):
const handleSubmit = (values) => {
console.log('Password:', values.password); // Logs password in plain text
// RECOMMENDED:
const handleSubmit = (values) => {
// Never log sensitive data
const { password, ...logSafeValues } = values;
console.log('Login attempt:', logSafeValues);
2. Performance Issue - Unnecessary Re-renders
// CURRENT (ISSUE):
const AuthForm = () => {
const [errors, setErrors] = useState({});
// This creates new object every render
const validationRules = {
username: { required: true, minLength: 3 },
password: { required: true, minLength: 8 }
};
// RECOMMENDED:
const validationRules = {
username: { required: true, minLength: 3 },
password: { required: true, minLength: 8 }
}; // Move outside component or use useMemo
MEDIUM PRIORITY SUGGESTIONS:
3. Code Organization - Extract Custom Hook
// RECOMMENDED: Extract authentication logic
const useAuthForm = () => {
const [isLoading, setIsLoading] = useState(false);
const [errors, setErrors] = useState({});
const handleLogin = async (credentials) => {
// Authentication logic here
};
return { isLoading, errors, handleLogin };
};
TECHNICAL STANDARDS COMPLIANCE ✅ GOOD
STRENGTHS:
- Consistent React patterns (hooks, functional components)
- Proper prop types defined
- ESLint rules followed
- Appropriate file structure and naming
MINOR IMPROVEMENTS:
- Add data-testid attributes for testing
- Consider extracting validation messages to constants
- Add error boundary for graceful error handling
CONSTRUCTIVE FEEDBACK & LEARNING
EXCELLENT PRACTICES OBSERVED:
- Clean component structure and separation of concerns
- Proper error handling with user-friendly messages
- Accessibility considerations (ARIA labels, semantic HTML)
LEARNING OPPORTUNITIES:
- Security Best Practices: Never log sensitive data in production
- Resource: OWASP JavaScript Security Guide
- React Performance: Understanding re-render triggers
- Resource: React.dev Performance Guide
- Testing Strategy: Component testing with React Testing Library
- Suggested: Unit tests for validation logic
DISCUSSION POINTS:
- Should we implement rate limiting for login attempts?
- Would you like to pair program on the testing implementation?
- Any questions about the security recommendations?
VERDICT: REQUEST CHANGES ⚠️
REQUIRED BEFORE MERGE:
- Fix password logging security issue (HIGH)
- Optimize validation rules performance (HIGH)
RECOMMENDED FOR NEXT ITERATION:
- Extract authentication hook for reusability
- Add comprehensive test coverage
- Implement error boundary pattern
ESTIMATED EFFORT: 2-3 hours for required changes
Great work on the overall structure and user experience! The security and performance fixes are important but straightforward. Happy to review again once updated. ```
Tips per risultati migliori
- Context specificity: Fornisci info su project type, team skill level, e business requirements per relevant feedback
- Code examples: Include sempre suggested improvements con actual code, non solo description
- Priority levels: Categorizza feedback per urgency/importance per efficient resolution
- Learning focus: Balance critic feedback con educational opportunities per team growth
Template correlati
- prmpt.onl/003 - Codice e Documentazione per development standards
- prmpt.onl/201 - Architecture Review per structural decisions
- prmpt.onl/203 - Debug Problemi Complessi per troubleshooting
📖 Da “Prompt Engineering: Il Nuovo Skill” di Marco Milani
🔗 Tutti i template: prmpt.onl/index
📱 Accesso rapido: [QR Code]
Ultimo aggiornamento: 24 Gennaio 2025