Automatic code review method, computer and storage medium

By integrating artificial intelligence models and DevOps toolchain, automated code review is achieved, and the problem of inefficient code review in the existing technology is solved, review efficiency and accuracy is improved, costs are reduced and needs to adapt to the needs of continuous updates.

CN119987829APending Publication Date: 2025-05-13BOSCH CAR MULTIMEDIA WUHU

Patent Information

Application Number
CN202411982286.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

The code review efficiency in the prior art is inefficient and cannot meet the requirements of modern software development for code development efficiency.

Method used

By integrating artificial intelligence models and DevOps toolchain, automated code review is achieved. The specific steps include collecting historical code and error reports to train the artificial intelligence model, using the difference generation script to automatically compare the code differences, and conducting in-depth analysis and review report generation through the application platform Dify.

Benefits of technology

Improves the efficiency and accuracy of code review, reduces labor costs, reduces error rates, and adapts to the needs of continuous updates through continuous updates of artificial intelligence models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119987829A_ABST
    Figure CN119987829A_ABST
Patent Text Reader

Abstract

The invention provides an automatic code review method, a computer and a storage medium, and belongs to the technical field of automatic code review, and the review method comprises the steps that the computer collects codes and program error reports submitted by a development team in the past, trains an artificial intelligence model, and integrates the artificial intelligence model to an application platform, by deploying software and a warehouse trigger event, automatically executing a difference generation script, comparing the difference between a to-be-examined code and a previous version, examining the difference content, deeply analyzing the difference content through an artificial intelligence model in an application platform, automatically generating an examination report, identifying potential problems and providing improvement suggestions. And analyzing information in the review report through deployment software, and notifying a development team to view a feedback result through a mail. And the computer performs incremental training on the artificial intelligence model according to the difference content between the newly submitted code and the old data, and regularly updates the review standard and rule. According to the invention, the code review efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of automatic code review, and in particular, the present invention relates to an automatic code review method, a computer and a storage medium. Background Art

[0002] With the continuous development of software development, code quality and development efficiency have become key factors for project success. Traditional code review methods mainly rely on manual review among developers. Although they can ensure a certain quality, they also face challenges such as low review efficiency, omissions, and poor team collaboration. In addition, manual code review has problems such as long time consumption, long feedback cycle, and incomplete review, which seriously affects the overall progress of software development.

[0003] Chinese Patent 103677831A provides an online code review system and method, and its technical solution can be summarized as: an online code review system, characterized in that it includes an interactive client and a code review system, the interactive client is connected to the code review system, and the code review system includes a code review sheet management module, a comparison file generator module, a version management tool agent module and an annotation information management module.

[0004] The code review efficiency of existing technologies is low and cannot meet the current requirements for code development efficiency. Summary of the invention

[0005] The present invention aims to provide an automated code review method, a computer and a storage medium to achieve the technical purpose of improving the efficiency of code review.

[0006] In order to achieve the above object, the technical solution adopted by the present invention is:

[0007] The present invention provides an automated code review method:

[0008] S1: The computer collects the development team’s past submitted code and program error reports, trains the AI ​​model, and integrates the AI ​​model into the application platform.

[0009] S2: The computer triggers events by deploying software and repositories, and automatically executes the difference generation script to compare the differences between the code to be reviewed and the previous version, and reviews the differences.

[0010] S3: The computer conducts in-depth analysis of the difference content through the artificial intelligence model in the application platform, automatically generates a review report, identifies potential problems and provides improvement suggestions.

[0011] S4: The computer parses the information in the review report by deploying software and notifies the development team via email to review the feedback results.

[0012] S5: Computers perform incremental training on AI models based on the differences between newly submitted code and old data, and regularly update review standards and rules.

[0013] In S1, computers collect past code commits from the Gerrit repository and bug reports from bug tracking tools.

[0014] In S1, computers design evaluation criteria when training artificial intelligence models.

[0015] In S2, the deployment software Jenkins receives push events from the Gerrit repository and triggers events when the code is submitted. It generates difference content through the difference generation script, and then reviews the difference content through Dify, an application platform that integrates artificial intelligence models.

