Giter Site home page Giter Site logo

sonar-bugfix-ai's Introduction

sonar-bugfix-ai

Sonar Bug AI 自动化修复 Demo,使用 AI 模型自动修复 Sonar Bug。

实现思路:

从 SonarQube 中获取 Bug 信息,然后使用 AI 模型自动修复 Bug。

详细文章:Python + Google AI 自动修复 Sonar Bug 实践

注意: 这是一个 Demo 项目,用于演示如何使用 AI 自动化修复 Sonar Bug,请不要在生产环境中使用。

依赖环境

  • Python 3.10+

安装依赖

pip install -r requirements.txt

配置

修改 .env 文件中的配置信息,请注意需要自己申请 AI 模型的 Token。

默认使用 Google AI gemini 模型,如果需要使用 OpenAI ChatGPT 模型,请修改 .env 文件中的 USE_AI_MODELopenai

########################## 通用配置 配置 ###############################
# 配置 AI 服务提供商,可选值:openai、gemini
USE_AI_MODEL=gemini
# 本地项目路径,用于读取本地代码
LOCAL_PROJECT_PATH=/Users/yourname/yourproject

########################## Soanr 配置 ###############################
# SonarQube URL: SonarQube 服务地址
SONARQUBE_URL=http://localhost:9000
# SonarQube Token: 用于鉴权
SONARQUBE_TOKEN=your_token
# SonarQube Project Key: 项目唯一标识
SONARQUBE_PROJECT_KEY=your_project_key
# SonarQube Branch: 项目分支
SONARQUBE_BRANCH=main

########################## Google GeMini 配置 ###############################
# Gemini AI Model
GEMINI_AI_MODEL=gemini-pro
# Google Gemini API Key
GEMINI_API_KEY=your_api_key

########################## OpenAI ChatGPT 配置 ###############################
# OpenAI ChatGPT API URL
OPENAI_API_URL=https://api.openai.com/
# ChatGPT AI Model
CHATGPT_AI_MODEL=gpt-4-turbo
# OpenAI ChatGPT API Key
OPENAI_API_KEY=your_api_key # 修改为你的 API Key

使用方法

python main.py

再次声明

  • 该项目是一个被阉割的 Demo 项目, 仅用于演示思路
  • 不能保证 Sonar Bug 都能被修复,甚至可能会直接导致代码异常
  • 本项目仅用于学习,如果想要实际使用,请 fork 本项目并自行修改
  • 本项目不对使用本项目导致的任何后果负责

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.