Automatic online code review method and system

By setting up webhook requests in the code repository and automatically calling the AI ​​code review system for code review, the problems of low efficiency and poor accuracy of traditional manual code review are solved, and automated online code review is realized, which improves software quality and development efficiency.

CN119512902APending Publication Date: 2025-02-25SHANDONG LUNENG SOFTWARE TECH
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411684219.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

Traditional code review methods rely on manual labor, are inefficient and prone to errors, resulting in the inability to effectively guarantee the quality of the software.

Method used

Using automated online code review methods and systems, by setting up webhook requests in the code repository, the AI ​​code review system is automatically called for code review. The AI ​​system matches the code rules according to the preset rule template configuration, detects codes that violate rules, and generates review reports.

Benefits of technology

It improves the efficiency and accuracy of code review, reduces the cost and error rate of manual review, ensures the implementation of company coding specifications, and improves software quality and development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512902A_ABST
    Figure CN119512902A_ABST
Patent Text Reader

Abstract

The invention relates to the field of automation, the field of artificial intelligence and the technical field of code quality management, and provides an automatic online code review method and system. The method comprises the following steps: compiling a self-defined rule description document, and compiling or updating a formulated coding specification document; a webhook request is set in a code warehouse in advance and used for automatically triggering an external service or process when a specific event occurs in the code warehouse; compiling or modifying codes, and manually / automatically submitting the codes to a code warehouse; the code warehouse automatically triggers a pre-configured webhook request, and then an interface of an AI code review system is called for code review; the AI review system pulls the to-be-reviewed code, performs rule matching on the to-be-reviewed code according to preset rule template configuration, detects whether a code violating a rule exists or not, and generates a review report after review is completed; wherein the rule template configuration comprises a rule description document and a coding specification document.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of automation, artificial intelligence and code quality management, and in particular to an automated online code review method and system. Background Art

[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.

[0003] Traditional code review methods mostly rely on manual review, which is often not efficient enough and often results in errors due to human factors, which undoubtedly poses a hidden danger to software quality assurance.

[0004] At the same time, many code review programs have formulated detailed coding standards, but in actual operations, these standards are often not effectively implemented. This is mainly because coding standards often only remain on paper, and relevant personnel often deviate in actual operations, which makes it impossible to ensure software quality.

[0005] Moreover, the current code quality and security do not meet the coding standards set by the company, resulting in low development efficiency, increased later debugging and operation and maintenance costs, and may even cause project delays. Summary of the invention

[0006] In order to solve the technical problems existing in the above background technology, the present invention provides an automated online code review method and system, which can detect errors and potential risks in the code through automated review, thereby effectively improving the quality of the software. At the same time, due to the automated review, the efficiency and accuracy of the review can be greatly improved, avoiding some errors that may occur in manual review.

[0007] In order to achieve the above object, the present invention adopts the following technical solution:

[0008] A first aspect of the present invention provides an automated online code review method.

[0009] An automated online code review method, comprising:

[0010] Write custom rule description documents, write or update established coding standard documents; set up webhook requests in the code repository in advance to automatically trigger external services or processes when specific events occur in the code repository;

[0011] Write or modify code and submit it manually / automatically to the code repository;

[0012] The code repository automatically triggers a pre-configured webhook request, and then calls the interface of the AI ​​code review system for code review; the AI ​​review system pulls the code to be reviewed, and matches the code to be reviewed according to the preset rule template configuration, detects whether there is any code that violates the rules, and generates a review report after the review is completed; wherein, the rule template configuration includes a rule description document and a coding specification document.

[0013] Furthermore, the writing of the customized rule description document includes manually adding new security rules or coding specifications.

[0014] Furthermore, the process of performing rule matching on the code to be reviewed according to the preset rule template configuration also includes: the AI ​​review system automatically adds the newly generated rule description document and / or coding specification document to the rule library.

[0015] Furthermore, the process of matching the code to be reviewed according to the preset rule template configuration also includes: the AI ​​review system automatically adds the new rules in the rule library to the rule template configuration.

[0016] Furthermore, the process of performing rule matching on the code to be reviewed according to the preset rule template configuration also includes: using a code parser to parse the code to be reviewed to obtain the structure and logic information of the code, and then using the preset rule template configuration to perform rule matching.

[0017] Furthermore, the review report includes an assessment of code quality, performance, and security, and provides suggestions for improvement.

[0018] Furthermore, after the problems in the review report are found and modified, the modified code is reviewed again. If it meets the requirements of the rules, it passes the review; if there is still code that violates the rules, the review report continues to be generated.

[0019] A second aspect of the present invention provides an automated online code review system.

[0020] An automated online code review system, comprising:

[0021] The rule writing module is configured to: write custom rule description documents, write or update the established coding standard documents; set up webhook requests in the code repository in advance to automatically trigger external services or processes when specific events occur in the code repository;

[0022] A code writing module, which is configured to: write or modify code and submit it manually or automatically to the code repository;

[0023] The review module is configured as follows: the code repository automatically triggers a pre-configured webhook request, and then calls the interface of the AI ​​code review system for code review; the AI ​​review system pulls the code to be reviewed, and matches the code to be reviewed according to the preset rule template configuration, detects whether there is any code that violates the rules, and generates a review report after the review is completed; wherein, the rule template configuration includes a rule description document and a coding specification document.

[0024] A third aspect of the present invention provides a computer-readable storage medium.

[0025] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps in the first automated online code review method described above.

[0026] A fourth aspect of the present invention provides a computer device.

[0027] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the first automated online code review method described above are implemented.

[0028] Compared with the prior art, the present invention has the following beneficial effects:

[0029] The present invention realizes the automation and intelligence of code review, improves the efficiency and accuracy of code review, reduces the cost and error rate of manual review, and ensures the implementation of the company's coding standards. At the same time, the preset rule library can be customized and expanded as needed, with strong flexibility and adaptability.

[0030] In the present invention, some review rules can be set according to the coding standards formulated by the company, and behaviors that do not meet the standards can be prompted or prohibited, so that relevant personnel must abide by these standards when writing code, effectively promoting the implementation of coding standards; not only can the quality of software be improved, but also the development efficiency can be improved and the development cost can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0032] Figure 1 It is a flowchart of automatic code review shown in the present invention;

