Code specification review method and device based on combination of large language model and static code check tool and electronic equipment
By combining a large language model and static code analysis tools, and dynamically adjusting configuration files, the problems of low efficiency, poor rule adaptability, and insufficient intelligence in code review are solved, achieving efficient and intelligent code style review.
Patent Information
- Application Number
- CN202511979209.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-25
- Publication Date
- 2026-02-24
AI Technical Summary
Existing code review methods are inefficient, have poor rule adaptability and insufficient intelligence, lack integration between automated tools and manual review, are difficult to maintain rule bases, and have prominent problems with cross-tool integration and context management.
By combining a large language model and static code analysis tools, code style rules are analyzed through retrieval enhancement generation technology, configuration file parameters are dynamically adjusted, and MCP architecture is used to schedule inspection tools to generate structured review reports.
It has achieved an efficient, intelligent, and flexible code style review process, improving the efficiency and accuracy of code review and enhancing the adaptability and uniformity of rules.
Smart Images

Figure CN121560720A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of code style review technology, and more specifically, to a code style review method, apparatus and electronic device based on a combination of a large language model and static code analysis tools. Background Technology
[0002] With the rapid development of artificial intelligence and Large Language Model (LLM) technology, the level of automation in the software development process is gradually increasing, especially in the field of code review. Code review is a crucial step in software development, aiming to ensure code quality, standardization, and security. Traditional code review mainly relies on manual checks by developers, which is time-consuming and prone to omissions or errors. To improve the efficiency and accuracy of code review, researchers and developers are exploring the introduction of automation tools into the code review process, with the combination of static code analysis tools and large language models emerging as a possible solution.
[0003] However, existing code review methods still face some problems, mainly in the following aspects: 1. Inefficiency: Traditional manual review methods require developers to check code line by line, which is labor-intensive and prone to oversights. Although static code analysis tools can automatically detect some common problems, they often only discover some code style issues and cannot perform in-depth analysis of the semantics and logic of the code; 2. Poor rule adaptability: Most existing static code analysis tools rely on fixed rule sets, lacking flexibility and extensibility. For different projects, developers often need to manually adjust the rules or add new inspection items according to project requirements, making the review process cumbersome and inefficient. 3. Insufficient Intelligence: While some methods attempt to combine large language models for code review, the use of large language models is often limited to simple natural language processing tasks and cannot be effectively integrated with static code analysis tools for comprehensive code analysis. Existing methods often lack the ability to comprehensively utilize different technologies and cannot fully leverage the advantages of large language models in semantic understanding and reasoning. To address the aforementioned issues, existing research attempts to overcome the shortcomings of code review by introducing smarter algorithmic strategies or employing a combination of static and dynamic analysis. However, these methods still suffer from the following problems: 1. Insufficient integration of automated tools and human review: Although static analysis tools can help developers automatically discover some common errors, they still cannot effectively replace the in-depth judgment in human review, especially in complex code logic and business requirement analysis; 2. Difficulty in maintaining and updating the rule base: Existing tools often use fixed rule sets. As the project progresses, developers need to continuously update the rule base to adapt to new requirements. This process is not only time-consuming but also error-prone, lacking flexibility and scalability. 3. Cross-tool integration and context management issues: Existing tool integration often suffers from fragmentation, making it difficult to achieve context sharing between different tools. This leads to a lack of coordination and consistency in the code review process, affecting the accuracy and comprehensiveness of the review results. Summary of the Invention
[0004] The embodiments of this application provide a code style review method, apparatus, and electronic device based on a combination of a large language model and a static code analysis tool, to overcome the problems of low efficiency, poor rule adaptability, and insufficient intelligence in the code review process of the prior art.
[0005] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0006] According to a first aspect of the embodiments of this application, a code style review method based on a combination of a large language model and static code analysis tools is provided, including: The code inspection rule files in the project are parsed using retrieval enhancement generation technology to read and understand each code style rule. Analyze the type of each code style rule and assign a suitable inspection tool to each code style rule. The inspection tools include: a large language model and a static code inspection tool. The static code analysis tool generates a configuration file based on the code style rules and dynamically adjusts the configuration file parameters according to the specific project requirements. Use the MCP architecture to schedule large language models or static code analysis tools for inspection; Summarize all inspection results and generate a structured code review report.
[0007] In some embodiments of this application, based on the foregoing scheme, the step of parsing the code inspection rule file in the project using retrieval enhancement generation technology, and reading and understanding each code style rule therein, includes: Relevant specification entries are retrieved from existing code specification libraries using search-enhanced generation techniques. By using a large language model to deeply understand the retrieved normative entries, the core requirements of the rules can be extracted. Generate a specification summary that meets the project's specific requirements, based on the project's actual situation.
[0008] In some embodiments of this application, based on the foregoing scheme, the step of analyzing each code style rule type and assigning a suitable inspection tool to each code style rule includes: Automatically identify and categorize each code style rule based on its nature; Choose either a static code analysis tool or a large language model based on the rule category.
[0009] In some embodiments of this application, based on the foregoing scheme, the step of generating a configuration file for the static code analysis tool according to the code style rule type, and dynamically adjusting the configuration file parameters according to the specific project situation, includes: Based on the category of each code style rule, generate configuration files for static code analysis tools corresponding to different categories; The configuration file format is automatically generated according to the rule requirements; The parameters in the configuration file are automatically adjusted according to the specific circumstances of the project.
[0010] In some embodiments of this application, the process of checking using a large language model based on the foregoing scheme includes: Generate codebases and inspection tasks based on the inspection rules of the inspection tool; The code is inspected based on the codebase and the inspection task.
[0011] In some embodiments of this application, based on the foregoing scheme, the step of generating the codebase and inspection tasks according to the inspection rules of the inspection tool includes: Prepare the codebase according to the checking rules of the large language model; Convert the codebase into a format suitable for large language model checks; Based on the checking rules of the large language model, relevant checking tasks are generated, and each task is analyzed according to specific checking rules. Based on the rule category, inspection tasks are assigned to groups, with each group containing a maximum of ten inspection tasks.
[0012] In some embodiments of this application, based on the foregoing scheme, code inspection is performed according to the code library and the inspection task, including: The large language model is used to inspect all code according to predetermined inspection tasks, identify potential problems and perform rule matching.
[0013] In some embodiments of this application, based on the foregoing scheme, the step of summarizing all inspection results and generating a structured code review report includes: Collect and summarize all inspection results from different inspection tools, including the inspection output of each tool, identified code issues, violation rules, detected files and related line numbers; Based on the summarized inspection results, a structured code review report is generated, which includes detailed inspection items, detected issues, and violation types. The code review report should indicate the location and severity of each issue. For each detected issue, repair suggestions are generated based on coding standards and inspection rules, and specific solutions or modifications are provided in the code review report. Save code review reports to a specified file storage location and support export in multiple formats.
[0014] According to a second aspect of the embodiments of this application, a code style review apparatus based on a combination of a large language model and static code analysis tools is provided, comprising: The parsing unit is used to parse the code inspection rule files in the project using retrieval enhancement generation technology, and to read and understand each code style rule in them; The allocation unit is used to analyze the type of each code style rule and assign a suitable inspection tool to each code style rule. The inspection tools include: a large language model and a static code inspection tool. The generation unit is used to generate configuration files for static code analysis tools based on code style rules and dynamically adjust the configuration file parameters according to the specific project situation. The inspection unit is used to schedule large language models or static code analysis tools to perform inspections using the MCP architecture. The summary unit is used to summarize all inspection results and generate a structured code review report.
[0015] According to a third aspect of the embodiments of this application, an electronic device is provided, including: a memory and a processor; The memory is used to store computer instructions; The processor is configured to invoke computer instructions stored in the memory, causing the electronic device to execute the method described in the first aspect.
[0016] The technical solution of this application solves the problems of low execution efficiency and lack of intelligent judgment in traditional code review tools. By combining a large language model and static analysis tools, it utilizes the MCP architecture to achieve a more efficient, intelligent and flexible code style review process.
[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings: Figure 1 A flowchart illustrating a code style review method based on a combination of a large language model and a static code analysis tool, according to an embodiment of this application, is shown. Figure 2 A block diagram of a code style review apparatus based on a combination of a large language model and a static code analysis tool, according to an embodiment of this application, is shown. Figure 3 A block diagram of an electronic device according to one embodiment of this application is shown; Figure 4 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation
[0019] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0020] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0021] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0022] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily need to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0023] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0024] The following detailed description of some embodiments of this application will be provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0025] See Figure 1 The diagram illustrates a flowchart of a code style review method based on a combination of a large language model and a static code analysis tool, according to an embodiment of this application.
[0026] like Figure 1 As shown, a code style review method based on a combination of a large language model and a static code analysis tool is demonstrated, specifically including steps S100 to S500.
[0027] refer to Figure 1 In step S100, the code inspection rule file in the project is parsed using retrieval enhancement generation technology, and each code style rule in it is read and understood.
[0028] In some feasible embodiments, based on the foregoing scheme, step S100 includes: Relevant specification entries are retrieved from existing code specification libraries using search-enhanced generation techniques. By using a large language model to deeply understand the retrieved normative entries, the core requirements of the rules can be extracted. Generate a specification summary that meets the project's specific requirements, based on the project's actual situation.
[0029] For example, step S100 specifically includes: Step S110: Retrieve relevant rules from the code style knowledge base using RAG (Retrieval Enhancement Generation) technology. Understandably, RAG technology is used to retrieve project-related code style entries to enhance understanding of the style content.
[0030] Step S120: Perform semantic understanding and parsing using a large language model. Conduct deep semantic analysis on the retrieved specification content to ensure the matching degree between the specification content and the code, thereby improving the accuracy of the specification.
[0031] Step S130: Generate a specification summary that meets the current project requirements. Based on the actual situation of the project, automatically generate a project-related specification summary to facilitate subsequent review tasks.
[0032] Continue to refer to Figure 1 Step S200: Analyze the type of each code style rule and assign a suitable inspection tool to each code style rule. The inspection tools include: a large language model and a static code inspection tool.
[0033] In some feasible embodiments, based on the foregoing scheme, step S200 includes: Automatically identify and categorize each code style rule based on its nature; Choose either a static code analysis tool or a large language model based on the rule category.
[0034] For example, step S200 specifically includes: Step S210: Analyze the type of code style rule. The system automatically identifies and classifies each code style rule based on its nature (such as format, logic, security, etc.) to select the most suitable inspection tool type; Step S220: Perform a tool compatibility check. The system checks the compatibility between the current development environment and the tools to ensure that the selected tools support the current code library type and can correctly process the relevant code files; Step S230: Automatically select the static code analysis tool and the large language model. For format checking, the system selects the static code analysis tool; for logical and complex semantic rules, the system calls the large language model for in-depth analysis. Step S240: Dynamically adjust tool configuration. Based on project requirements and feedback from tool execution, automatically adjust the tool configuration to optimize the inspection process and improve review efficiency and accuracy.
[0035] Continue to refer to Figure 1 Step S300: Generate a configuration file for the static code analysis tool based on the code style rule type, and dynamically adjust the configuration file parameters according to the specific project situation.
[0036] It is understood that in this embodiment, the configuration file of the large language model is generated using existing technology, therefore the generation of the large language model configuration file and parameter adjustment are not described in detail in this embodiment.
[0037] In some feasible embodiments, based on the foregoing scheme, step S300 includes: Based on the category of each code style rule, generate configuration files for static code analysis tools corresponding to different categories; The configuration file format is automatically generated according to the rule requirements; The parameters in the configuration file are automatically adjusted according to the specific circumstances of the project.
[0038] For example, step S300 specifically includes: Step S310: Generate configuration files based on rule type. The system generates corresponding static code analysis tool configuration files based on the category of each specification rule (such as format, performance, security, etc.) to ensure that the static code analysis tool can perform targeted analysis tasks; Step S320: Automatically generate configuration file format. For static code analysis tools (such as Checkstyle, PMD, etc.), automatically generate configuration files that meet the rules and ensure compatibility with the tools; Step S330: Adjust configuration parameters to suit the project environment. The system automatically adjusts the parameters in the configuration file (such as encoding format, file path, etc.) according to the project's programming language and code library structure to ensure efficient tool execution; Step S340: Dynamically update and optimize configuration files. Based on the tool's execution results, the system can dynamically optimize and update configuration files, improving execution efficiency and accuracy.
[0039] Continue to refer to Figure 1 Step S400: Use the MCP architecture to schedule a large language model or static code analysis tool for inspection.
[0040] It should be noted that in this embodiment, the MCP architecture is used to uniformly schedule various inspection tools (static code inspection tools and large language models) to ensure that all tools are correctly initialized before execution and started in a predetermined order.
[0041] It should be noted that in this embodiment, the MCP architecture manages multiple inspection tasks and ensures that each task can be executed in parallel or sequentially to improve overall inspection efficiency. Each task is assigned to an appropriate tool to ensure high efficiency and accuracy during task execution.
[0042] It should be noted that in this embodiment, the MCP architecture ensures seamless collaboration between different types of tools through standardized interfaces. For example, static analysis tools and large language models can share contextual information during execution to comprehensively evaluate code quality.
[0043] It should be noted that in this embodiment, the system monitors the execution status of each tool in real time to ensure that the tools start correctly and can complete the specified check tasks. If a tool fails to start or executes abnormally, the system will automatically perform error repair or adjust the scheduling strategy.
[0044] It should be noted that in this embodiment, after all tools have completed their respective inspection tasks, the MCP architecture will summarize the inspection results of each tool and pass them to subsequent steps for report generation and storage.
[0045] In some feasible embodiments, the process of performing the inspection using a large language model based on the aforementioned scheme includes: Generate codebases and inspection tasks based on the inspection rules of the inspection tool; The code is inspected based on the codebase and the inspection task.
[0046] In some feasible embodiments, based on the foregoing scheme, the step of generating the codebase and inspection tasks according to the inspection rules of the inspection tool includes: Prepare the codebase according to the checking rules of the large language model; Convert the codebase into a format suitable for large language model checks; Based on the checking rules of the large language model, relevant checking tasks are generated, and each task is analyzed according to specific checking rules. Based on the rule category, inspection tasks are assigned to groups, with each group containing a maximum of ten inspection tasks.
[0047] It should be noted that during the code repository preparation process, for Git repositories, the system uses the `git clone` command to download and synchronize the latest code version; for local code repositories, the system directly specifies the path and ensures the code repository is complete.
[0048] It should be noted that the purpose of converting the codebase into a format suitable for large language model checks is to enable the model to perform semantic analysis and rule validation.
[0049] In some feasible embodiments, based on the foregoing scheme, the code is inspected according to the codebase and the inspection task, including: The large language model is used to inspect all code according to predetermined inspection tasks, identify potential problems and perform rule matching.
[0050] Continue to refer to Figure 1 Step S500: Summarize all inspection results and generate a structured code review report.
[0051] In some feasible embodiments, based on the foregoing scheme, step S500 includes: Collect and summarize all inspection results from different inspection tools, including the inspection output of each tool, identified code issues, violation rules, detected files and related line numbers; Based on the summarized inspection results, a structured code review report is generated, which includes detailed inspection items, detected issues, and violation types. The code review report should indicate the location and severity of each issue. For each detected issue, repair suggestions are generated based on coding standards and inspection rules, and specific solutions or modifications are provided in the code review report. Save code review reports to a specified file storage location and support export in multiple formats.
[0052] The following describes an embodiment of the apparatus described in this application, which can be used to execute a code style review method based on a combination of a large language model and a static code analysis tool, as described in the above embodiments of this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in the above applications.
[0053] Reference Figure 2 As shown, a code style review apparatus 200 based on a combination of a large language model and a static code analysis tool, according to an embodiment of this application, includes: Parsing unit 201 is used to parse the code inspection rule file in the project through retrieval enhancement generation technology, and read and understand each code style rule in it; The allocation unit 202 is used to analyze the type of each code style rule and allocate a suitable inspection tool to each code style rule. The inspection tools include: a large language model and a static code inspection tool. Generation unit 203 is used to generate configuration files for static code analysis tools according to code style rules and dynamically adjust configuration file parameters according to the specific circumstances of the project. Inspection unit 204 is used to schedule large language models or static code analysis tools to perform inspections using the MCP architecture; Summary unit 205 is used to summarize all inspection results and generate a structured code review report.
[0054] like Figure 3 As shown, this application embodiment also provides an electronic device 300, including a memory 310, a processor 320, and a computer program 311 stored in the memory 310 and executable on the processor. When the processor 320 executes the computer program 311, it implements the steps of the above-mentioned code style review method based on a combination of a large language model and a static code inspection tool.
[0055] Since the electronic device described in this embodiment is the device used to implement the code style review device based on the combination of a large language model and a static code inspection tool in the embodiments of this application, those skilled in the art can understand the specific implementation method and its various variations of the electronic device in this embodiment based on the method described in the embodiments of this application. Therefore, how the electronic device implements the method in the embodiments of this application will not be described in detail here. Any device used by those skilled in the art to implement the method in the embodiments of this application falls within the scope of protection of this application.
[0056] In practice, when the computer program 311 is executed by the processor, it can implement any of the embodiments corresponding to the first aspect.
[0057] Figure 4 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown.
[0058] It should be noted that, Figure 4 The computer system 400 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0059] like Figure 4 As shown, the computer system 400 includes a Central Processing Unit (CPU) 401, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 402 or programs loaded from storage portion 408 into Random Access Memory (RAM) 403, such as performing the methods described in the above embodiments. Various programs and data required for system operation are also stored in RAM 403. The CPU 401, ROM 402, and RAM 403 are interconnected via bus 404. An Input / Output (I / O) interface 405 is also connected to bus 404.
[0060] The following components are connected to I / O interface 405: an input section 406 including a keyboard, mouse, etc.; an output section 407 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to I / O interface 405 as needed. A removable medium 411, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 410 as needed so that computer programs read from it can be installed into storage section 408 as needed.
[0061] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 409, and / or installed from removable medium 411. When the computer program is executed by central processing unit (CPU) 401, it performs various functions defined in the system of this application.
[0062] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0063] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0064] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.
[0065] In another aspect, this application also provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the code style review method based on a combination of a large language model and static code analysis tools described in the above embodiments.
[0066] In another aspect, this application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to implement the code style review method based on a combination of a large language model and static code analysis tools described in the above embodiments.
[0067] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0068] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the methods according to the embodiments of this application.
[0069] Other embodiments of this application will readily conceive of by those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. It should be understood that this application is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A code style review method based on a combination of a large language model and static code analysis tools, characterized in that, include: The code inspection rule files in the project are parsed using retrieval enhancement generation technology to read and understand each code style rule. Analyze the type of each code style rule and assign a suitable inspection tool to each code style rule. The inspection tools include: a large language model and a static code inspection tool. The static code analysis tool generates a configuration file based on the code style rules and dynamically adjusts the configuration file parameters according to the specific project requirements. Use the MCP architecture to schedule large language models or static code analysis tools for inspection; Summarize all inspection results and generate a structured code review report.
2. The method according to claim 1, characterized in that, The process involves parsing the code inspection rule files in the project using enhanced retrieval technology, reading and understanding each code style rule, including: Relevant specification entries are retrieved from existing code specification libraries using search-enhanced generation techniques. By using a large language model to deeply understand the retrieved normative entries, the core requirements of the rules can be extracted. Generate a specification summary that meets the project's specific requirements, based on the project's actual situation.
3. The method according to claim 1, characterized in that, The analysis covers the type of each code style rule and assigns a suitable inspection tool to each rule, including: Automatically identify and categorize each code style rule based on its nature; Choose either a static code analysis tool or a large language model based on the rule category.
4. The method according to claim 3, characterized in that, The process of generating a configuration file for the static code analysis tool based on code style rules and dynamically adjusting the configuration file parameters according to the specific project requirements includes: Based on the category of each code style rule, generate configuration files for static code analysis tools corresponding to different categories; The configuration file format is automatically generated according to the rule requirements; The parameters in the configuration file are automatically adjusted according to the specific circumstances of the project.
5. The method according to claim 3, characterized in that, The process of using a large language model for inspection includes: Generate codebases and inspection tasks based on the inspection rules of the inspection tool; The code is inspected based on the codebase and the inspection task.
6. The method according to claim 5, characterized in that, The process of generating a codebase and inspection tasks based on the inspection rules of the inspection tool includes: Prepare the codebase according to the checking rules of the large language model; Convert the codebase into a format suitable for large language model checks; Based on the checking rules of the large language model, relevant checking tasks are generated, and each task is analyzed according to specific checking rules. Based on the rule category, inspection tasks are assigned to groups, with each group containing a maximum of ten inspection tasks.
7. The method according to claim 5, characterized in that, The code is inspected based on the codebase and the inspection task, including: The large language model is used to inspect all code according to predetermined inspection tasks, identify potential problems and perform rule matching.
8. The method according to claim 7, characterized in that, The summary of all inspection results generates a structured code review report, including: Collect and summarize all inspection results from different inspection tools, including the inspection output of each tool, identified code issues, violation rules, detected files and related line numbers; Based on the summarized inspection results, a structured code review report is generated, which includes detailed inspection items, detected issues, and violation types. The code review report should indicate the location and severity of each issue. For each detected issue, repair suggestions are generated based on coding standards and inspection rules, and specific solutions or modifications are provided in the code review report. Save code review reports to a specified file storage location and support export in multiple formats.
9. A code style review device based on a combination of a large language model and static code analysis tools, characterized in that, include: The parsing unit is used to parse the code inspection rule files in the project using retrieval enhancement generation technology, and to read and understand each code style rule in them; The allocation unit is used to analyze the type of each code style rule and assign a suitable inspection tool to each code style rule. The inspection tools include: a large language model and a static code inspection tool. The generation unit is used to generate configuration files for static code analysis tools based on code style rules and dynamically adjust the configuration file parameters according to the specific project situation. The inspection unit is used to schedule large language models or static code analysis tools to perform inspections using the MCP architecture. The summary unit is used to summarize all inspection results and generate a structured code review report.
10. An electronic device, characterized in that, include: Memory and processor; The memory is used to store computer instructions; The processor is configured to invoke computer instructions stored in the memory, causing the electronic device to perform the method as described in any one of claims 1-8.