Code review method and device, computer device and storage medium

By extracting the contextual features and functional requirements of lines of code and using a code review model for multi-dimensional analysis, the problems of low accuracy and efficiency in traditional code review are solved, and refined code review is achieved.

CN122152658APending Publication Date: 2026-06-05BEIJING BAILONG MAYUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING BAILONG MAYUN TECH CO LTD
Filing Date
2026-01-30
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Traditional code reviews rely on manual line-by-line examination, making it difficult to identify the development background and design intent of the code, thus affecting the accuracy and efficiency of the review.

Method used

By extracting contextual feature data of the current line of code, code commit records, and functional requirement information, a pre-trained code review model is used to perform multi-dimensional analysis and generate review results.

Benefits of technology

It improves the accuracy and efficiency of code review, refines the review granularity, and enables detailed review of each line of code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122152658A_ABST
    Figure CN122152658A_ABST
Patent Text Reader

Abstract

The application relates to a code review method and device, computer equipment and a storage medium. The foregoing method comprises the following steps: in response to a review request of a current code line, extracting context feature data of the current code line, obtaining a code submission record corresponding to the current code line, obtaining code branch information to which the current code line belongs according to the code submission record, obtaining function requirement information corresponding to the current code line according to the code branch information, inputting the context feature data, the historical code submission record and the function requirement information into a pre-trained code review model, and obtaining a review result corresponding to the current code line. The method can improve the efficiency of code review and refine the review granularity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a code review method, apparatus, computer device, and storage medium. Background Technology

[0002] Code review is a core quality control step in software development. It is primarily used to verify the match between code implementation and business requirements, while also identifying technical defects in the code itself, standardizing development practices, and ensuring the development quality and iteration efficiency of software products.

[0003] In traditional solutions, code reviews rely on Git (Global Information Tracker) code repositories. Reviewers only examine the code submitted by developers, manually checking and verifying line by line to determine the code's writing style and the rationality of its technical implementation.

[0004] Traditional code reviews focus solely on the technical aspects of the code itself. Reviewers cannot identify the development background and design intent behind any line of code, making it difficult to determine the necessity and rationality of the code implementation from its root, thus affecting the accuracy of the code review. Summary of the Invention

[0005] Therefore, it is necessary to provide a code review method, apparatus, computer equipment, and storage medium that can improve the efficiency of code review and refine the granularity of review, in order to address the above-mentioned technical problems.

[0006] Firstly, this application provides a code review method, including: In response to a review request for the current line of code, extract the contextual feature data for the current line of code; Get the code commit record corresponding to the current line of code, and get the code branch information to which the current line of code belongs based on the code commit record; Obtain the functional requirements information corresponding to the current line of code based on the code branch information; Contextual feature data, historical code commit records, and functional requirement information are input into a pre-trained code review model to obtain the review result corresponding to the current line of code.

[0007] In one embodiment, the context feature data includes the inline marker sequence of the current line of code, the abstract syntax tree subtree corresponding to the function to which the current line of code belongs, and the call chain of the file to which the current line of code belongs.

[0008] In one embodiment, the code review method further includes: Get the test case data corresponding to the current line of code; Contextual feature data, requirement information, and historical code commit records are input into a pre-trained code review model to obtain the review result corresponding to the current line of code, including: Input contextual feature data, requirement information, historical code commit records, and test case data into the code review model to obtain the review result corresponding to the current line of code.

[0009] In one embodiment, retrieving the code commit record corresponding to the current line of code includes: Retrieve the code commit record corresponding to the current line of code from the code version control system based on the identifier information of the current line of code.

[0010] In one embodiment, the functional requirement information corresponding to the current line of code is obtained based on the code branch information, including: Based on the code branch information and the pre-created mapping relationship, obtain the functional requirement information corresponding to the current code line. The mapping relationship includes the correspondence between the functional requirement information of each baseline and the code branch information.

[0011] In one embodiment, the code review method further includes: When the functional requirement information that does not exist in the mapping relationship does not match the code branch information, code fragment extraction is performed on the current code line; The extracted code snippet is input into a pre-trained recognition model to identify a summary of the code function of the current line of code. Calculate the similarity between the code function summary and the requirement description information in the pre-configured requirement library; The functional requirement information corresponding to the current line of code is determined based on the similarity calculation results.