[0016] In S3, the structure of the review report includes the conclusion of the analysis, listing the potential problems identified, and providing specific improvement suggestions for each problem.

[0017] In S4, the computer parses the information in the review report and converts the parsed information into a text format.

[0018] In S5, the structure of the review report was optimized based on feedback from developers.

[0019] The present invention provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method when executing the computer program.

[0020] The present invention provides a storage medium, wherein the storage medium stores a computer program, and is characterized in that the steps of the method are implemented when the computer program is executed by a processor.

[0021] The technical effects of the present invention are:

[0022] (1) The present invention realizes automatic code review through the integration of DevOps tool chain, which improves the efficiency of code review, reduces labor costs, and reduces error rate.

[0023] (2) The accuracy of code review is improved by training artificial intelligence models with large amounts of data.

[0024] (3) The present invention uses Dify, an application platform that integrates artificial intelligence models, to conduct code review using a chat question-and-answer method, thereby automating code review and reducing the investment in labor costs.

[0025] (4) The present invention evaluates the effect of automatic code review to ensure the quality of code review.

[0026] (5) The present invention continuously updates the artificial intelligence model used for code review and can cope with constantly updated needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] This specification includes the following drawings, which show the following contents:

[0028] Figure 1 The present invention provides a flowchart of an automated code review method, a computer and a storage medium. DETAILED DESCRIPTION

[0029] The specific implementation methods of the present invention are further explained in detail below by describing the embodiments with reference to the accompanying drawings, with the aim of helping those skilled in the art to have a more complete, accurate and in-depth understanding of the inventive concept and technical solution of the present invention and facilitating their implementation.

[0030] The present invention provides an automated code review method:

[0031] S1: The computer collects the development team’s past submitted code and program error reports, trains the AI ​​model, and integrates the AI ​​model into the application platform.

[0032] S2: The computer triggers events by deploying software and repositories, and automatically executes the difference generation script to compare the differences between the code to be reviewed and the previous version, and reviews the differences.

[0033] S3: The computer conducts in-depth analysis of the difference content through the artificial intelligence model in the application platform, automatically generates a review report, identifies potential problems and provides improvement suggestions.

[0034] S4: The computer parses the information in the review report by deploying software and notifies the development team via email to review the feedback results.

[0035] S5: Computers perform incremental training on AI models based on the differences between newly submitted code and old data, and regularly update review standards and rules.

[0036] In S1, computers collect past code commits from the Gerrit repository and bug reports from bug tracking tools.

[0037] In S1, computers design evaluation criteria when training artificial intelligence models.

[0038] In S2, the deployment software Jenkins receives push events from the Gerrit repository and triggers events when the code is submitted. It generates difference content through the difference generation script, and then reviews the difference content through Dify, an application platform that integrates artificial intelligence models.

[0039] In S3, the structure of the review report includes the conclusion of the analysis, listing the potential problems identified, and providing specific improvement suggestions for each problem.

[0040] In S4, the computer parses the information in the review report and converts the parsed information into a text format.

[0041] In S5, the structure of the review report was optimized based on feedback from developers.

[0042] The present invention provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method when executing the computer program.

[0043] The present invention provides a storage medium, wherein the storage medium stores a computer program, and is characterized in that the steps of the method are implemented when the computer program is executed by a processor.

[0044] An automated code review method of the present invention is described in detail below.

[0045] S1: The computer collects the past code submissions and program error reports of the development team, trains the AI ​​model, and integrates the AI ​​model into the application platform. Specifically, the computer collects data from the Gerrit repository to ensure that enough past code submissions are collected. The past code submissions contain different development stages and code types. Specifically, the computer uses the Gerrit API interface to obtain submission records, including code changes, submission information, and developer information. The accuracy of code review is improved by training the AI ​​model with a large amount of data.

[0046] The computer collects comments and repair suggestions related to code defects, code quality, and performance issues through a program error tracking tool. The program error tracking tool in the present invention adopts Redmine. Specifically, the computer uses the API interface provided by Redmine to extract program error reports, including program error descriptions, reproduction steps, and fixed versions. Each program error should be associated with a related submission record and a repair commit ID to ensure that the program error report can match the repaired code.

