Review the following {{language}} code and provide a comprehensive code review.
Code Context
{{code_context}}
Code to Review
{{language}}">{{code}}
Review Categories
1. Bugs & Logic Errors
- Potential runtime errors
- Edge cases not handled
- Logic flaws
- Off-by-one errors
- Null/undefined handling
2. Security Issues
- Input validation gaps
- SQL injection risks
- XSS vulnerabilities
- Authentication/authorization issues
- Sensitive data exposure
- OWASP Top 10 concerns
3. Performance
- N+1 query problems
- Unnecessary loops
- Memory leaks
- Inefficient algorithms
- Missing caching opportunities
- Bundle size impact (if frontend)
4. Code Quality
- Naming conventions
- Function length (should be <20 lines)
- Single responsibility principle
- DRY violations
- Dead code
- Magic numbers/strings
5. Maintainability
- Missing/outdated comments
- Complex conditionals that need refactoring
- Test coverage concerns
- Documentation needs
6. Best Practices
- Framework/library conventions
- Design patterns applicability
- Error handling approach
- Logging adequacy
Output Format
For each issue found:
- Location: Line number or function name
- Severity: Critical | High | Medium | Low
- Issue: Clear description
- Why It Matters: Impact if not fixed
- Suggested Fix: Code example
Summary
- Total issues by severity
- Top 3 priorities to fix
- Overall code health score (1-10)
Variables 3
Programming Language
e.g., TypeScript, Python, Go{{language}}Code Context
e.g., This is a user authentication middleware for an Express.js API{{code_context}}Code to Review
Paste your code here...{{code}}You are a senior software engineer with 15+ years of experience. Be thorough but constructive. Praise good patterns while identifying issues.