[0012] In one embodiment, the code review method further includes: Configure a jump link for the functional requirements information of the current line of code. The target page of the jump link is the code change page in the third-party code management system that matches the functional requirements information. The functional requirement information with the jump link is returned to the corresponding terminal so that the terminal can respond to the click command of the functional requirement information, jump to the code change page through the jump link, and display the code commit record of the current line of code on the code change page.

[0013] Secondly, this application provides a code review apparatus, comprising: The extraction module is used to extract the contextual feature data of the current line of code in response to the review request of the current line of code; The first acquisition module is used to obtain the code commit record corresponding to the current code line, and obtain the code branch information to which the current code line belongs based on the code commit record; The second acquisition module is used to obtain the functional requirement information corresponding to the current line of code based on the code branch information; The review module is used to input context feature data, historical code commit records, and functional requirement information into a pre-trained code review model to obtain the review result corresponding to the current line of code.

[0014] Thirdly, this application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the code review method provided in any embodiment of the first aspect of this application.

[0015] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the code review method provided in any embodiment of the first aspect of this application.

[0016] The aforementioned code review method, apparatus, computer equipment, and storage medium, by analyzing the correlation between the current line of code and code commit records, code branch information, and functional requirement information, can accurately obtain the code commit records and functional requirement information corresponding to the current line of code. Compared to traditional technologies where it is necessary to manually query across platforms to determine which requirement a line of code originates from, this application is more efficient in obtaining functional requirement information. Furthermore, this application can obtain the contextual feature data of the current line of code, the code commit records associated with the current line of code, and the functional requirement information. By using a code review model to fuse and analyze multiple dimensions of data for the current line of code, the accuracy of the review is improved. Moreover, it enables review of each line of code, refining the granularity of code review and solving the problem of insufficient granularity in traditional technologies. Attached Figure Description

[0017] Figure 1 This is a flowchart illustrating the code review method in some embodiments; Figure 2 This is a schematic diagram illustrating the method flow for displaying code review results in some embodiments; Figure 3 This is a schematic diagram of the display page for the functional requirements information corresponding to the current line of code in some embodiments; Figure 4 Here are some block diagrams of the code review apparatus in some embodiments; Figure 5 This is a diagram showing the internal structure of a computer device in some embodiments. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0019] In the first aspect, this application provides a code review method, such as Figure 1 As shown, the method is applied to a server as an example, and includes the following steps: Step S11: In response to the review request of the current line of code, extract the context feature data of the current line of code.

[0020] Among them, context feature data refers to the set of syntactic and logical association features of the current line of code in the code file.

[0021] Specifically, this application can listen to code line click events in the code editing or review interface, obtain the identifier information of the currently selected code line, such as the line number, and extract it. Based on the obtained line number, a code segment of a preset number of lines above and below the current code line is extracted as the basic context. The syntax tree of the code segment is parsed, and features such as the function it belongs to, the external method it calls, and the code statement type are extracted to form the context feature data of the current code line.

[0022] Step S12: Obtain the code commit record corresponding to the current line of code, and obtain the code branch information to which the current line of code belongs based on the code commit record.

[0023] Code commit records refer to the information retained in the code repository for a single commit operation of a code file. This information includes the commit ID, committer, commit time, commit comments, the code changes made in this commit, the modified line number, the associated version number, and other information that records the code change process.

[0024] Code branch information refers to the unique identifier and attribute information of the Git code branch to which the current line of code belongs, including branch name, branch creation time, branch type, branch origin, and the development task identifier associated with the branch.

[0025] Specifically, this application can obtain the file path and line number of the current line of code, obtain all historical commit IDs of the current line of code based on the obtained file path and line number of the current line of code, and obtain the code commit record corresponding to the current line of code based on all historical commit IDs of the current line of code.

[0026] Furthermore, the associated branch identifier or branch name is extracted from the code commit history to obtain the code branch information. This code branch information can be either the branch identifier or the branch name of the current branch.