[0047] The specific algorithm is as follows:

[0048]

[0049]

[0050] The computer organizes and cleans the submitted code and program error reports in the past, removes irrelevant or duplicate data, and standardizes the data formats from different sources. The present invention uses the GPT3.5 model as an artificial intelligence model for code review, trains the artificial intelligence model through the collected data, and fine-tunes the artificial intelligence model based on specific task requirements, such as syntax errors, performance bottlenecks, security vulnerabilities, etc., to enhance the ability of the artificial intelligence model to identify specific code problems. The present invention uses Dify, an application platform that integrates artificial intelligence models, to conduct code review using a chat question-and-answer method. In order to better verify the ability of the artificial intelligence model to review code, the evaluation criteria designed by the present invention define four criteria: whether the problems found by the artificial intelligence model are prepared, whether they are consistent with the results of manual review, the number of actual problems that the artificial intelligence model can find, and the comprehensive evaluation of accuracy and recall rate, and the proportion of normal code that the model incorrectly marks as a problem. Based on the historical code submission and the corresponding manual review records as the benchmark data set, the model is evaluated by the above four criteria, and only when the accuracy rate reaches more than 90% can it meet the use standard. The present invention evaluates the automatic review effect of the code to ensure the quality of the code review.

[0051] S2: The computer triggers events through the deployment software and warehouse, and automatically executes the difference generation script, compares the difference between the code to be reviewed and the previous version, and reviews the difference content. Specifically, the computer integrates the three DevOps tools of the deployment software Jenkins, the Gerrit warehouse and the application platform Dify, and automatically executes the difference generation script by configuring the trigger events of the deployment software Jenkins and the Gerrit warehouse, compares the difference between the code to be reviewed and the previous version, and sends the difference content to the application platform Dify for detailed code review. Further, the computer installs the plug-in of the Gerrit warehouse in the deployment software Jenkins, clicks Manage Jenkins->Manage Plugins in the main interface of the deployment software Jenkins, searches for and installs the Gerrit Trigger Plugin. Configure the connection of the server of the Gerrit warehouse in the deployment software Jenkins, find the Gerrit Trigger configuration part in Manage Jenkins->Configure System, and fill in the address, port, account, password, credentials and other information of the Gerrit server. Set the triggered Gerrit Project and Branches in the Jenkins Job, and when there is a new submission, the Jenkins Job will be triggered.

[0052] The computer difference generation script generates difference content, and executes and compares the difference between the code to be reviewed and the previous version when deploying the software Jenkins build. In the Jenkins Job configuration, configure the pipeline and configure the path of the difference generation script to the pipeline to ensure that Jenkins successfully executes the difference generation script and generates the correct difference file. The computer enters the API configuration page through the application platform Dify to generate an API key and configures external tools to allow access to HTTP requests. Write an API call script and send the generated difference file to Dify for review. The API calls the Dify algorithm to generate a difference file and call the API algorithm.

[0053] The specific algorithm is:

[0054]

[0055]

[0056] S3: The computer uses the artificial intelligence model in the application platform to conduct an in-depth analysis of the difference content, automatically generate a review report, identify potential problems and provide improvement suggestions. Specifically, the computer transmits the difference content to the artificial intelligence model through the API interface. The artificial intelligence model will identify potential problems in the code, such as irregular code style, performance bottlenecks, security risks, etc., and classify, describe, classify the severity level of these problems and provide improvement suggestions. The computer extracts key information from the review report returned by the artificial intelligence model, such as problem type, description, suggestions, etc., and formats the analysis results into a structured review report, which usually includes a review summary, problem classification and improvement suggestions. The review summary is the overall analysis conclusion of the AI ​​model, and the problem classification is to list all problems according to the type of problem (such as performance, security, readability, etc.). The improvement suggestions provide specific repair or optimization suggestions for each problem.

[0057] The specific algorithm is:

[0058]

