Sign inSign up

coderz/ai-code-review

By coderz

•Updated over 1 year ago

Image
0

767

coderz/ai-code-review repository overview

⁠AI-Powered Code Review

This project provides automated code review for GitLab merge requests using AI to analyze code quality.

⁠Features

⁠Code Quality Review

The automated code review analyzes each changed file in merge requests for:

  1. Bugs and Logical Errors

    • Undefined variables
    • Memory leaks
    • Logic flow issues
    • Error handling problems
  2. Security Vulnerabilities

    • SQL injection risks
    • Command injection vulnerabilities
    • Unsafe file operations
    • Authentication/authorization issues
    • Input validation problems
  3. Performance Issues

    • Memory usage concerns
    • CPU intensive operations
    • Inefficient algorithms
    • Resource leaks
    • Caching issues

⁠Setup

  1. Configure GitLab CI/CD variables:

    • GITLAB_TOKEN: Your GitLab API token
    • OPENAI_API_KEY: Your OpenAI API key
    • OPENAI_MODEL: The OpenAI model to use (defaults to gpt-4)
    • OPENAI_BASE_URL: (Optional) URL for Ollama API endpoint, e.g., http://localhost:11434/v1
    • PROXY: (Optional) HTTP/HTTPS proxy URL for connecting to OpenAI or Ollama, e.g., http://proxy.example.com:8080
  2. Add the .gitlab-ci.yml to your repository

  3. Create a merge request to see the automated review in action

⁠Using Ollama

This project supports using Ollama⁠ as an alternative to OpenAI's API:

  1. Install and run Ollama on your machine or server
  2. Set the OPENAI_BASE_URL environment variable to point to your Ollama instance (e.g., http://localhost:11434/v1)
  3. Ensure you have models available in your Ollama installation that are compatible with the OpenAI API format

⁠Using a Proxy

If you need to connect to OpenAI API or Ollama through a proxy:

  1. Set the PROXY environment variable to your proxy URL (e.g., http://proxy.example.com:8080 or http://username:[email protected]:8080)
  2. The application will automatically route all OpenAI API requests through the specified proxy
  3. This works for both OpenAI API and Ollama connections

⁠Usage

The code review runs automatically on all merge requests. It will:

  • Analyze changed files for quality issues
  • Post detailed review comments on the merge request
  • Provide specific suggestions for improvements

⁠Local Development

# Install dependencies
npm install

# Run code review locally
npm run code-review

⁠Scripts

  • npm run code-review: Run the code quality review
  • npm run analyze: Analyze merge request changes
  • npm run validate: Validate merge request size
  • npm run debug: Debug GitLab configuration

Tag summary

Content type

Image

Digest

sha256:510588eaa…

Size

85.3 MB

Last updated

over 1 year ago

docker pull coderz/ai-code-review