[0027] Step S13: Obtain the functional requirement information corresponding to the current line of code based on the code branch information.

[0028] Among them, functional requirement information refers to the requirement description information corresponding to the business function implemented in the current line of code, including the unique identifier of the requirement, the name of the requirement, the description of the core function of the requirement, the creation time of the requirement, the change time of the requirement, the access testing time of the requirement, and the launch time of the requirement.

[0029] Specifically, this application can obtain the functional requirement information corresponding to the current line of code by obtaining the functional requirement information pre-bound to the code branch information.

[0030] Step S14: Input the context feature data, historical code submission records, and functional requirement information into the pre-trained code review model to obtain the review result corresponding to the current line of code.

[0031] Among them, the code review model refers to an intelligent code review model built on the Large Language Model (LLM). It integrates capabilities such as code syntax parsing, natural language semantic understanding, code change sequence analysis, and test case verification. Through preset multi-layer fusion rules and dynamic weighting mechanisms, it intelligently analyzes the rationality, compliance, and matching of code lines with requirements, and outputs graded review results and optimization suggestions.

[0032] The code review model first extracts and integrates features from contextual data to explore the syntactic compliance, logical rationality, and execution relevance of the current line of code, its associated function, and file. Then, it combines historical code submission records to match review standards, problem cases, and optimization solutions for similar code, constructing a reference benchmark for code quality. Finally, it performs semantic alignment and matching verification between the above feature information and functional requirement information, making a comprehensive judgment and analysis from dimensions such as syntactic correctness and requirement compliance, and ultimately generating the review result.

[0033] Specifically, the review results can include the line numbers of the start and end lines of the problematic code, the priority level marked with numbers and words, and a detailed description of the problem type, specific manifestations, error examples, and optimization suggestions. This can accurately locate the problem, clarify the degree of impact, and help developers quickly locate and resolve code defects.

[0034] In one embodiment, the context feature data includes the inline marker sequence of the current line of code, the abstract syntax tree subtree corresponding to the function to which the current line of code belongs, and the call chain of the file to which the current line of code belongs.

[0035] Among them, the inline token sequence of the current code line is an ordered set of tokens formed by extracting a preset number of lexical units forward and backward from the current code line. It includes keywords, identifiers, operators, literals, etc., and is the basic lexical representation of the current code line and its surrounding context.

[0036] The inline tag sequence of the current line of code can provide the nearest lexical context of the current line of code, quickly verify the compliance and formatting of single-line grammar, explore the semantic relationships of the line level and surrounding code, and provide a basis for judging syntax errors, formatting problems, and neighboring logical connection problems.

[0037] The abstract syntax tree subtree corresponding to the function to which the current line of code belongs is a local structure of the abstract syntax tree with the function to which the current line of code belongs as the root node. It represents the function-level semantic information such as the syntax level, statement logic, variable and method call relationships.

[0038] The abstract syntax tree subtree corresponding to the function to which the current line of code belongs can parse the code's logical structure from the function's semantic level.

[0039] The call chain of the file to which the current line of code belongs is a hierarchical relationship between various functions, methods, and modules in the current code file, reflecting the execution flow, dependencies, and overall logical architecture of the code within the file.

[0040] The call chain of the file to which the current line of code belongs can show the file-level dependencies of the code, providing a basis for judging the logical consistency of calls within the file and the rationality of the connection between upstream and downstream modules.

[0041] In one embodiment, the code review method may further include: obtaining test case data corresponding to the current line of code, inputting context feature data, requirement information and historical code submission records into a pre-trained code review model, and obtaining the review result corresponding to the current line of code, including: inputting context feature data, requirement information, historical code submission records and test case data into the code review model to obtain the review result corresponding to the current line of code.

[0042] The test case data consists of test-related data that matches the functional module and business logic to which the current line of code belongs. It includes information such as test input parameters, expected execution results, test execution process, boundary test conditions, and test coverage for that line of code.

[0043] Specifically, the code review model first performs hierarchical feature extraction on the contextual feature data, mining the code's syntax compliance, logical coherence, and architectural rationality at the line level, function level, and file level respectively; then, it combines historical code submission records and matches them with review standards for similar code to form a historical reference for code quality.