[0033] Figure 2 It is a flow chart of the AI ​​code review system shown in the present invention. DETAILED DESCRIPTION

[0034] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0035] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0036] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0037] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the methods and systems according to various embodiments of the present disclosure. It should be noted that each box in the flowchart or block diagram can represent a module, a program segment, or a part of a code, and the module, program segment, or a part of a code may include one or more executable instructions for implementing the logical functions specified in each embodiment. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the flowchart and / or block diagram, and the combination of boxes in the flowchart and / or block diagram can be implemented using a dedicated hardware-based system that performs a specified function or operation, or can be implemented using a combination of dedicated hardware and computer instructions.

[0038] Embodiment 1

[0039] This embodiment provides an automated online code review method, including:

[0040] Write custom rule description documents, write or update established coding standard documents; set up webhook requests in the code repository in advance to automatically trigger external services or processes when specific events occur in the code repository;

[0041] Write or modify code and submit it manually / automatically to the code repository;

[0042] The code repository automatically triggers a pre-configured webhook request, and then calls the interface of the AI ​​code review system for code review; the AI ​​review system pulls the code to be reviewed, and matches the code to be reviewed according to the preset rule template configuration, detects whether there is any code that violates the rules, and generates a review report after the review is completed; wherein, the rule template configuration includes a rule description document and a coding specification document.

[0043] The specific scheme of this embodiment is analyzed in detail below with reference to the accompanying drawings:

[0044] See the automatic code review process for Figure 1 As shown:

[0045] Pa: Write custom rule description documents to manually add new security rules or coding standards.

[0046] Pb: Write or update the company's coding standard documents, including coding standards for Java, JavaScript, C++ and other related development languages.

[0047] P1: Relevant personnel write or modify the code and submit it to the code repository.

[0048] P2: The code repository will trigger a webhook request and automatically push it to the AI ​​code review system.

[0049] P3: The AI ​​code review system automatically obtains the code to be reviewed, and parses it through a preset code parser to obtain the structure and logic information of the code. The code is reviewed according to the pre-set rules and configuration parameters. The review direction is mainly to evaluate the quality, performance, security and other aspects of the code, and put forward improvement suggestions.

[0050] P4: The review report is automatically generated after the review is completed.

[0051] P5: Relevant personnel modify the code according to the review report and resubmit the modified code to the system.

[0052] The system re-examines the modified code. If it meets the requirements of the rules, it passes the review; if there is still code that violates the rules, it continues to generate a review report and repeats steps P1 to P5.

[0053] See the AI ​​code review system process for details. Figure 2 As shown:

[0054] P1: Deploy the AI ​​code review system and configure the preset code review rule template.

