A powerful PR review tool for local Git repositories, inspired by AI-powered services, but running entirely on your local machine. Review code changes, analyze impact, evaluate quality, and collaborate effectivelyβall without uploading your code to external services.
Local CodeRabbit provides a comprehensive suite of tools for reviewing pull requests in local Git repositories:
- View file changes with syntax highlighting
- Side-by-side diff comparison
- Add line-specific comments
- Track changes between branches
Understand how changes affect your codebase:
- Function changes detection (added, modified, removed)
- Variable changes tracking
- Control flow impact analysis (conditionals, loops, error handling)
- Impact level assessment (Low, Medium, High)
Evaluate code quality changes:
- Complexity metrics (cyclomatic complexity, maintainability index)
- Code style analysis using ESLint
- Before/after quality comparison
- Quality trend assessment (Improved, Reduced, Unchanged)
Automated code review suggestions:
- Detects potential issues (console.log statements, TODOs)
- Identifies hardcoded values
- Flags large files that might need refactoring
- Provides contextual improvement suggestions
- Node.js (v14 or higher)
- npm or yarn
- Git
- Clone the repository:
git clone https://github.com/yourusername/local-coderabbit.git
cd local-coderabbit
- Install dependencies:
npm run install-all
- Start the application:
npm start
This will launch both the server and client applications. The web interface will be available at http://localhost:3000.
- When you first open Local CodeRabbit, you'll be prompted to enter the path to your Git repository:
- Enter the absolute path to your Git repository and click "Set Repository"
- Once connected, you'll see a list of branches in your repository
- Select the base branch and compare branch to begin code review
The Diff Viewer provides a visual representation of changes between branches:
- Left panel displays a list of changed files with additions and deletions count
- Main panel shows the specific changes in the selected file
- Color coding: green for additions, red for deletions
- Line numbers for easy reference
- Comments panel for adding line-specific feedback
- Select a file from the left panel
- Review changes in the main panel
- Add comments by specifying a line number and your feedback
- Comments are saved locally and persist during your session
The Impact Analyzer evaluates how changes might affect the behavior of your code:
- Function Changes: Detects added, modified, and removed functions
- Variable Changes: Tracks variables that have been added, modified, or removed
- Flow Changes: Analyzes changes in control flow (if statements, loops, etc.)
- Impact Level: Provides an overall impact assessment (Low, Medium, High)
- The analyzer first obtains the diff between branches
- For each JavaScript/JSX file, it extracts the structure using AST (Abstract Syntax Tree) parsing
- It compares the structures of the old and new code to identify changes
- An impact score is calculated based on the significance of changes
- Results are categorized and presented visually
The Quality Analyzer measures how changes affect code quality:
- Complexity Metrics: Changes in cyclomatic complexity, maintainability index, and Halstead difficulty
- Linting Results: Comparison of ESLint errors and warnings before and after
- Overall Assessment: Evaluation of whether quality improved, reduced, or remained unchanged
- The analyzer runs code complexity tools on both the old and new versions of each file
- It calculates the difference in various metrics
- ESLint is used to detect potential issues in both versions
- A quality score is calculated based on changes in complexity and linting results
- Results are presented with color-coded indicators (green for improvements, red for regressions)
The Code Reviewer provides automatic feedback on your changes:
- Warning: Potential issues that might affect production (e.g., console.log statements)
- Info: Informational notes (e.g., TODO comments found)
- Suggestion: Improvement recommendations (e.g., extract hardcoded values)
- The reviewer analyzes each changed file looking for common patterns
- It generates comments based on detected patterns
- Comments are categorized by type and associated with specific lines
- The diff view is presented alongside suggestions for context
Local CodeRabbit is built with a modern JavaScript stack:
- Git Integration: Uses
simple-git
to interact with local Git repositories - Code Analysis: Employs
jscodeshift
for AST manipulation,escomplex
for complexity metrics, andeslint
for style checking - API Layer: RESTful API built with Express.js
- UI Framework: React with React Router for navigation
- State Management: React hooks for component state
- Styling: CSS with flexbox and grid for layout
- Server reads Git repository information and exposes it via API
- React frontend requests repository data and displays branches
- User selects branches to compare
- Server performs diffs, analysis, and review
- Frontend displays results in specialized views
- Comments are stored in-memory on the server during session
The system uses Git's diff capabilities to generate a structured diff representation:
git diff
command is executed between branches- The raw diff output is parsed into a structured format
- Chunks, lines, and changes are categorized for rendering
Abstract Syntax Tree analysis powers the impact and quality analysis:
- Code is parsed into an AST using
jscodeshift
- Tree traversal identifies functions, variables, and control flow
- Before and after trees are compared to detect changes
- Changes are categorized and quantified
Quality assessment uses a weighted scoring system:
- Decreased complexity: +2 points
- Increased maintainability: +3 points
- Reduced ESLint errors: +3 points
- Reduced ESLint warnings: +1 point
The final assessment is determined by the total score:
- Score > 3: Quality Improved
- Score < -3: Quality Reduced
- Otherwise: Quality Unchanged
Contributions to Local CodeRabbit are welcome! Here's how you can help:
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ for developers who care about code quality