[0044] Furthermore, the requirements information is used as the core basis for verification to align the code semantics with business requirements, determine whether the requirements are met, and finally incorporate test case data to verify from a practical testing perspective whether the code's response to test inputs meets expectations and whether there are any logical vulnerabilities or functional defects at the practical testing level. The model integrates and performs multi-dimensional cross-validation on the characteristics of the above four types of data, ultimately generating the current line-of-code review result.

[0045] Specifically, this application can convert functional requirement information into a summary of expected functions and inject it into the code review model, allowing the code review model to judge the consistency between the technical implementation of the current line of code and the intended requirements based on the summary of expected functions.

[0046] Furthermore, the code review model can count the number of modifications to the current line of code from the code commit history. If the number of modifications is greater than a preset number, it is marked as a high-frequency change line, and the review weight of the current line of code is increased, prompting the model to focus on the rationality of the design.

[0047] Furthermore, the code review model can assign fusion weights to four data dimensions—functional requirement information, contextual feature data, test case data, and code submission records—according to the weight ratios corresponding to different scenarios. Based on the fusion weights and the review results corresponding to each data dimension, the final review result for the current line of code can be obtained.

[0048] For example, in scenario 1: new requirement development, the following weights can be set: functional requirement information (40%), contextual feature data (40%), test case data (20%), and code commit records (0%).

[0049] Scenario 2: Historical code refactoring, with weights set for: functional requirement information (35%), contextual feature data (35%), test case data (20%), and code commit records (10%).

[0050] Scenario 3: Online fault repair, with weights set for: functional requirement information (40%), contextual feature data (30%), test case data (20%), and code commit records (10%).

[0051] In one embodiment, obtaining the code commit record corresponding to the current line of code includes: obtaining the code commit record corresponding to the current line of code from the code version control system based on the identification information of the current line of code.

[0052] Among them, the code version control system can be Git, which is a distributed version control system used to record snapshots of file changes over time and support multi-person collaboration.

[0053] This application can extract the unique identifier information of the current line of code, including the repository address, file path, line number, code hash value, and other core location information. The above identifier information is used as search criteria and sent to the Git system's search interface. The Git system matches the associated code commit records in the repository according to the search criteria and extracts the full commit information, including the committer, commit time, commit notes, code changes, associated branches, etc., to obtain the code commit record corresponding to the current line of code.

[0054] The beneficial effects of this embodiment are: to achieve a precise association between lines of code and commit records, allowing the model to trace the background, design intent, and historical issues of the current line of code modification, providing traceable historical evidence for review conclusions, and improving the accuracy of review results.

[0055] In one embodiment, obtaining the functional requirement information corresponding to the current line of code based on the code branch information includes: obtaining the functional requirement information corresponding to the current line of code based on the code branch information and a pre-created mapping relationship, wherein the mapping relationship includes the correspondence between the functional requirement information of each baseline and the code branch information.

[0056] Specifically, this application extracts the code commit record associated with the current line of code and parses out the corresponding code branch information from it; it retrieves the mapping relationship pre-created in the internal third-party code management system. This mapping relationship is based on the branch binding operation when creating a requirement in the third-party code management system, and establishes a three-way correspondence between the unique ID of the functional requirement, the functional requirement information and the code branch information. Moreover, this correspondence has been synchronized to the database to achieve accurate matching between code commit records and requirement IDs.

[0057] Furthermore, using the parsed code branch information as search keywords, a matching process is performed within the above mapping relationship: first, the unique ID of the corresponding functional requirement is matched, and then the complete functional requirement information corresponding to the current line of code is retrieved through the requirement ID association.

[0058] The beneficial effect of this embodiment is that, based on the binding relationship between functional requirements and code branch information created in the internal third-party code management system and the correspondence between code branch information and code commit records in Git, a precise association link between code commit records and functional requirement information is constructed, avoiding errors from manual matching and ensuring the accuracy of functional requirement information acquisition.

