A code review method and related apparatus
By constructing semantically enhanced contexts and multi-level filtering mechanisms, the problems of high false positive rates and high resource consumption in code review by large language models are solved, achieving efficient and accurate code review and optimizing the use of computing resources.
Patent Information
- Application Number
- CN202611337093.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-17
AI Technical Summary
Existing automated code review solutions based on large language models suffer from high false positive rates and high computational resource consumption, making it difficult to balance the requirements of high recall, high accuracy, and low cost in enterprise-level large-scale review scenarios.
By constructing a semantically enhanced context, the abstract syntax tree is used to accurately locate the structured semantics of code changes. Combined with a primary review model, inter-level convergence processing, and a discrimination model, multi-level screening and deep verification are performed to eliminate invalid candidate issues and optimize the use of computing resources.
It significantly reduced the false positive rate, compressed inference time and computing power costs, achieved high recall and high accuracy code review, and optimized the efficiency of computing resource utilization.
Smart Images

Figure CN123114541A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of artificial intelligence and software engineering, and in particular to a code review method and related apparatus. Background Technology
[0002] As software systems become more complex, code review has become a crucial step in ensuring software quality.
[0003] Currently, automated code review solutions based on large language models are gradually being adopted. However, existing technologies typically input code change fragments directly into a single model for review, lacking the construction of a complete semantic context for the code. This leads to a large number of false positives due to missing information. At the same time, simply chaining multiple heavyweight models together to reduce false positives introduces high inference latency and computational costs, making it difficult to balance the requirements of high recall, high accuracy, and low cost in enterprise-level large-scale review scenarios.
[0004] In summary, existing automated code review schemes based on large language models suffer from high false positive rates and high computational resource consumption. Summary of the Invention
[0005] In view of the above problems, this application provides a code review method and related apparatus to improve review accuracy and optimize computational costs. The specific solution is as follows:
[0006] The first aspect of this application provides a code review method, including:
[0007] Obtain code change data and construct a semantically enhanced context based on the abstract syntax tree corresponding to the code change data;
[0008] A preliminary review model is used to perform a preliminary review of the semantically enhanced context to generate candidate questions.
[0009] Inter-level convergence processing is performed on candidate issues. This process includes calibrating the defect level of candidate issues based on preset rules and performing source code consistency verification on the code snippets contained in the candidate issues.
[0010] The candidate problems that have passed the inter-level convergence process are classified by the discriminant model to select the target candidate problems.
[0011] The target candidate problem is deeply validated by a deep validation model, and code review results are generated.
[0012] In one possible implementation, the defect level of candidate problems is calibrated based on preset rules, including:
[0013] Identify the defect labels associated with candidate issues, and correct the defect level corresponding to the defect label to the target level based on the preset label mapping relationship;
[0014] Perform source code consistency checks on the code snippets included in the candidate issues, including:
[0015] The code snippet is compared with the source code corresponding to the code change data. If the code snippet does not exist in the source code, the corresponding candidate issue is marked as invalid and blocked from entering deep verification.
[0016] In one possible implementation, the code snippet is compared with the source code corresponding to the code change data, including:
[0017] Perform character filtering on the code snippet and source code respectively, removing at least one of the tab character, newline character, carriage return character, and space character;
[0018] Based on the character-filtered code snippet and source code, perform precise string inclusion matching;
[0019] If the matching result is "not included", then the code snippet is determined not to exist in the source code.
[0020] In one possible implementation, a semantically enhanced context is constructed based on the abstract syntax tree corresponding to the code change data, including:
[0021] Parse the code file corresponding to the code change data and construct an abstract syntax tree;
[0022] Based on the abstract syntax tree, extract the function definition boundaries where code change data is located;
[0023] Analyze the identifier reference relationships within the function definition boundaries and extract the associated dependency definitions;
[0024] By combining function definition boundaries and dependency definitions, a semantically enhanced context is generated.
[0025] In one possible implementation, the method also includes:
[0026] Determine the text size of the semantically enhanced context;
[0027] Based on the comparison results between the text size and the preset size threshold, dynamic routing is performed between the locally deployed language model and the cloud-deployed language model to determine whether to perform primary review or deep verification.
[0028] In one possible implementation, a discriminative model is used to classify the candidate problems that have passed the inter-level convergence process, and target candidate problems are selected, including:
[0029] The candidate question is input into the discriminant model, which outputs the validity classification result, including the valid state or the invalid state. The discriminant model is a lightweight model, located between the primary review model and the deep verification model. It is used to classify the validity of candidate questions that have passed the inter-level convergence process with a millisecond-level response speed.
[0030] Candidate questions that are in an invalid state are downgraded to a preset filtered state and blocked from entering deep verification;
[0031] Candidate problems that are in a valid state are used as target candidate problems.
[0032] In one possible implementation, the training process of the discriminative model includes:
[0033] Obtain manual annotation feedback data of historical code review results. The manual annotation feedback data includes confirmed defect data marked as modified and false alarm data marked as invalid.
[0034] The lightweight pedestal model is trained under supervised fine-tuning based on manually annotated feedback data to obtain a discriminative model.
[0035] In one possible implementation, after generating the code review results, the following is also included:
[0036] Calculate the code similarity between the code review results and historically ignored issues. If the code similarity is greater than a preset similarity threshold, perform deduplication filtering on the code review results.
[0037] The code audit result is marked as invalid if any hallucination indicator keywords are detected in the verification text output by the deep verification model.
[0038] A second aspect of this application provides a code review apparatus, comprising:
[0039] The context building module is used to obtain code change data and build a semantically enhanced context based on the abstract syntax tree corresponding to the code change data;
[0040] The primary review module is used to perform a preliminary review of the semantically enhanced context using a primary review model, and generate candidate questions.
[0041] The inter-level convergence module is used to perform inter-level convergence processing on candidate issues. The inter-level convergence processing includes calibrating the defect level of candidate issues based on preset rules, and performing source code consistency verification on the code snippets contained in the candidate issues.
[0042] The intermediate filtering module is used to classify the candidate problems that have passed the inter-level convergence process by a discriminant model and filter out the target candidate problems.
[0043] The deep verification module is used to perform deep verification on target candidate issues through a deep verification model and generate code review results.
[0044] A third aspect of this application provides a code review device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the code review method described in the first aspect or any implementation thereof.
[0045] The fourth aspect of 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 code review method of the first aspect or any implementation thereof.
[0046] By employing the aforementioned technical solutions, the code review method and related apparatus provided in this application construct a semantically enhanced context based on an abstract syntax tree, accurately capturing the structured semantics of code changes and overcoming the comprehension bias caused by the lack of context in large models, thus reducing invalid candidates from the source. Secondly, after the initial review, inter-level convergence processing is introduced: defect levels are calibrated through preset rules to filter out overly sensitive false positives; and illusionary issues that do not match the changed code are eliminated through source code consistency verification, with dual filtering significantly reducing the number of candidate issues. Subsequently, a lightweight discrimination model filters target candidates, avoiding high-cost deep verification of all candidates. Finally, deep verification models are only activated for high-value issues after screening, concentrating computational resources on key defects, significantly reducing inference time and computational cost while ensuring review accuracy, achieving synergistic optimization of false positive rate and resource consumption. Attached Figure Description
[0047] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0048] Figure 1 A flowchart illustrating the code review method provided in this application;
[0049] Figure 2 A system architecture example diagram for implementing the code review method provided in this application;
[0050] Figure 3 A flowchart illustrating the code review process provided for this application;
[0051] Figure 4 A schematic diagram of the structure of the code review device provided in this application. Detailed Implementation
[0052] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0053] As will be known to those skilled in the art, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0054] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0055] In existing technologies, relying solely on large language models to directly parse code change fragments is often limited by the model context window and the limitations of plain text understanding. It is difficult to accurately restore deep logic such as variable scope and function call chain, which can easily lead to illusionary misjudgments.
[0056] Meanwhile, if a strategy of simply stacking multiple large models for serial verification is adopted, although false alarms can be suppressed to a certain extent, it will cause a large number of candidate problems to undergo highly complex inference calculations, resulting in a huge waste of computing power and latency.
[0057] To address the aforementioned issues, this application provides a code review method and related apparatus.
[0058] See Figure 1 This application provides a flowchart illustrating a code review method.
[0059] like Figure 1 As shown, this code review method includes the following steps:
[0060] Step 101: Obtain code change data and construct a semantically enhanced context based on the abstract syntax tree corresponding to the code change data.
[0061] It should be noted that code change data is usually presented in differential Diff format, which only contains newly added, deleted, or modified code line fragments and lacks complete logical structure information.
[0062] To compensate for this semantic gap, this embodiment introduces an Abstract Syntax Tree (AST) as an intermediate representation layer. By parsing the code file, the linear source code is transformed into a tree structure, thereby accurately locating syntax nodes such as function definition boundaries, class structures, and variable declarations where the modified code is located.
[0063] Building upon this foundation, the identifier reference relationships within the function body are further analyzed, and dependency information such as the definition and type declaration of the called external function is automatically extracted. These discrete change fragments are then combined with the complete function body and dependency definitions to generate an enhanced context containing rich semantic information.
[0064] For example, when changing data involves modifying the internal logic of a function, the semantic enhancement context not only contains the complete definition of the function, but also automatically associates it with the utility class methods or interface definitions it calls, enabling subsequent models to understand the complete execution logic of the code, rather than just seeing isolated code snippets.
[0065] This step mainly focuses on context construction based on AST, which solves the problem of logical misjudgment caused by context truncation in traditional solutions from the input end.
[0066] Step 102: Perform a preliminary review of the semantically enhanced context using a preliminary review model to generate candidate questions.
[0067] In this embodiment, the primary review model is configured as a language model with broad coverage, whose main goal is to recall as many potential defects as possible, while allowing a certain false positive rate to ensure a high recall rate.
[0068] Optionally, the primary audit model receives an enhanced context containing complete semantic information, enabling it to more accurately understand code intent and business logic, thereby identifying various types of candidate issues such as null pointer risks, unreleased resources, and logical vulnerabilities.
[0069] Understandably, the primary audit model can be a lightweight model deployed locally or a general-purpose large model in the cloud. The selection strategy can be flexibly adjusted according to actual computing resources and response latency requirements, as long as basic code understanding and defect identification capabilities are available.
[0070] Step 103: Perform inter-level convergence processing on the candidate issues. The inter-level convergence processing includes calibrating the defect level of the candidate issues based on preset rules and performing source code consistency verification on the code segments contained in the candidate issues.
[0071] This is a core step in the application, aimed at establishing a deterministic filter gate between the initial review and subsequent in-depth verification.
[0072] Optionally, since the defect levels output by large language models are often subjective and unstable, this step first uses a preset rule mapping table to forcibly correct the original labels output by the model to a standardized target level. For example, labels involving security vulnerabilities are uniformly calibrated to the severity level, and labels related to code style are calibrated to the warning level, thereby eliminating the drift of the model evaluation criteria.
[0073] More importantly, to address the issue of "illusion"—the creation of non-existent code snippets—that large models are prone to, this step performs rigorous source code consistency checks, comparing the code snippets referenced in candidate questions with the original source code. If the defective code pointed out by the model simply does not exist in the source file, the candidate question is directly deemed invalid and eliminated. This mechanism uses deterministic code matching logic to combat probabilistic model-generated content, preventing a large number of obvious false positives caused by illusions before proceeding to the next level of high-cost verification, significantly reducing the computational load of subsequent stages.
[0074] Step 104: The candidate problems that have passed the inter-level convergence process are classified for effectiveness using a discriminant model, and the target candidate problems are selected.
[0075] Although the remaining candidate issues after inter-level convergence processing have passed the basic verification, they may still contain pseudo-defects that are logically unreasonable or business-acceptable.
[0076] This embodiment introduces a pre-trained lightweight discriminant model as an intermediate filter. This discriminant model is a lightweight model trained under the supervision of manually annotated feedback data. It is deployed in the local inference framework, located between the aforementioned primary review model and deep verification model, and is used to classify the validity of candidate questions that have passed the inter-level convergence process with a millisecond-level response speed.
[0077] Specifically, this discriminative model focuses on binary classification tasks, namely valid and invalid. Compared to general large language models, its inference speed is extremely fast and its computational cost is extremely low. It takes candidate questions and their context as input and quickly determines whether the question is a real defect. For candidate questions judged as invalid, the system marks them in a specific filtering state and blocks them from entering the subsequent deep verification stage; only candidate questions judged as valid are passed to the next level as target candidate questions.
[0078] This design inserts a low-cost sieve between the two heavyweight models in this step, further converging the data flow and avoiding the waste of expensive deep validation resources on obvious false positives.
[0079] Step 105: Perform deep verification of the target candidate problem using a deep verification model to generate code review results.
[0080] It should be noted that deep validation models typically employ language models with a larger number of parameters and stronger reasoning capabilities to make the final, accurate decision on the target candidate questions that have undergone multiple rounds of screening. Since the number of questions to be validated has been significantly reduced at this point, the system can concentrate its computing resources on in-depth logical analysis and evidence chain verification, and even generate specific remediation suggestions.
[0081] Deep verification models not only confirm the existence of defects, but also output detailed analysis processes and confidence scores, ultimately resulting in high-quality code review results.
[0082] In addition, after generating the code review results, the following steps may also be included:
[0083] Post-processing and output of the audit results.
[0084] For example, the results can be deduplicated, formatted for display, or pushed to the development platform.
[0085] In summary, the code review method provided in this application constructs a semantically enhanced context based on an abstract syntax tree, accurately capturing the structured semantics of code changes and overcoming the comprehension bias caused by the lack of context in large models, thus reducing invalid candidates from the source. Secondly, after the initial review, inter-level convergence processing is introduced: defect levels are calibrated through preset rules to filter out overly sensitive false positives; and illusionary issues that do not match the changed code are eliminated through source code consistency verification, significantly reducing the number of candidate issues through dual filtering. Subsequently, a lightweight discrimination model filters target candidates, avoiding high-cost deep verification of all candidates. Finally, deep verification models are only activated for high-value issues after screening, concentrating computational resources on key defects. While ensuring review accuracy, this significantly reduces inference time and computational cost, achieving synergistic optimization of false positive rate and resource consumption.
[0086] Based on the first embodiment described above, this embodiment further details the specific implementation mechanism of inter-stage convergence processing as a second embodiment.
[0087] As one implementation method, the defect level of candidate problems is calibrated based on preset rules, including:
[0088] Identify the defect labels associated with candidate issues, and correct the defect level corresponding to the defect label to the target level based on the preset label mapping relationship.
[0089] Specifically, the defect level output by the primary review model often carries the model's own subjective bias or instability. For example, for the same type of null pointer risk, the model may give different severity ratings in different calls.
[0090] To standardize evaluation criteria and ensure consistency in subsequent processes, this embodiment pre-constructs a label mapping table, which defines the mandatory correspondence between various defect labels and standardized target levels.
[0091] For example, when a candidate issue is identified as being associated with high-risk tags such as security vulnerabilities or SQL injection, the system will forcibly correct it to the highest severity level, regardless of the original output level of the primary review model; while when a code style tag such as non-standard naming or missing comments is identified, it will be forcibly corrected to the lowest warning level.
[0092] This hard-correction method based on deterministic rules eliminates the random drift of large language models in terms of grading, ensuring the interpretability and consistency of the review results at the business level.
[0093] As another core step in the inter-level convergence process, source code consistency checks are performed on the code snippets contained in the candidate problem, including:
[0094] The code snippet is compared with the source code corresponding to the code change data. If the code snippet does not exist in the source code, the corresponding candidate issue is marked as invalid and blocked from entering deep verification.
[0095] This step is a key defense against the phenomenon of large language model illusion.
[0096] In practical applications, models may fabricate seemingly plausible code snippets that have never appeared in the source files as evidence of defects. If such false evidence is not intercepted, subsequent deep validation models will waste a lot of computing power analyzing a problem that does not exist at all, and may even produce a chain of misjudgments due to the model's associative abilities.
[0097] Therefore, this embodiment sets up this physical-level verification gate before entering the next level of review. Only when the code snippet referenced by the candidate issue is confirmed to actually exist in the original source code is it allowed to continue circulating; otherwise, it is directly marked as invalid and the life cycle of the candidate issue is terminated, thereby cutting off the path of illusion propagation from the source.
[0098] To achieve high accuracy in the aforementioned source code consistency verification, this application also provides a specific comparison algorithm.
[0099] As one implementation method, the code snippet is compared with the source code corresponding to the code change data, including:
[0100] Perform character filtering on the code snippet and source code respectively, removing at least one of the tab, newline, carriage return, and space characters; perform exact string inclusion matching based on the character-filtered code snippet and source code; if the matching result is no inclusion, it is determined that the code snippet does not exist in the source code.
[0101] Specifically, because the code snippets generated by the large language model often have subtle differences from the original source code in terms of indentation, line breaks, number of spaces, etc., if the original text is directly compared, it is very easy to misjudge that they do not exist due to the inconsistency in format, thus incorrectly filtering out real defect reports.
[0102] Therefore, this embodiment first performs standardized character filtering on both texts, removing all non-semantic whitespace control characters and retaining only code content with actual syntactic meaning. Based on this, precise string inclusion matching is then performed, that is, determining whether the filtered code fragment appears as a complete substring in the filtered source code.
[0103] Understandably, the exact string inclusion match here refers to strict character-level matching, rather than semantic similarity matching, which ensures the absolute certainty of the verification result.
[0104] This processing logic of standardization followed by precise matching effectively avoids false filtering caused by format noise, significantly improving the robustness and reliability of inter-level convergence processing.
[0105] Based on the first embodiment, this embodiment further details the construction process of the semantic enhancement context and the dynamic routing mechanism of the model based on the context, as the third embodiment.
[0106] As one implementation method, a semantically enhanced context is constructed based on the abstract syntax tree corresponding to the code change data, including:
[0107] The code file corresponding to the code change data is parsed to construct an abstract syntax tree; based on the abstract syntax tree, the function definition boundary where the code change data is located is extracted; the identifier reference relationship within the function definition boundary is parsed to extract the associated dependency definition; the function definition boundary and dependency definition are combined to generate a semantically enhanced context.
[0108] Specifically, code change data is usually presented only as differential representations of the modified lines of code, lacking complete logical structure information. Directly inputting it into the model can easily lead to misjudgments due to missing context.
[0109] To this end, this embodiment first uses a syntax parsing engine to parse the complete code file containing the changes, constructing an abstract syntax tree that reflects the code's syntactic structure. This abstract syntax tree transforms the linear source code into a hierarchical node structure, enabling the system to accurately locate the function definition node to which the changed code line belongs, thereby extracting the complete function body as the underlying context.
[0110] Based on this, the system further traverses the identifier reference relationships inside the function definition node, identifies dependencies such as external methods called within the function body, referenced type definitions, or global variables, and extracts the specific definition content of these dependencies from the abstract syntax tree or symbol table.
[0111] For example, when code changes involve the internal logic of a data processing function, the system will not only extract the complete implementation of the function, but also automatically associate it with the definition of the data validation utility class or entity class it calls, combining these discrete pieces of information into a semantically coherent enhanced context.
[0112] This approach enables subsequent audit models to understand the complete execution logic and dependent environment of the code, fundamentally solving the semantic gap problem caused by traditional solutions relying only on fragmented change information, and significantly improving the accuracy of defect identification.
[0113] After constructing a high-quality semantically enhanced context, in order to optimize computational resource consumption while ensuring the accuracy of the review, this application also introduces an intelligent scheduling strategy based on context size.
[0114] As one implementation method, the text size of the semantic enhancement context is determined; based on the comparison result of the text size and the preset size threshold, dynamic routing is performed between the locally deployed language model and the cloud-deployed language model to determine the primary review model for primary review or the deep verification model for deep verification.
[0115] Specifically, after generating the semantically enhanced context, the system will calculate its text size in real time. This size can be determined by counting the number of characters, the number of tokens, or estimating memory usage.
[0116] The system then compares the calculated text size with a preset size threshold. When the text size is less than or equal to the preset size threshold, it indicates that the semantic complexity of the current task is low, and the locally deployed language model is sufficient, with faster response and lower cost. Therefore, the system routes the review task to the local model for execution. Conversely, when the text size exceeds the preset size threshold, it indicates that the task involves complex long-context reasoning and requires stronger comprehension capabilities. In this case, the system automatically switches the task to a cloud-deployed high-parameter language model for processing.
[0117] Understandably, this dynamic routing mechanism is not a simple load balancing or round-robin strategy, but rather an adaptive selection based on the semantic complexity of the task itself. It ensures that simple tasks can quickly close the loop locally, avoiding unnecessary network latency and API costs, while complex tasks can obtain sufficient computing power to guarantee the quality of the review, thus achieving an optimal balance between review accuracy, response speed, and economic cost.
[0118] Furthermore, this routing strategy is not only applicable to the initial review stage, but also to the deep verification stage. It can flexibly allocate verification resources according to the context and scale of the issue to be verified, thereby further improving the overall system efficiency.
[0119] Based on the first embodiment described above, this embodiment further details the specific implementation mechanism of intermediate filtering and state degradation through the discriminative model, as the fourth embodiment.
[0120] As one implementation method, a discriminant model is used to classify the candidate problems that have passed the inter-level convergence process and select target candidate problems, including:
[0121] The candidate questions are input into the discriminant model, which outputs validity classification results, including valid or invalid states. This discriminant model is a lightweight model, located between the primary review model and the deep verification model, and is used to classify the validity of candidate questions that have passed the inter-level convergence process with a millisecond-level response speed. Candidate questions in the invalid state are downgraded to a preset filtering state and blocked from entering deep verification. Candidate questions in the valid state are used as target candidate questions.
[0122] Specifically, the discrimination model in this embodiment is a pre-trained lightweight language model that has been optimized for validity discrimination tasks in code review scenarios.
[0123] Unlike the inter-level convergence processing based on fixed rules in the second embodiment, this discriminant model has semantic understanding capabilities and can identify pseudo-problems that, although the code snippets are real and the levels conform to the specifications, do not constitute defects in business logic.
[0124] For example, some code practices may not conform to best practices but are necessary in a specific context, or certain potential risks may have been covered by external mechanisms and do not require fixing. For these types of problems, deterministic rule validation cannot effectively eliminate them, while heavyweight deep validation models would waste computational resources. Therefore, this embodiment introduces this discriminative model as a low-cost intelligent gate located between two large-scale models.
[0125] In practice, the system concatenates the candidate questions and their associated contexts, after inter-level convergence processing, into a specific formatted input sequence, which is then fed into the discriminative model for inference. The discriminative model outputs a binary classification result for validity, which can be a clear valid or invalid label, or a confidence score representing the probability of validity. When the confidence score is below a preset threshold or an invalid label is directly output, the system determines that the candidate question is invalid.
[0126] For candidate issues deemed invalid, the system does not simply delete them, but downgrades them to a preset filter status. This preset filter status is a special data marker used to explicitly indicate in the data stream that the issue has been intercepted by the intermediate layer. For example, the severity level field of such issues can be forcibly modified to a specific filter level, such as level E, and the stage and reason for its interception can be recorded in the database.
[0127] More importantly, the system will perform a physical blocking operation at the data flow level, that is, it will no longer add the candidate question to the waiting queue of the deep verification model.
[0128] This blocking method ensures that the deep validation model, which has a larger number of backend parameters and higher inference costs, only receives high-value candidate questions that have been screened through multiple layers, thereby avoiding the waste of expensive computing resources in processing obvious false positives or low-value questions.
[0129] It is understandable that the blocking here refers to cutting off the data transmission path to the next processing node in the program logic, rather than simply hiding it on the interface.
[0130] For candidate problems that are determined to be valid, the system confirms them as target candidate problems, maintains their original level or makes fine adjustments based on the output of the discriminant model, and then passes them to the deep verification stage for final accurate decision.
[0131] Because the discriminative models typically employ a relatively small parameter scale, such as less than one billion parameters, and are deployed on a local high-performance inference framework, their single inference time can be controlled in the millisecond range, far lower than the second-level response time of large cloud-based models. This means that even when faced with a massive number of initial review candidate questions, this intermediate filtering step will not become a system bottleneck. On the contrary, by eliminating a large number of invalid items in advance, it significantly shortens the average latency of the overall review process.
[0132] Through the dual guarantee of deterministic rule convergence and learning-based probabilistic filtering, this application achieves an ultimate balance between review accuracy and computational cost while ensuring high recall rate, solving the technical problem that multi-model cascade solutions in the prior art are costly and difficult to implement.
[0133] Based on the first embodiment, this embodiment further details the training method of the discriminative model as the fifth embodiment.
[0134] As one implementation method, the training process of the discriminant model includes: obtaining manual annotation feedback data of historical code review results, which includes confirmed defect data marked as modified and false alarm data marked as invalid; and supervising fine-tuning training of the lightweight base model based on the manual annotation feedback data to obtain the discriminant model.
[0135] The following section will detail each step of the training process described above.
[0136] Step 1: Obtain the manual annotation feedback data of historical code review results. The manual annotation feedback data includes confirmed defect data marked as modified and false alarm data marked as invalid.
[0137] Specifically, during the actual operation of the intelligent code review system in this application, developers will manually annotate the review results output by the system. The annotation status includes modified, invalid, skipped, ignored, etc. The system periodically filters records containing annotation status from the database and exports them as training data files in CSV format. Each record retains key fields such as analysis (review analysis text), code (problem code snippet), level (defect level), manual_feedback_status (human feedback status), and tags.
[0138] In the exported manual annotation feedback data, data marked as modified is defined as confirmed defect data (positive example, valid), indicating that the developer has confirmed that the problem is a real code defect; data marked as invalid is defined as false alarm data (negative example, invalid), indicating that the developer has confirmed that the problem is a false alarm from the model.
[0139] As a result, the system constructs a high-quality manually annotated feedback dataset that includes both confirmed defect data and false alarm data, providing real and reliable labeled samples for subsequent supervision and fine-tuning.
[0140] To adapt to the fine-tuning input requirements of large language models, the system further converts the above CSV format data into an Alpaca format JSON training set.
[0141] Each training sample contains two fields: instruction and output.
[0142] The instruction consists of a fixed prompt template, the specific code content, and the analysis content. The fixed prompt template is used to determine whether the analysis's description of the code is valid. If it is valid, the answer is "valid"; if it is invalid, the answer is "invalid".
[0143] The output field corresponds to a binary label of valid or invalid.
[0144] After format conversion, the data is randomly shuffled and divided into training and validation sets in a 9:1 ratio for subsequent supervised fine-tuning.
[0145] Step 2: Supervised fine-tuning training of the lightweight pedestal model based on manually annotated feedback data to obtain the discriminative model.
[0146] After obtaining the manually annotated feedback data after the above format conversion, the system uses this data to train the lightweight base model using supervised fine-tuning (SFT) to obtain a dedicated discriminant model.
[0147] Specifically, in this embodiment, Qwen 2.5 1.5B is selected as the lightweight base model.
[0148] For fine-tuning, SFT full-parameter fine-tuning is used instead of parameter-efficient fine-tuning methods such as LoRA. This is because code review and judgment tasks require the model to deeply understand the complex relationship between code semantics and problem descriptions. Full-parameter fine-tuning can more fully learn these features, thereby significantly improving the accuracy of binary classification. After fine-tuning, a dedicated discrimination model with valid / invalid binary classification capabilities is obtained.
[0149] After training, the discriminative model is deployed using the vLLM inference framework. vLLM supports optimization techniques such as Continuous Batching and PagedAttention. The model is deployed on an independent port, achieving millisecond-level response times, which meets the low latency requirements of enterprise-level batch review scenarios.
[0150] In the actual code review process, this discrimination model serves as a second-level lightweight fine-tuning model, positioned between the first-level large model's initial review and the third-level external large model's in-depth verification, acting as a low-cost filtering gate. It's easy to understand that the first-level large model is the initial review model, while the third-level external large model is the in-depth verification model.
[0151] After the initial screening and rule-based hard correction of the classification level, candidate questions are input into the discriminant model for valid / invalid binary classification. Questions classified as invalid are downgraded to level E and stop entering the subsequent deep validation process, significantly reducing the number of calls to the external large model in the third level; questions classified as valid retain their original level and enter the third level for deep validation by the external large model. This approach can achieve early convergence of false positives without sacrificing the initial screening recall rate.
[0152] Furthermore, this embodiment establishes a continuous iterative closed loop from usage to annotation to training and optimization. As developers continue to use the review system and generate new manual annotation feedback data, the system periodically exports new data, repeating the above data format conversion, supervised fine-tuning training, and deployment processes to iteratively update the discrimination model. The review accuracy continuously improves with increased usage, creating a positive flywheel effect.
[0153] By executing the above two steps sequentially, this specific embodiment realizes the training process of the discrimination model. This process provides the core millisecond-level, high-precision filtering capability for the three-level funnel-shaped review architecture in this application.
[0154] Based on the first embodiment, this embodiment further details the post-processing and multi-dimensional de-illusion mechanism after generating the code review results, as the sixth embodiment.
[0155] As one implementation method, after generating the code review results, the following steps are also included:
[0156] Calculate the code similarity between the code review results and historical ignored issues. If the code similarity is greater than a preset similarity threshold, perform deduplication filtering on the code review results. Detect hallucination indicator keywords in the verification text output by the deep verification model. If hallucination indicator keywords are detected, mark the code review results as invalid.
[0157] Specifically, the post-processing method described above includes two parallel quality assurance actions, which clean the final output from the two dimensions of structured data and natural language semantics, respectively.
[0158] The first action is deduplication filtering based on code similarity.
[0159] In actual code review operations, developers often manually verify certain code patterns or alerts and mark them as ignored, false alarms, or not requiring repair. These marked records constitute historical ignored issues. To avoid the system repeatedly reporting similar issues that have already been manually waived, causing review fatigue and a decline in trust, this embodiment will perform code-level similarity calculations between the currently generated code review results and the historical ignored issues stored in the database.
[0160] For example, a sequence matching algorithm, such as SequenceMatcher, can be used to calculate the similarity ratio of two code texts. When the similarity exceeds a preset similarity threshold, such as 0.9, the system determines that the current result belongs to a known false positive variant or duplicate, and thus automatically performs a deduplication filtering operation and no longer displays it to the user.
[0161] Understandably, the comparison here specifically refers to historically ignored issues rather than all historical audit records. This ensures that only issues confirmed as invalid will trigger the silent mechanism, while genuine defects will still be reported normally even if they occur repeatedly, thus achieving a balance between reducing noise and preventing underreporting.
[0162] The second action is semantic detection based on illusion-indicating keywords.
[0163] Although the preceding steps have filtered out a large number of explicit illusions through source code consistency verification and discrimination models, the deep verification model may still produce a kind of implicit self-denying illusion when generating complex analysis text. That is, it may admit that there are no problems with the code during the analysis process, but ultimately output a defective conclusion incorrectly.
[0164] To intercept such logically contradictory results, this embodiment performs keyword scanning on the complete verification text output by the deep verification model. Illusion indicator keywords include, but are not limited to, semantic words that indicate affirmation or exclusion of defects, such as misjudgment, no problem, error-free code, logically correct, and as expected.
[0165] Once such keywords are detected in the verification text, the system will forcibly mark the result as invalid, even if the result is structurally complete and passes the code matching check.
[0166] This approach utilizes the text generated by the model itself as a reverse verification signal, which is equivalent to setting a semantic-level circuit breaker at the output end, effectively preventing seemingly reasonable but actually contradictory low-confidence results from reaching the user.
[0167] Through the collaborative work of the two methods described above, this embodiment constructs a final line of defense on the output side. Similarity deduplication addresses the pain point of duplicate reports, ensuring concise and efficient review results; illusion keyword detection addresses the trust issue of hidden false positives, ensuring logical consistency and high confidence in the review conclusions. The combination of these two approaches ensures that the review results, processed through a multi-level cascaded architecture, have undergone comprehensive purification from data authenticity and business relevance to semantic consistency before being presented to the user, significantly enhancing the practical application value of the intelligent code review system.
[0168] For example, see Figure 2 The system architecture example diagram for implementing the code review method provided in this application is shown below.
[0169] The diagram illustrates a complete engineering code review platform, which is divided into four logical areas: front-end, back-end service layer, core business components, and data persistence. It achieves a closed-loop process from code change capture to review result implementation.
[0170] At the front-end interaction level, the user interface is built using the React and TypeScript technology stack, and communicates with the back-end route controller through standard HTTP requests, providing a visual operation entry point.
[0171] The backend service layer, as the central hub of the system, integrates three basic support modules: Router & Controllers, which are responsible for receiving and distributing frontend requests; Changyou Task System, which supports batch and scheduled task sending and realizes automated scheduling of the review process; and Async Queue & Worker, which ensures task peak shaving and asynchronous processing capabilities in high-concurrency scenarios.
[0172] The core business components area integrates key logic for code review. The Version Control (SVN) module not only manages the code baseline through SVN tools and cache / mirror directories, but also supplies data to the review comments and project management modules on the right. The TreeSitter code parser performs low-level syntax analysis for mainstream languages such as Go and C#, extracting structured information. The Agentic tools module focuses on intelligent agent-assisted operations such as code insertion. The LLM module, as the core engine, handles code review tasks and the generation of automatic code repairs, and works in conjunction with the user permissions and progress tracking modules to ensure the controllability and traceability of the review process.
[0173] Ultimately, the system will persistently store all metadata, including audit records and task status, in a MongoDB database, forming a complete code quality data asset.
[0174] Corresponding to the system architecture for implementing the code review method described above, this application provides a flowchart example of a code review process.
[0175] like Figure 3 As shown, the code review process includes the following:
[0176] This diagram illustrates the complete automated chain from code change input to structured result output, achieving high-precision auditing through multi-level model and rule validation.
[0177] The process begins with three trigger modes: incremental, full, and file review, all of which retrieve the changed code via SVN. The system filters the changed content by path, directly retrieving the full code and using TreeSitter to construct a syntax tree to extract the relevant functions and their dependencies. These two are then combined to form a complete context.
[0178] Before the model is reviewed, the system adds formatting requirements based on language characteristics.
[0179] The audit core adopts a three-level chain mechanism: First, a local LLM with 30 parameters performs preliminary screening; then, a fine-tuning model with 1.5 parameters performs validity judgment and blocks invalid candidates; finally, an external LLM with 100+ parameters performs in-depth review and performs special repairs for specific formats, such as null pointers, and finally outputs a structured report containing information such as bug level and code pre-modification.
[0180] To more clearly illustrate the application value of the technical solution of this application in actual business, this embodiment provides a comprehensive application scenario of an enterprise-level code review platform.
[0181] In this scenario, the intelligent code review system is integrated into the enterprise's software development pipeline, realizing closed-loop management of the entire chain from code submission, automated review, result feedback to assisted repair.
[0182] Specifically, when developers complete feature development and submit the code to the version control system, the system will automatically listen for the submission event and trigger an audit task.
[0183] First, the system retrieves the code change data for this commit from the version control system and uses abstract syntax tree parsing technology to construct a semantically enhanced context containing complete function definitions and dependencies. This process ensures that the subsequent review model can understand the complete logical structure of the code, rather than guessing based solely on fragmented differential information, thus laying the foundation for accurate review at the input stage.
[0184] Subsequently, the system dynamically selects review resources based on the text size of the context: for changes of a normal size, it automatically routes to the locally deployed language model for rapid initial review; for changes involving complex logic or extremely long files, it seamlessly switches to a cloud-based language model with large parameters to ensure in-depth analysis. This dynamic routing mechanism significantly reduces the enterprise's computing power costs and waiting time while ensuring review quality.
[0185] During the review process, the system strictly implements multi-level cascading filtering. Candidate issues generated by the initial review model immediately enter the inter-level convergence processing stage, where the defect level is calibrated using deterministic rules, and source code consistency checks are performed on the referenced code snippets, directly eliminating false code evidence generated by model illusions. Next, a lightweight discrimination model acts as an intermediate gate, further intercepting invalid alarms at the business logic level with millisecond-level response speeds. Finally, only a small number of high-confidence target candidate issues are sent to the deep verification model for refined analysis. Through these layers of screening, the review results displayed on the front-end interface have significantly reduced false alarm interference, allowing developers to focus on truly valuable defect fixes.
[0186] At the front-end presentation level, the system not only displays defect descriptions and severity levels in a list format but also provides a visual differential preview function. Developers can directly view the location of defective code in the original file and its context on the interface. More importantly, for common defects of specific types, such as null pointer references and unreleased resources, the system can automatically generate repair code suggestions conforming to the differential format. Developers only need to click the "Apply Repair" button, and the system will automatically merge the repair patch into the local code or generate a change set to be committed. This simplifies the traditional process of discovering problems, manually locating them, and writing repairs to confirming problems and fixing them with one click, greatly improving defect repair efficiency.
[0187] In addition, the platform has established a system for continuous optimization based on human feedback.
[0188] When reviewing the audit results, developers can annotate each alert with comments such as "valid," "false alarm," or "ignore." This human feedback data from real business scenarios is automatically collected and structured by the system, serving as a valuable dataset for subsequent optimization of the judgment model and audit rules.
[0189] For example, when a certain type of code pattern is repeatedly marked as a false positive by multiple developers, the system can automatically adapt to this business characteristic by retraining the discrimination model or updating the inter-level convergence rules.
[0190] It is understood that although this embodiment describes the application effect of feedback data for model optimization, this is intended to illustrate that the technical solution of this application has the ability to evolve with use, and does not constitute a limitation on the steps of the code review method itself. Through this virtuous cycle of review, feedback, repair, and optimization, the intelligent code review platform provided by this embodiment can effectively solve the technical pain points of traditional solutions, such as high false alarm rate, lack of context understanding, and inability to automatically repair, and significantly improve the quality and efficiency of enterprise software development.
[0191] See Figure 4 The present application provides a schematic diagram of the structure of a code review device. The device adopts a modular architecture design, which encapsulates each processing step in the aforementioned method embodiment into an independent functional module to realize the automated execution of the code review process.
[0192] like Figure 4 As shown, the code review device includes a context building module 10, a primary review module 20, an inter-level convergence module 30, an intermediate filtering module 40, and a deep verification module 50. The modules communicate with each other through a data bus or message queue to form a progressive data processing link.
[0193] The context building module 10 is used to obtain code change data and build a semantically enhanced context based on the abstract syntax tree corresponding to the code change data.
[0194] Specifically, this module serves as the input to the entire review process, connecting to a version control system or code hosting platform to retrieve differential data of the code to be reviewed in real time.
[0195] Internally, this module integrates a syntax parsing engine that can convert linear source code into a structured abstract syntax tree, and extract function definition boundaries and identifier reference relationships, thereby reorganizing discrete change fragments into an enhanced context containing complete semantic dependencies.
[0196] For example, when receiving a Diff file involving modifications to business logic, the context building module 10 not only extracts the modified function body but also automatically associates it with the utility class definition or interface declaration of the function call, ensuring that the subsequent audit model can obtain sufficient background information. This design solves the misjudgment problem caused by the lack of context in traditional solutions from the source, laying the foundation for the audit accuracy of the entire device.
[0197] The primary review module 20 is used to perform a primary review of the semantically enhanced context using a primary review model to generate candidate questions. This module is connected to the context construction module 10 and receives the generated semantically enhanced context as input.
[0198] In terms of specific configuration, the primary review module 20 typically calls the language model service, which has broad coverage, to identify all potential code defects with a high recall rate, including but not limited to null pointer risks, resource leaks, and logical errors.
[0199] Understandably, this module allows for a certain false positive rate to ensure no missed detections, and its output list of candidate issues will serve as the raw dataset for the next stage of processing. This "wide entry, strict exit" strategy ensures the device's defect detection capabilities in complex code scenarios.
[0200] The inter-level convergence module 30 is used to perform inter-level convergence processing on candidate issues. The inter-level convergence processing includes calibrating the defect level of candidate issues based on preset rules and performing source code consistency verification on the code segments contained in the candidate issues.
[0201] This is the core filtering component that connects the upper and lower levels of the code review device. It is further divided into a rule calibration unit and a source code verification unit.
[0202] The rule calibration unit is used to identify the defect labels associated with candidate issues and, based on a pre-set label mapping table, forcibly correct the original level of the model output to a standardized target level. For example, it can uniformly upgrade safety labels to the severe level and downgrade style labels to the warning level, thereby eliminating the instability of the model evaluation criteria.
[0203] The source code verification unit focuses on combating model illusions by comparing the code snippets referenced in candidate problems with the original source code in a standardized manner. If the source code verification unit determines that a code snippet does not exist in the source file, it directly marks the candidate problem as invalid and blocks its further processing.
[0204] This dual verification method builds a deterministic firewall inside the device, effectively preventing false defects from contaminating subsequent high-cost verification processes.
[0205] The intermediate filtering module 40 is used to classify the candidate problems that have passed the inter-level convergence process by using a discriminant model to select the target candidate problems.
[0206] This module is located between the inter-stage convergence module 30 and the deep verification module 50, and acts as a low-cost smart gate.
[0207] Specifically, the intermediate filtering module 40 is equipped with a pre-trained lightweight discrimination model that focuses on binary classification tasks and can determine the validity of candidate questions with a response speed of milliseconds. For candidate questions that are determined to be invalid, the intermediate filtering module 40 downgrades them to a preset filtering state, such as level E, and physically blocks them from entering the deep verification stage; only candidate questions that are determined to be valid are passed to the next level as target candidate questions.
[0208] This design allows the device to significantly reduce the consumption of expensive computing resources without sacrificing audit accuracy, achieving an optimal balance between performance and cost.
[0209] The deep verification module 50 is used to perform deep verification of target candidate issues using a deep verification model, generating code review results. As the final adjudication unit of the device, this module receives target candidate issues that have undergone rigorous screening and invokes a high-precision deep verification model for logical analysis and evidence chain confirmation. Since the number of issues to be processed has significantly decreased at this point, the deep verification module 50 can concentrate computing resources for refined reasoning and even generate specific code repair suggestions. The final output code review results not only include defect confirmation information but also include detailed analysis reports and repair patches, which can be directly integrated with the front-end display or automated repair process.
[0210] Through the modular architecture described above, the code review device provided in this application decouples complex review methods into clear functional components, each operating independently yet closely collaboratively. This design not only facilitates system maintenance and upgrades—for example, updating the rule base of the inter-level convergence module 30 independently without affecting other modules—but also enhances the visibility of the technical solution in infringement determination, enabling a clear correspondence between the product's functional features and the scope of patent protection. It should be understood that, although... Figure 1 An exemplary layout of the modules is shown, but in actual deployment, the modules can also be merged or split according to the distribution of computing resources. As long as the above functional logic and data flow are consistent, they are all within the protection scope of this application.
[0211] This application also provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the code review method in any of the foregoing method embodiments.
[0212] Specifically, the computer device can be a server, workstation, personal computer, or other computing terminal with data processing capabilities deployed in an enterprise intranet or cloud environment.
[0213] The memory may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device, for persistently storing program instructions that implement the code review logic, as well as intermediate data and results generated during the review process. The processor communicates with the memory via the system bus, loads the computer program from the memory during runtime, and executes the steps sequentially according to the logical sequence defined by the program instructions, including obtaining code change data, constructing semantic enhancement context, primary review, inter-level convergence processing, discriminant model filtering, and deep verification.
[0214] It is understood that although this embodiment uses a general-purpose computer architecture as an example, in practical applications, the computer device can also be a specially customized ASIC chip, FPGA accelerator card, or a node in a distributed computing cluster. As long as it can complete the code review process described in the foregoing method embodiment by executing stored program instructions, it falls within the protection scope of this application. Through this hardware architecture, this application transforms the abstract review algorithm into concrete physical execution capabilities, ensuring the stable operation and real-time response of the multi-level cascaded review mechanism in high-concurrency code submission scenarios.
[0215] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the code review method in any of the foregoing method embodiments.
[0216] Specifically, the computer-readable storage medium can be a tangible, non-transitory storage medium, including but not limited to read-only memory (ROM), random access memory (RAM), CD-ROM, DVD, magnetic tape, floppy disk, USB flash drive, portable hard drive, solid-state drive (SSD), and optical data storage devices.
[0217] The computer program stored in this storage medium contains a series of instruction codes. When these instruction codes are read and executed by the processor of a computer device, they can control the device to complete the entire data processing process from obtaining code changes to generating review results. For example, when maintenance personnel insert this storage medium into the review server or mount it to a cloud platform via the network, the server can automatically load the program and start the intelligent code review service. This implementation method, existing in the form of a software product, allows the code review technology solution of this application to be independent of specific hardware, facilitating flexible deployment, version updates, and distribution in different computing environments, thereby greatly expanding the application scenarios and commercial value of the technology solution. At the same time, since the storage medium itself carries the instruction set for implementing the core technology solution, this also provides a clear physical object for evidence collection against software product infringement, further improving the intellectual property protection system of this application.
[0218] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A code review method, characterized in that, include: Obtain code change data and construct a semantically enhanced context based on the abstract syntax tree corresponding to the code change data; The semantic enhancement context is initially reviewed using a preliminary review model to generate candidate questions. The candidate issues are subjected to inter-level convergence processing, which includes calibrating the defect level of the candidate issues based on preset rules and performing source code consistency verification on the code segments contained in the candidate issues. The candidate problems that have passed the inter-level convergence process are classified by a discriminant model to select target candidate problems. The target candidate problem is deeply verified using a deep verification model, and code review results are generated.
2. The code review method according to claim 1, characterized in that, The calibration of the defect level of the candidate problem based on preset rules includes: Identify the defect tags associated with the candidate issues, and correct the defect level corresponding to the defect tags to the target level based on a preset tag mapping relationship; The step of performing source code consistency verification on the code fragments contained in the candidate problem includes: The code snippet is compared with the source code corresponding to the code change data. If the code snippet does not exist in the source code, the corresponding candidate issue is marked as invalid and blocked from entering the deep verification.
3. The code review method according to claim 2, characterized in that, The step of comparing the code fragment with the source code corresponding to the code change data includes: Perform character filtering on the code snippet and the source code respectively to remove at least one of the tab character, newline character, carriage return character and space character; Based on the code snippet after character filtering and the source code, perform precise string inclusion matching; If the matching result is "not included", then the code fragment is determined not to exist in the source code.
4. The code review method according to claim 1, characterized in that, The construction of a semantically enhanced context based on the abstract syntax tree corresponding to the code change data includes: Parse the code file corresponding to the code change data and construct the abstract syntax tree; Based on the abstract syntax tree, extract the function definition boundaries where the code change data is located; Parse the identifier reference relationships within the function definition boundaries and extract the associated dependency definitions; The semantic enhancement context is generated by combining the function definition boundary and the dependency definition.
5. The code review method according to claim 4, characterized in that, The method further includes: Determine the text size of the semantically enhanced context; Based on the comparison between the text size and the preset size threshold, dynamic routing is performed between the locally deployed language model and the cloud-deployed language model to determine either the primary review model for the initial review or the deep verification model for the deep verification.
6. The code review method according to claim 1, characterized in that, The process of classifying the candidate problems that have passed the inter-level convergence process using a discriminant model to select target candidate problems includes: The candidate questions are input into the discriminant model, which outputs a validity classification result, including a valid state or an invalid state. The discriminant model is a lightweight model, located between the primary review model and the deep verification model, and is used to classify the validity of candidate questions that have passed the inter-level convergence processing with a millisecond-level response speed. Candidate questions in the invalid state are downgraded to a preset filtering state and blocked from entering the deep verification. The candidate problem that is in the effective state is taken as the target candidate problem.
7. The code review method according to claim 1, characterized in that, The training process of the discriminative model includes: Obtain manual annotation feedback data of historical code review results, wherein the manual annotation feedback data includes confirmed defect data marked as modified and false alarm data marked as invalid; The lightweight pedestal model is trained under supervised supervision based on the manually annotated feedback data to obtain the discriminant model.
8. The code review method according to claim 1, characterized in that, After generating the code review results, the following is also included: Calculate the code similarity between the code review result and historically ignored issues. If the code similarity is greater than a preset similarity threshold, perform deduplication filtering on the code review result. The system detects hallucination indicator keywords in the verification text output by the deep verification model. If the hallucination indicator keywords are detected, the code review result is marked as invalid.
9. A code review device, characterized in that, include: The context building module is used to obtain code change data and build a semantically enhanced context based on the abstract syntax tree corresponding to the code change data; The primary review module is used to perform a primary review of the semantic enhancement context using a primary review model, and generate candidate questions. The inter-level convergence module is used to perform inter-level convergence processing on the candidate problem. The inter-level convergence processing includes calibrating the defect level of the candidate problem based on preset rules and performing source code consistency verification on the code fragments contained in the candidate problem. The intermediate filtering module is used to classify the candidate problems that have passed the inter-level convergence process by a discriminant model and filter out the target candidate problems. The deep verification module is used to perform deep verification on the target candidate problem through a deep verification model and generate code review results.
10. A code review device, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the code review method according to any one of claims 1 to 8.
11. 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 code review method according to any one of claims 1 to 8.