[0055] Pa: Write custom rule description documents to manually add new security rules or coding standards.

[0056] Pb: Write or update the company's coding standard documents, including coding standards for Java, JavaScript, C++ and other related development languages.

[0057] P2: Configure webhook in the code repository. Configure webhook in the Git code repository and associate it with the AI ​​code review system.

[0058] P3: When the code in the code repository changes (the code is submitted to the code repository), the code repository will trigger a webhook request and call the interface of the AI ​​code review system. The AI ​​review system will pull the Git code and match the code according to the preset rule template configuration (for example, rules for errors and vulnerability types, which may check the risk of SQL injection, unhandled exceptions, null pointer exceptions, etc.) to detect whether there is any code that violates the rules.

[0059] P3.1: The AI ​​code review system is a software tool based on a neural network architecture that is used to help programmers check and optimize code quality. The core of the system is a neural network architecture based on Transformer, a deep learning model widely used in natural language processing tasks.

[0060] In this system, there is first a rule interpretation engine. The main function of this engine is to extract rules from given inputs and convert them into a machine-understandable form. These inputs can be custom rule description documents or natural language texts such as the company's coding standard documents.

[0061] Specifically, when a user enters a custom rule or specification document, the rule interpretation engine will parse these rules using its internal code review model, which is based on the Transformer neural network architecture and can understand and process complex natural language structures.

[0062] Then, the rule interpretation engine will generate a series of code review rules based on the parsing results. These rules can be either grammatical (for example, requiring all variable names to start with a lowercase letter) or semantic (for example, prohibiting the modification and query of the same data in the same function at the same time). Finally, these rules will be applied to the actual code review process to help programmers find and fix potential problems.

[0063] P3.2: The system automatically adds newly generated rules to the rule base, such as the Java coding rule base, JavaScript rule base, etc.

[0064] P3.3: The system automatically categorizes new rules in the rule base into preset template configurations, such as bugs, vulnerabilities, odors, security hotspots, etc.

[0065] P3.4: The system automatically obtains the code to be reviewed, and parses the source code through a preset code parser (it is responsible for reading the source code, and has functions such as syntax parsing and lexical parsing, and converts the code into a structured data that can be understood and processed by the platform. This structured data is usually called an abstract syntax tree) to obtain the structured data and logical information of the code. Once the code is parsed and converted into structured data, the system can use preset rule templates to match the rules on this data. These rule templates usually define a series of checkpoints to detect various problems in the code, such as potential defects, performance issues, code smells, etc. During the matching process, the system traverses the AST or CFG to find code structures or logical patterns that match the rules. Finally, based on the results of the rule matching, the system generates a review report that lists all detected problems, including information such as the description, location, and severity of the problem.

[0066] P4: The system automatically generates a review report to evaluate the code quality (for example, by checking the complexity, redundancy, long methods, long parameter lists and other indicators to identify bad smells in the code), performance evaluation (for example, by calculating the time complexity and space complexity of the code to evaluate its performance), security evaluation (for example, by checking the possible security vulnerabilities in the code, such as SQL injection, cross-site scripting attacks (XSS), cross-site request forgery (CSRF)), etc.), and put forward improvement suggestions.

[0067] P5: After the report is generated, the user needs to log in to the system page to view the review report. According to the review report, locate the problems and solve them.

[0068] The AI ​​code review system described in this embodiment can detect potential problems in the code writing stage, reducing the workload of later debugging and repair. By discovering and solving problems in advance, the risk of code quality degradation and project delays can be avoided.

[0069] The AI ​​code review system described in this embodiment can help teams establish and maintain a unified coding style and best practices. Through a standardized code style, the readability and maintainability of the code can be improved, and the communication and collaboration costs between team members can be reduced.

[0070] In this embodiment, by continuously using quality control tools, the development team can gradually improve code quality and cultivate good coding habits. It can help the team establish long-term quality awareness and focus on the testability, scalability and reusability of the code.

[0071] The quality control tool described in this embodiment can automate the process of code quality assessment, reduce manual subjective judgment and tedious manual inspection, save time and energy, improve development efficiency, and allow relevant personnel to focus more on the implementation of core business logic.

[0072] The AI ​​code review system described in this embodiment can collect and analyze code quality indicators and generate visual reports. Through the reports, the development team can understand the overall code quality, distribution and trends of problems, etc., so as to formulate corresponding improvement measures and priorities.

[0073] This embodiment performs code review in an automated and intelligent manner, thereby improving the efficiency and accuracy of the review.