[0059] In one embodiment, the code review method may further include: when there is no functional requirement information matching the code branch information in the mapping relationship, extracting code fragments from the current code line, inputting the extracted code fragments into a pre-trained recognition model to identify the code function summary of the current code line, calculating the similarity between the code function summary and the requirement description information in the pre-configured requirement library, and determining the functional requirement information corresponding to the current code line based on the result of the similarity calculation.

[0060] The recognition model is a deep learning model pre-trained on a large number of samples labeled with the correspondence between code snippets and functional summaries, and it has the ability to extract core business logic from code text.

[0061] The code function summary is a distillation of the core functions and business logic of the current line of code and related code segments.

[0062] The requirements repository is a pre-built, standardized repository of functional requirements. It contains all the functional requirements information for the project. Each requirement is associated with a unique identifier, detailed requirement description, business scenario, implementation requirements, and other structured data, serving as the benchmark data source for code requirement matching.

[0063] The requirement description information is the natural language description content corresponding to each functional requirement in the requirement library.

[0064] Specifically, this application can detect pre-created mapping relationships. If no functional requirement information matching the code branch information of the current code line is found, the acquisition process is triggered. Specifically, based on the context features of the current code line, this application extracts valid code segments containing the current code line, associated execution logic, and core call statements. The extracted valid code segments are input into a pre-trained recognition model, which performs code semantic parsing, core function extraction, and natural language conversion to generate a code function summary corresponding to the current code line. A pre-configured requirement library is retrieved, and requirement description information of all requirements in the library is extracted. The code function summary and each requirement description are compared using text semantic similarity calculation algorithms, such as vector similarity or cosine similarity. Based on the similarity calculation results, the functional requirement information corresponding to the requirement description with the highest similarity is selected as the functional requirement information matched to the current code line.

[0065] The beneficial effects of this embodiment are as follows: it constructs a fallback requirement matching mechanism, which solves the problem that requirement information cannot be obtained when there is no matching branch information in the mapping relationship, breaks the single association limitation of code branch and requirement binding, realizes full-scenario coverage of functional requirement information acquisition, and ensures the continuity and integrity of the code review process.

[0066] In one embodiment, when two requirements are mapped to the same line of code, that is, when multiple functional requirements match the same line of code, the functional requirement information corresponding to the last modified code is returned by default.

[0067] In one embodiment, the code review method may further include: configuring a jump link for the functional requirement information of the current line of code, wherein the target page of the jump link is a code change page in a third-party code management system that matches the functional requirement information; returning the functional requirement information configured with the jump link to the corresponding terminal, so that the terminal responds to the click instruction on the functional requirement information, jumps to the code change page through the jump link, and displays the code submission record of the current line of code on the code change page.

[0068] The jump link is a network access address configured for the functional requirements information. It is uniquely bound to the code change page of the third-party code management system. After the click operation is triggered, a targeted page jump can be achieved from the functional requirements information display end to the target code change page.

[0069] The code change page is a visualization page in third-party code management systems specifically designed to display the code submission records corresponding to functional requirements. It supports filtering and viewing code submission records based on requirements and includes a detailed jump entry to the code version control system.

[0070] A third-party code management system is a code management platform independent of the code review terminal, featuring functions such as code change record management, association between requirements and code submission records, and cross-platform page navigation configuration. Specifically, a third-party code management system could be the Bone platform, which is an integrated collaboration platform for internal R&D, testing, and operations, providing requirements management, code change tracking, and intelligent review linkage functions.

[0071] Specifically, this application can configure a redirect link for the functional requirement information corresponding to the current line of code, linking it to the code change page of a third-party code management system, and simultaneously associating it with the target page after the redirect. The functional requirement information carrying the aforementioned redirect link is then pushed to the corresponding terminal and displayed, creating a visual association between the terminal's functional requirement information and the redirect link. When the terminal detects a user's click on the functional requirement information, it automatically triggers the redirect link, redirecting the user to the code change page of the third-party code management system.

[0072] In response to a user's request to view code commit history on the code change page of a third-party code management system, a secondary redirect link is triggered, redirecting the user to the code version control system to retrieve and display the complete code change information and commit details corresponding to the code commit history, thus enabling the user to view the complete code commit history.