[0059] S4: The computer parses the information in the review report and notifies the development team by email to view the feedback results. Specifically, the deployment software Jenkins obtains the latest generated review report from the application platform Dify, which contains detailed information and suggestions for the code review. The deployment platform Jenkins parses the review report, extracts key issues, suggestions, and related code line information, and converts it into a text format suitable for display on the Gerrit repository based on the parsed information, and publishes the generated comments. The computer obtains access rights to the Gerrit API, and then sends it to the corresponding code review record through the Gerrit API, and then notifies the development team by email to view the feedback results in a timely manner.

[0060] The specific algorithm is:

[0061]

[0062] S5: The computer incrementally trains the artificial intelligence model based on the differences between the newly submitted code and the old data, and regularly updates the review standards and rules. Specifically, the computer converts the differences in the newly submitted code and the review feedback into feature vectors and adds them to the existing training set. Ensure that the data is correctly labeled, such as problems, defect types, code improvement suggestions, etc. in the review feedback, and retrain the artificial intelligence model to ensure that the model always adapts to new code submissions. The present invention continuously updates the artificial intelligence model used for code review and can cope with the needs of continuous updates.

[0063] The specific algorithm is:

[0064]

[0065] The computer analyzes the review report to identify which fields or code snippets have poor review results, for example, checking the difference between a specific field and the model's prediction results. At the same time, code samples from different fields are collected, especially those fields that are misjudged by the model, to ensure that new training data contains more field-specific code. If the model is biased in certain fields, it can be fine-tuned and retrained using proprietary data in that field.

[0066] The specific algorithm is:

[0067]

[0068] The computer collects feedback from developers and coders on existing review standards to understand which standards are outdated and which standards need to be modified or added. Update the review rules based on feedback and technological evolution. Automatically generate or update the review rules based on new code samples. Regularly analyze the feedback from developers to find out what needs to be improved in the report, and improve the format and content of the report based on the analysis results. At the same time, ensure that the review report not only points out the problem, but also provides specific solutions or improvement suggestions.

[0069] The present invention realizes automatic code review through DevOps tool chain integration, improves the efficiency of code review, reduces labor costs, and reduces error rate.

[0070] The present invention is described above by way of example in conjunction with the accompanying drawings. Obviously, the specific implementation of the present invention is not limited to the above-mentioned methods. As long as various non-substantial improvements are made using the method concept and technical solution of the present invention; or the above concept and technical solution of the present invention are directly applied to other occasions without improvement, they are all within the protection scope of the present invention.

Claims

1. An automated code review method, characterized in that: S1: The computer collects the code and program error reports submitted by the development team in the past, trains the AI ​​model, and integrates the AI ​​model into the application platform; S2: The computer triggers events by deploying software and warehouses, and automatically executes the difference generation script to compare the difference between the code to be reviewed and the previous version, and reviews the difference content; S3: The computer uses the artificial intelligence model in the application platform to conduct in-depth analysis of the difference content, automatically generate a review report, identify potential problems and provide improvement suggestions; S4: The computer parses the information in the review report through the deployment software and notifies the development team to review the feedback results via email; S5: Computers perform incremental training on AI models based on the differences between newly submitted code and old data, and regularly update review standards and rules.

2. An automated code review method as claimed in claim 1, characterized in that: In S1, computers collect past code commits from the Gerrit repository and bug reports from bug tracking tools.

3. An automated code review method as claimed in claim 1, characterized in that: In S1, computers design evaluation criteria when training artificial intelligence models.

4. The automated code review method according to claim 1, wherein: In S2, the deployment software Jenkins receives push events from the Gerrit repository and triggers events when the code is submitted. It generates difference content through the difference generation script, and then reviews the difference content through Dify, an application platform that integrates artificial intelligence models.

5. The automated code review method according to claim 1, wherein: In S3, the structure of the review report includes the conclusion of the analysis, listing the potential problems identified, and providing specific improvement suggestions for each problem.

6. An automated code review method as claimed in claim 1, characterized in that: In S4, the computer parses the information in the review report and converts the parsed information into a text format.

7. An automated code review method as claimed in claim 1, characterized in that: In S5, the structure of the review report was optimized based on feedback from developers.

8. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

9. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • On-line code inspection system and method

    CN103677831A

Cited By

  • Software updating method and device, equipment, medium and program product

    CN120315741A