Easy-AI-CodeReview: LLM-Powered Automated Code Review for GitLab

6月26日 Published inDeveloper Tools

Easy-AI-CodeReview uses Large Language Models (LLMs) to automate the code review process. By analyzing changes before a merge or commit, the tool helps maintain high code quality and accelerates the development cycle.

The platform supports a variety of LLMs, including DeepSeek, ZhipuAI, OpenAI, Qwen, and Ollama. Review results are delivered directly to communication tools such as DingTalk, WeChat Work, or Feishu. Additionally, Easy-AI-CodeReview generates daily development reports based on GitHub or GitLab commits, providing a clear overview of team contributions and project momentum.

A built-in data dashboard tracks every code review and provides project-level statistics and member analysis. Users can customize the feedback tone by choosing from four distinct review styles: professional, sharp, gentlemanly, or humorous. For broader analysis, full repository reviews can be executed via the command line. The tool automatically posts feedback as comments on GitLab Merge Requests or commit pages, ensuring developers receive suggestions exactly where they work.

The workflow is straightforward: when a developer pushes code or opens a Merge Request, GitLab triggers a webhook to Easy-AI-CodeReview. The system parses the code changes and sends the diff to an LLM for analysis. The model checks for coding standards, identifies potential bugs, flags security risks, and suggests improvements for maintainability. Finally, the feedback is posted back to the MR or commit page automatically, requiring no extra steps from the user.

Deployment Options

Option 1: Docker

  1. Prepare environment files Clone the repository:

    git clone https://github.com/spherical-up/Easy-AI-CodeReview
    cd Easy-AI-CodeReview
    

    Create the configuration file:

    cp conf/.env.dist conf/.env
    

    Edit conf/.env with your settings:

    # LLM provider: zhipuai, openai, deepseek, or ollama
    LLM_PROVIDER=deepseek
    
    # DeepSeek API Key
    DEEPSEEK_API_KEY={YOUR_DEEPSEEK_API_KEY}
    
    # File extensions to review (others will be ignored)
    SUPPORTED_EXTENSIONS=.java,.py,.php,.yml,.vue,.go,.c,.cpp,.h,.js,.css,.md,.sql
    
    # DingTalk notifications: 0 for off, 1 for on
    DINGTALK_ENABLED=0
    DINGTALK_WEBHOOK_URL={YOUR_DINGTALK_WEBHOOK_URL}
    
    # GitLab Configuration
    GITLAB_ACCESS_TOKEN={YOUR_GITLAB_ACCESS_TOKEN}
    
  2. Start the service

    docker-compose up -d
    
  3. Verify the installation

    • Main service: Visit http://your-server-ip:5001. You should see the message: "The code review server is running."
    • Dashboard: Visit http://your-server-ip:5002 to access the review logs and statistics.

Option 2: Local Python (3.10+)

  1. Download the source code

    git clone https://github.com/sunmh207/AI-Codereview-Gitlab.git
    cd AI-Codereview-Gitlab
    
  2. Install dependencies It is recommended to use a virtual environment:

    pip install -r requirements.txt
    
  3. Configure environment variables Use the same .env settings as described in the Docker section.

  4. Launch the services Start the API:

    python api.py
    

    Start the Dashboard:

    streamlit run ui.py --server.port=5002 --server.address=0.0.0.0
    

GitLab Webhook Setup

  1. Create an access token: You can use either a Personal Access Token or a Project Access Token.

  2. Configure the webhook: In your GitLab project settings, add a new webhook.

    • URL: http://your-server-ip:5001/review/webhook
    • Trigger events: Select "Push Events" and "Merge Request Events."
    • Secret token: Enter your access token (optional).

Messaging Notifications (DingTalk Example)

To receive alerts, add a custom bot to your DingTalk group and retrieve the webhook URL. Update your .env file as follows:

# DingTalk
DINGTALK_ENABLED=1
DINGTALK_WEBHOOK_URL=https://oapi.dingtalk.com/robot/send?access_token=xxx

The setup process is identical for WeChat Work and Feishu.

Extra: Full Repository Review

You can analyze an entire repository using the command-line interface. This feature is currently under active development. Run the following command:

python -m biz.cmd.review

Follow the on-screen prompts to complete the review. For additional troubleshooting, refer to doc/faq.md.