[0073] The beneficial effect of this embodiment is that by linking functional requirement information with specific code commit records through jump links, the tracing of the background of requirements and the verification of code changes during the code review process become more intuitive.

[0074] On the other hand, this application also provides a method for displaying code review results, such as... Figure 2 As shown, taking the application of this method to a terminal as an example, the steps include: Step S21: In response to the click instruction of the current line of code, submit a review request for the current line of code to the server.

[0075] Step S22: The server extracts the context feature data of the current code line, obtains the code commit record corresponding to the current code line, obtains the code branch information to which the current code line belongs based on the code commit record, obtains the functional requirement information corresponding to the current code line based on the code branch information, inputs the context feature data, historical code commit records and functional requirement information into the pre-trained code review model, and then feeds back the review result corresponding to the current code line.

[0076] Step S23: Present the review results.

[0077] Specifically, the specific implementation methods of each step S21-S23 can be referred to the specific methods of the various embodiments in the first aspect, and will not be repeated here.

[0078] In one embodiment, the method for displaying code review results further includes: responding to a command to view functional requirement information of the current line of code, submitting a request to the server to obtain functional requirement information, receiving the functional requirement information corresponding to the current line of code returned by the server, and displaying the functional requirement information.

[0079] Please refer to Figure 3 , Figure 3 This is a schematic diagram of a page displaying functional requirements information in one embodiment. Figure 3 As shown, functional requirement information can be displayed in the form of cards. Specifically, when the cursor is positioned on any line of code, a requirement card pops up, displaying the functional requirement information corresponding to the current line. This can include the requirement title, the status of each subtask within the requirement, and so on. Figure 3 The system displays completed and planned completion dates, and can also show the creation time, modification time, integration testing time, and deployment time of the requirement. Figure 3 The title of the requirement is “Special Test Dedicated - Automatic Progress Generation for One Side”. Clicking on the requirement title will take you to a third-party code management system to display the code commit records corresponding to the functional requirement information. Clicking further will take you to the code version control system to display the details of the code commit records.

[0080] In one embodiment, the method for displaying code review results further includes: responding to a click instruction on functional requirement information, redirecting to a code change page in a third-party code management system according to a redirection link pre-configured by the server for the functional requirement information, and displaying code submission records matching the functional requirement information on the code change page; responding to a viewing instruction on the code submission records on the code change page, redirecting to a display page showing details of the code submission records in the code version control system according to a redirection link pre-configured by the server for the code submission records.

[0081] Secondly, this application provides a code review apparatus, such as... Figure 4 As shown, the code review device includes: an extraction module 41, a first acquisition module 42, a second acquisition module 43, and a review module 44, wherein: Extraction module 41 is used to extract the context feature data of the current line of code in response to the review request of the current line of code; The first acquisition module 42 is used to acquire the code commit record corresponding to the current code line, and to acquire the code branch information to which the current code line belongs based on the code commit record; The second acquisition module 43 is used to obtain the functional requirement information corresponding to the current line of code based on the code branch information; The review module 44 is used to input context feature data, historical code commit records, and functional requirement information into a pre-trained code review model to obtain the review result corresponding to the current line of code.

[0082] In one embodiment, the context feature data includes the inline marker sequence of the current line of code, the abstract syntax tree subtree corresponding to the function to which the current line of code belongs, and the call chain of the file to which the current line of code belongs.

[0083] In one embodiment, the review module 44 can also obtain the test case data corresponding to the current line of code, input the context feature data, requirement information, historical code submission records and test case data into the code review model, and obtain the review result corresponding to the current line of code.

[0084] In one embodiment, the first acquisition module 42 can obtain the code commit record corresponding to the current code line from the code version control system based on the identification information of the current code line.

[0085] In one embodiment, the second acquisition module 43 can acquire the functional requirement information corresponding to the current line of code based on the code branch information and the pre-created mapping relationship. The mapping relationship includes the correspondence between the functional requirement information of each benchmark and the code branch information.