[0074] In this invention, when the content in the code repository changes, it will be automatically pushed to the AI ​​code review system for review. The system's review capabilities can be adjusted according to the company's specific coding rules and personalized needs, making the review process more practical and easier to adapt to the update of the review standards.

[0075] In the present invention, the preset rule base can be customized and expanded as needed, which is more flexible and adaptable. Its implementation not only helps to improve code quality and security, but also helps to reduce the later debugging and operation and maintenance costs, improve development efficiency, and ensure the timely completion of the project.

[0076] Embodiment 2

[0077] This embodiment provides an automated online code review system.

[0078] An automated online code review system, comprising:

[0079] The rule writing module is configured to: write custom rule description documents, write or update the established coding standard documents; set up webhook requests in the code repository in advance to automatically trigger external services or processes when specific events occur in the code repository;

[0080] A code writing module, which is configured to: write or modify code and submit it manually or automatically to the code repository;

[0081] The review module is configured as follows: the code repository automatically triggers a pre-configured webhook request, and then calls the interface of the AI ​​code review system for code review; the AI ​​review system pulls the code to be reviewed, and matches the code to be reviewed according to the preset rule template configuration, detects whether there is any code that violates the rules, and generates a review report after the review is completed; wherein, the rule template configuration includes a rule description document and a coding specification document.

[0082] Embodiment 3

[0083] This embodiment provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the steps in the first automated online code review method described above are implemented.

[0084] Embodiment 4

[0085] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps in the first automated online code review method described above are implemented.

[0086] A person skilled in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0087] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data processing device such as a server, a data center, etc. that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

[0088] The above description is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technical object familiar with the technical field can be easily changed or replaced within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. An automated online code review method, characterized in that: include: Write custom rule description documents, and write or update established coding standard documents; Set up webhook requests in the code repository in advance to automatically trigger external services or processes when specific events occur in the code repository; Write or modify code and submit it manually / automatically to the code repository; The code repository automatically triggers a pre-configured webhook request, and then calls the interface of the AI ​​code review system for code review; the AI ​​review system pulls the code to be reviewed, and matches the code to be reviewed according to the preset rule template configuration, detects whether there is any code that violates the rules, and generates a review report after the review is completed; wherein, the rule template configuration includes a rule description document and a coding specification document.

2. The automated online code review method according to claim 1, characterized in that: The writing of a customized rule description document includes manually adding new security rules or coding standards.

3. The automated online code review method according to claim 1, characterized in that: The process of performing rule matching on the code to be reviewed according to the preset rule template configuration also includes: the AI ​​review system automatically adds the newly generated rule description document and / or coding specification document to the rule library.

4. The automated online code review method according to claim 3, characterized in that: The process of matching rules on the code to be reviewed according to the preset rule template configuration also includes: the AI ​​review system automatically adds new rules in the rule library to the rule template configuration.

5. The automated online code review method according to claim 1, characterized in that: The process of performing rule matching on the code to be reviewed according to the preset rule template configuration also includes: using a code parser to parse the code to be reviewed to obtain the structure and logic information of the code, and then using the preset rule template configuration to perform rule matching.

6. The automated online code review method according to claim 1, characterized in that: The review report includes an assessment of code quality, performance, and security, and provides suggestions for improvements.

7. The automated online code review method according to claim 1, characterized in that: After the problems in the review report are found and modified, the modified code is reviewed again. If it meets the requirements of the rules, it passes the review; if there is still code that violates the rules, the review report will continue to be generated.

8. An automated online code review system, characterized in that: include: A rule writing module is configured to: write a custom rule description document, and write or update a formulated coding specification document; Set up webhook requests in the code repository in advance to automatically trigger external services or processes when specific events occur in the code repository; A code writing module, which is configured to: write or modify code and submit it manually or automatically to the code repository; The review module is configured as follows: the code repository automatically triggers a pre-configured webhook request, and then calls the interface of the AI ​​code review system for code review; the AI ​​review system pulls the code to be reviewed, and matches the code to be reviewed according to the preset rule template configuration, detects whether there is any code that violates the rules, and generates a review report after the review is completed; wherein, the rule template configuration includes a rule description document and a coding specification document.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps in the automated online code review method as described in any one of claims 1 to 7 are implemented.

10. A computer device 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 program, the steps in the automated online code review method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Method, apparatus, device and product for introducing signal in code

    CN120315690A

  • Application method of DevOps pipeline business code auditing

    CN120315987A

  • Automatic code review method and system based on AI assistance

    CN122387819A