You are an expert code reviewer. Analyze the following code for: 1. **Bugs & Errors**: Identify any bugs, edge cases, or potential runtime errors 2. **Security Issues**: Look for vulnerabilities (injection, XSS, auth issues, etc.) 3. **Performance**: Suggest optimizations where applicable 4. **Code Quality**: Check for readability, maintainability, and best practices 5. **Improvements**: Provide specific recommendations Code to review: ``` [PASTE YOUR CODE HERE] ``` Please provide a detailed review with line numbers where applicable.
Generate comprehensive documentation for the following code. Include: 1. **Overview**: What does this code do? 2. **Parameters/Arguments**: List all parameters with types and descriptions 3. **Returns**: What does it return? 4. **Example Usage**: Provide clear usage examples 5. **Edge Cases**: Any important edge cases to handle 6. **Dependencies**: Required imports or dependencies Code: ``` [PASTE YOUR CODE HERE] ``` Generate documentation in a clean, readable format.
Generate comprehensive unit tests for the following code. Include: 1. **Happy Path Tests**: Test normal/expected behavior 2. **Edge Cases**: Test boundary conditions and edge cases 3. **Error Handling**: Test error scenarios and exceptions 4. **Mock Data**: Provide sample test data where needed Use appropriate testing framework conventions (Jest, Mocha, pytest, etc.) Code to test: ``` [PASTE YOUR CODE HERE] ``` Testing framework preference: [Jest/pytest/JUnit/other] Generate complete, runnable test cases.
Analyze and refactor the following code to improve: 1. **Readability**: Improve variable names, structure, and clarity 2. **Performance**: Optimize algorithms and reduce complexity 3. **Maintainability**: Apply design patterns and best practices 4. **DRY Principle**: Eliminate code duplication 5. **Modern Syntax**: Use modern language features where applicable Original code: ``` [PASTE YOUR CODE HERE] ``` Language: [SPECIFY LANGUAGE] Provide: - Refactored code - Explanation of changes made - Before/after comparison
Explain the following code in simple, easy-to-understand terms. Structure your explanation as: 1. **Purpose**: What does this code do overall? 2. **How It Works**: Step-by-step walkthrough 3. **Key Components**: Explain important parts 4. **Data Flow**: How does data move through the code? 5. **Dependencies**: What external libraries/functions does it rely on? Use analogies and real-world comparisons where helpful. Target audience level: [Beginner/Intermediate/Advanced] Code to explain: ``` [PASTE YOUR CODE HERE] ``` Make it accessible without oversimplifying.