[0086] In one embodiment, the second acquisition module 43 can also extract code fragments from the current code line when the functional requirement information that does not exist in the mapping relationship does not exist in the code branch information matching, input the extracted code fragments into the pre-trained recognition model, identify the code function summary of the current code line, calculate the similarity between the code function summary and the requirement description information in the pre-configured requirement library, and determine the functional requirement information corresponding to the current code line based on the result of the similarity calculation.

[0087] In one embodiment, the review module 44 can also configure a jump link for the functional requirement information of the current line of code. The target page of the jump link is the code change page in the third-party code management system that matches the functional requirement information. The functional requirement information configured with the jump link is returned to the corresponding terminal so that the terminal responds to the click instruction on the functional requirement information, jumps to the code change page through the jump link, and displays the code submission record of the current line of code on the code change page.

[0088] Thirdly, this application 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 computer program, it implements the steps of the code review method provided in any embodiment of the first aspect of this application.

[0089] In one embodiment, the computer device may be a server, and its internal structure diagram may be as follows: Figure 5 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a code review method.

[0090] In a fourth aspect, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the code review method provided in any embodiment of the first aspect of this application.

[0091] The computer-readable storage medium may be Figure 5 The computer-readable storage medium in the computer device shown.

[0092] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0093] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0094] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A code review method, characterized in that, The method includes: In response to a review request for the current line of code, extract the contextual feature data of the current line of code; Obtain the code commit record corresponding to the current line of code, and obtain the code branch information to which the current line of code belongs based on the code commit record; Obtain the functional requirement information corresponding to the current line of code based on the code branch information; The context feature data, the historical code submission records, and the functional requirement information are input into a pre-trained code review model to obtain the review result corresponding to the current line of code.

2. The method according to claim 1, characterized in that, The context feature data includes the inline marker sequence of the current line of code, the abstract syntax tree subtree corresponding to the function to which the current line of code belongs, and the call chain of the file to which the current line of code belongs.

3. The method according to claim 1, characterized in that, The method further includes: Obtain the test case data corresponding to the current line of code; The step of inputting the context feature data, the requirement information, and the historical code submission records into a pre-trained code review model to obtain the review result corresponding to the current line of code includes: The context feature data, the requirement information, the historical code submission records, and the test case data are input into the code review model to obtain the review result corresponding to the current line of code.

4. The method according to claim 1, characterized in that, The step of obtaining the code commit record corresponding to the current line of code includes: Based on the identifier information of the current line of code, retrieve the code commit record corresponding to the current line of code from the code version control system.

5. The method according to claim 1, characterized in that, The step of obtaining the functional requirement information corresponding to the current line of code based on the code branch information includes: The functional requirement information corresponding to the current line of code is obtained based on the code branch information and the pre-created mapping relationship. The mapping relationship includes the correspondence between the functional requirement information of each benchmark and the code branch information.

6. The method according to claim 1, characterized in that, The method further includes: When the functional requirement information that does not exist in the mapping relationship does not match the code branch information, code fragment extraction is performed on the current code line; The extracted code snippet is input into a pre-trained recognition model to identify the code function summary of the current line of code; The similarity between the code function summary and the requirement description information in the pre-configured requirement library is calculated. The functional requirement information corresponding to the current line of code is determined based on the result of the similarity calculation.

7. The method according to claim 1, characterized in that, The method further includes: Configure a jump link for the functional requirement information of the current line of code, wherein the target page of the jump link is the code change page in the third-party code management system that matches the functional requirement information; The functional requirement information configured with the jump link is returned to the corresponding terminal, so that the terminal responds to the click instruction of the functional requirement information, jumps to the code change page through the jump link, and displays the code commit record of the current line of code on the code change page.

8. A code review device, characterized in that, The device includes: The extraction module is used to extract the context feature data of the current line of code in response to the review request of the current line of code; The first acquisition module is used to acquire the code commit record corresponding to the current code line, and to acquire the code branch information to which the current code line belongs based on the code commit record; The second acquisition module is used to acquire the functional requirement information corresponding to the current line of code based on the code branch information; The review module is used to input the context feature data, the historical code submission records, and the functional requirement information into a pre-trained code review model to obtain the review result corresponding to the current line of code.

9. 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 computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.