Code analysis method, device, storage medium and computer program product

By segmenting code files and performing large-model-driven analysis, combined with case files to understand business logic, the problem of low analysis efficiency in large-scale codebases is solved, and intelligent code quality assessment and automatic report generation are achieved.

CN122332238APending Publication Date: 2026-07-03GF SECURITIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GF SECURITIES CO LTD
Filing Date
2026-02-04
Publication Date
2026-07-03

Smart Images

  • Figure CN122332238A_ABST
    Figure CN122332238A_ABST
Patent Text Reader

Abstract

This application provides a code analysis method, device, storage medium, and computer program product; the method includes: a first device acquiring multiple first code files corresponding to a first service, and performing code segmentation on the multiple first code files to obtain multiple second code files; the multiple first code files are used to implement the functional requirements corresponding to the first service; for each of the multiple second code files, the second code file and multiple case files are analyzed based on a first large model to obtain multiple analysis results, and the multiple analysis results are summarized based on the first large model to obtain a first report corresponding to the second code file; the multiple case files are used to test whether the functions implemented based on the multiple first code files meet the functional requirements corresponding to the first service; based on the first large model, the multiple first reports corresponding to the multiple second code files are summarized to obtain a second report; and the second report is output to a set first channel.
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 analysis method, device, storage medium, and computer program product. Background Technology

[0002] In related technologies, static analysis is performed on the code in the code file based on preset rules to evaluate the code quality. However, for code files in a large-scale business code library, there is a problem of low analysis efficiency. Summary of the Invention

[0003] To address the related technical issues, embodiments of this application provide a code analysis method, device, storage medium, and computer program product.

[0004] The technical solution of this application embodiment is implemented as follows: This application provides a code analysis method applied to a first device, the method comprising: Multiple first code files corresponding to the first service are obtained, and the multiple first code files are split into multiple second code files; the multiple first code files are used to implement the functional requirements corresponding to the first service; the number of lines of code in the second code files is less than a set first threshold. For each of the plurality of second code files, the second code file and the plurality of case files are analyzed based on the first large model to obtain multiple analysis results, and the plurality of analysis results are summarized based on the first large model to obtain a first report corresponding to the second code file; wherein, the plurality of case files are used to test whether the functions implemented based on the plurality of first code files meet the functional requirements corresponding to the first business; Based on the first major model, the multiple first reports corresponding to the multiple second code files are summarized to obtain the second report; The second report is output to a designated first channel; the first channel is used by relevant personnel of the first business to view the second report.

[0005] In the above scheme, the code segmentation of the plurality of first code files includes: Based on the plurality of first code files, a first syntax tree is constructed; the first syntax tree includes multiple syntax structures. Based on one or more defined syntax structure types, the first syntax tree is subjected to syntax structure recognition to obtain multiple first syntax structures; each of the multiple first syntax structures corresponds to one of the syntax structure types. Determine the first code corresponding to each of the plurality of first syntax structures in the plurality of first code files, and output the first code completely to a blank second code file or a non-blank second code file.

[0006] The method in the above scheme further includes: Obtain multiple first-case files; Each of the plurality of first case files is split into one or more second case files corresponding to each first case file; the number of cases in the second case file is less than or equal to a set second threshold. The system uploads multiple second case files corresponding to the multiple first case files to a first platform in batches, and receives multiple first identifiers returned by the first platform based on the multiple second case files; the first platform deploys the first large model; each of the multiple first identifiers is used to indicate one of the multiple second case files; Correspondingly, the analysis of the second code file and multiple case files based on the first major model includes: The second code file and the multiple second case files were analyzed based on the first major model.

[0007] In the above scheme, the analysis of the second code file and the multiple case files based on the first major model includes: A first request is sent to a first platform, and a first response is received from the first platform based on the first request; the first platform has a first large model deployed on it; the first request is used to request the first large model to perform code analysis on the second code file; the first response carries a first analysis result output by the first large model based on the model call corresponding to the first request; Multiple second requests are sent to the first platform, and a second response is received from the first platform based on each second request; each of the multiple second requests is used to request the first large model to perform joint analysis on the second code file and a case file; the second response carries the second analysis result output by the first large model based on the model call corresponding to the second request.

[0008] In the above scheme, the first request carries the second identifier corresponding to the second code file; each of the second requests carries the second identifier corresponding to the second code file and the first identifier corresponding to a case file; The second identifier is received from the first platform, and the second identifier is generated by the first platform based on the second code file uploaded by the first device; the first identifier is received from the first platform, and the first identifier is generated by the first platform based on the case file uploaded by the first device.

[0009] In the above scheme, based on the first major model, multiple first reports corresponding to the multiple second code files are summarized, including: Add each of the multiple first reports to the first report list in sequence; A third request is sent to a third interface of the first platform, and a third response is received from the third interface based on the third request; the first platform has a first large model deployed thereon; the third interface represents an interface for requesting the first platform to call the first large model for aggregation processing; the third request is for requesting the first large model to aggregate the reports in the first report list; the third response carries a second report output by the first large model based on the model call corresponding to the third request.

[0010] In the above scheme, after each addition of one of the plurality of first reports to the first report list, the method includes: Determine whether the number of characters corresponding to the first report list exceeds a set third threshold to obtain a first determination result; the number of characters represents the total number of characters in one or more reports in the first report list; When the first judgment result indicates that the number of the first character is greater than the third threshold: Send a fourth request to the third interface and receive a fourth response returned by the third interface based on the fourth request; the fourth request is used to request the first large model to summarize the reports in the current first report list, and the number of characters in the summarized report is less than or equal to a set fourth threshold; the fourth response carries a third report output by the first large model based on the model call corresponding to the fourth request; the fourth threshold is less than the third threshold; Clear the first report list; Add the third report to the first report list.

[0011] This application also provides a first device, including: a processor and a memory for storing a computer program capable of running on the processor. Wherein, when the processor is used to run the computer program, it executes the steps of any of the aforementioned methods.

[0012] This application also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of any of the aforementioned methods.

[0013] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the aforementioned methods.

[0014] In this embodiment, a first device acquires multiple first code files corresponding to a first service and performs code segmentation on the multiple first code files to obtain multiple second code files. Here, the multiple first code files are used to implement the functional requirements corresponding to the first service, and the number of lines of code in the second code files is less than a set first threshold. Then, for each of the multiple second code files, the second code file and multiple case files are analyzed based on a first large model to obtain multiple analysis results. The multiple analysis results are then summarized based on the first large model to obtain a first report corresponding to the second code file. The multiple case files are used to test whether the functions implemented based on the multiple first code files meet the functional requirements corresponding to the first service. Afterwards, based on the first large model, the multiple first reports corresponding to the multiple second code files are summarized to obtain a second report, which is then output to a set first channel. The first channel is used by relevant personnel of the first service to view the second report. In the above solution, code files and test case files are analyzed based on a large model, and a report is then compiled and automatically output to a designated channel for relevant personnel to view and use. In this way, an intelligent automatic code analysis mechanism driven by a large model is realized. Furthermore, by combining the analysis with test case files, the understanding of business logic is ensured. Compared with related technologies, for code files in a large-scale business code library, a relatively accurate code quality assessment can be achieved without the need for a large number of preset rules and manual intervention, thereby improving code analysis efficiency. Attached Figure Description

[0015] Figure 1 A schematic diagram illustrating the implementation flow of a code analysis method provided in an embodiment of this application; Figure 2 A schematic diagram of the software architecture of a code analysis system provided for an application embodiment of this application; Figure 3 A flowchart illustrating a code analysis method provided for an application embodiment of this application; Figure 4 A flowchart illustrating a code segmentation process provided for an application embodiment of this application; Figure 5 A flowchart illustrating a case file processing step provided for an application embodiment of this application; Figure 6A flowchart illustrating a multi-dimensional code analysis process provided for an application embodiment of this application; Figure 7 A flowchart illustrating a summary report processing step provided for an application embodiment of this application; Figure 8 A schematic diagram of the code segmentation process provided for an application embodiment of this application; Figure 9 A schematic diagram of the implementation code for a case file processing step provided in an application embodiment of this application; Figure 10 A schematic diagram of the implementation code for a multi-dimensional code analysis step provided for an application embodiment of this application; Figure 11 A schematic diagram of the implementation code for a summary report processing step provided in an application embodiment of this application; Figure 12 This is a schematic diagram of the structure of a code analysis device provided in an embodiment of this application; Figure 13 This is a schematic diagram of the hardware structure of a first device provided in an embodiment of this application. Detailed Implementation

[0016] As software systems grow in scale, code maintenance and quality management become increasingly important. Related technologies involve static analysis of code files based on preset rules to assess code quality. Specifically, code inspection tools such as Checkstyle, Programming Mistake Detectors (PMD), and SpotBugs are used to analyze code quality. However, these tools can only analyze items indicated by preset rules, failing to analyze items outside of those rules and lacking the ability to understand business logic. Therefore, for large-scale business codebases, due to the large number of code files, these technologies require predefined rules and manual analysis related to business logic, resulting in low analysis efficiency.

[0017] Based on this, in this embodiment of the application, the first device obtains multiple first code files corresponding to the first service, and performs code segmentation on the multiple first code files to obtain multiple second code files. Here, the multiple first code files are used to implement the functional requirements corresponding to the first service, and the number of lines of code in the second code files is less than a set first threshold. Then, for each of the multiple second code files, the second code file and multiple case files are analyzed based on a first large model to obtain multiple analysis results. The multiple analysis results are then summarized based on the first large model to obtain a first report corresponding to the second code file. The multiple case files are used to test whether the functions implemented based on the multiple first code files meet the functional requirements corresponding to the first service. Afterwards, based on the first large model, the multiple first reports corresponding to the multiple second code files are summarized to obtain a second report, and then the second report is output to a set first channel. The first channel is used by relevant personnel of the first service to view the second report. In the above solution, code files and test case files are analyzed based on a large model, and a report is then compiled and automatically output to a designated channel for relevant personnel to view and use. In this way, an intelligent automatic code analysis mechanism driven by a large model is realized. Furthermore, by combining the analysis with test case files, the understanding of business logic is ensured. Compared with related technologies, for code files in a large-scale business code library, a relatively accurate code quality assessment can be achieved without the need for a large number of preset rules and manual intervention, thereby improving code analysis efficiency.

[0018] The present application will now be described in further detail with reference to the accompanying drawings and embodiments.

[0019] This application provides a code analysis method applied to a first device. In practical applications, the first device can be a server or computing node running processing logic, or it can be understood as an electronic device.

[0020] See Figure 1 The method includes: Step 101: Obtain multiple first code files corresponding to the first business, and perform code splitting on the multiple first code files to obtain multiple second code files.

[0021] Among them, multiple first code files are used to implement the functional requirements corresponding to the first business; the number of lines of code in the second code file is less than the set first threshold.

[0022] In practical applications, "business" can refer to the transactions required to achieve a specific goal. The goal corresponding to the first business can include developing a specific software system. For example, the goal corresponding to the first business could be: developing an online payment system.

[0023] The objective of the first business can be broken down into one or more functional points. Each functional point can be represented as a task that needs to be completed to achieve the objective. These functional points can also be understood as the functional requirements of the first business. For example, for a business whose objective is to develop an online payment system, the corresponding functional points may include: user account management, payment transaction processing, and security authentication, etc.

[0024] In practical applications, the first code file may include one or more lines of code, which can be written in programming languages ​​such as Python and Java. By running the code from multiple first code files, the functional requirements corresponding to the first business function can be achieved.

[0025] In practical applications, multiple first-level code files can be stored in a cloud-based code repository, also known as a code repository. For example, multiple first-level code files can be stored in the master branch of a Git (Distributed Version Control System) repository. A first device can pull the corresponding code files from the cloud-based code repository to its local machine or a storage medium capable of reading data, thereby obtaining multiple first-level code files. For instance, a first device can use Git commands to pull multiple first-level code files from the master branch of a Git repository.

[0026] In practical applications, code splitting can divide a long code file into multiple shorter code files. Here, multiple first code files are split into multiple second code files. In subsequent processing, the code in multiple first code files can be processed by processing the multiple second code files. This reduces the amount of data in each code file during processing and avoids the reduction in processing efficiency or processing failure caused by the large amount of data in a single code file. For example, when processing a single code file based on a large model, it can avoid exceeding the input limit of the large model when processing a single code file.

[0027] Code segmentation methods in related technologies are usually based on string matching and simple statistics, or directly split according to the number of lines. This approach does not utilize the syntactic structure information of the code, lacks an understanding of the semantics of the code, cannot identify function boundaries and logical structures, and cannot maintain the integrity of variable scope and function call relationships.

[0028] In practical applications, during the code segmentation process of multiple first code files, the embodiments of this application can identify the syntactic structures in multiple first code files based on an Abstract Syntax Tree (AST). The syntactic structure can correspond to specific code semantics. Then, the code corresponding to a single syntactic structure can be completely written into a second code file to ensure the integrity of the code semantics contained in each second code file. For example, the semantic structures of functions, classes, variable scopes, etc. in the code file are guaranteed to be complete. Compared with related technologies, this improves the readability and maintainability of the code, and on this basis, it can improve the accuracy of code analysis.

[0029] Here, the first threshold can be understood as the maximum number of lines of code to be split during the code splitting process. In practical applications, when multiple second code files are obtained, a blank second code file can be created, and then the code split from the first code file each time can be written into this second code file until the split code causes the number of lines of code in the second code file to exceed the first threshold. After that, another blank second code file is created, and the code split from each time can be written into this second code file in the same way as the code writing method for a single second code file. Then, the relevant processing of the subsequent second code files is performed in the same way as the creation and writing methods of the second code files described above, until the multiple first code files are split.

[0030] Step 102: For each of the multiple second code files, analyze the second code file and multiple case files based on the first major model to obtain multiple analysis results, and summarize the multiple analysis results based on the first major model to obtain the first report corresponding to the second code file.

[0031] Among them, multiple case files are used to test whether the functions implemented based on multiple first code files meet the functional requirements corresponding to the first business.

[0032] In practical applications, multiple test cases can be used to test whether the functionality implemented based on multiple first code files meets the functional requirements of the first business function, thereby testing whether the functionality conforms to the business logic required by the first business function. Test cases can include file formats such as Excel workbooks (xlsx) or comma-separated values ​​(CSV).

[0033] A test case file may include one or more test cases. Each test case can be used to test whether a functional point implemented based on multiple first code files meets the functional requirements of the corresponding first business function. Test cases may include test data, test steps, and expected results—data describing how to test the corresponding functional point.

[0034] In practical applications, the first major model can refer to a language model with natural language understanding and generation capabilities, such as a large-scale pre-trained model based on the Transformer architecture. This first major model can understand the syntactic structure and semantic meaning of input code files, and can combine the content of multiple example files to understand business logic, thereby achieving multi-dimensional analysis that combines code and business dimensions. Furthermore, the first major model can also integrate and summarize the input content and style it through natural language understanding capabilities, thereby automatically generating highly readable and aesthetically pleasing reports.

[0035] In practical applications, the first major model can be deployed on other devices or platforms besides the first device. The first device can send a model invocation request to the device or platform where the first major model is located, and receive the response returned by the corresponding device or platform based on the model invocation request. The response can carry the processing result of the first major model based on the model invocation request, thereby realizing the processing performed by the first device based on the first major model.

[0036] Here, the second code file and multiple case files are analyzed based on the first major model. In practical applications, the analysis process can include two parts: first, analyzing the second code file separately to assess potential syntax errors and style conventions; second, jointly analyzing the second code file with multiple case files to determine whether the functionality implemented by the corresponding code meets the business logic required by the first business requirement. The analysis results can, for example, include code defect hints, performance optimization suggestions, and functional coverage assessments.

[0037] Here, based on the first main model, multiple analysis results are summarized to obtain the first report corresponding to the second code file. In practical applications, the first main model can summarize multiple analysis results corresponding to the second code file to generate a corresponding natural language description, and set the content style of this natural language description in the report, thus obtaining the first report. For example, the first main model can generate a natural language description that follows the syntax of a lightweight markup language (Markdown), and the style of this description in the first report can be set using Markdown syntax. The first report may include a Markdown document.

[0038] In practical applications, multiple first reports can be understood as independent analysis reports generated by the first major model for each second code file. The first report may include, for example, different types of code problems, their severity, and recommended measures.

[0039] In practical applications, the process of generating the first report based on the first major model can support an automatic retry mechanism to deal with situations where the generation of the first report fails due to network anomalies or model running errors, thereby improving the reliability of code analysis.

[0040] Step 103: Based on the first major model, summarize the multiple first reports corresponding to multiple second code files to obtain the second report.

[0041] In practical applications, the first major model can organize and refine multiple first reports, thereby generating a more concise, clearly structured, complete, and focused report based on the first report.

[0042] For example, the first major model can automatically identify recurring issues, categorize similar suggestions, and sort them by importance during the aggregation process, so that relevant personnel can quickly locate key improvement items.

[0043] For example, the second report can record the following issues: class and inheritance structure issues, method definition and duplication issues, syntax and documentation issues, initialization and property management issues, and missing core functional logic. In addition, the second report can provide optimization suggestions for these issues and highlight the content that needs to be focused on.

[0044] In practical applications, the process of summarizing multiple first reports corresponding to multiple second code files based on the first major model can support an automatic retry mechanism to deal with situations where the generation of second reports fails due to network anomalies or model running errors, thereby improving the reliability of code analysis.

[0045] For example, if the second report fails to be generated, the first device can automatically retry, that is, it can re-aggregate the multiple first reports corresponding to multiple second code files based on the first major model. If the second report still fails to be generated, it can retry again until the number of retries reaches the set maximum number of retries or the second report is successfully generated. The maximum number of retries can be set to 3 for example.

[0046] In related technologies, reports are usually generated by filling in static template files. However, static templates cannot adapt to diverse analysis results and personalized needs, resulting in insufficient template flexibility, and manual editing consumes a lot of time.

[0047] In this embodiment, the report is generated based on the first major model. This allows for the automated generation of highly readable and complete reports, and it can flexibly adapt to different report content. Compared with related technologies, this improves the quality and efficiency of report generation.

[0048] Step 104: Output the second report to the designated first channel.

[0049] The first channel is used by relevant personnel for the first business to view the second report.

[0050] In practical applications, the designated first channel can include a specific platform or system for publishing, notifying, or storing the second report. For example, it could include social media platforms, email services, push notification platforms, or internal management systems commonly used by relevant personnel. The selection of the first channel can be configured according to actual business needs, ensuring that relevant personnel in the first business can easily view the content of the second report. For instance, relevant personnel in the first business could include R&D personnel and testing personnel.

[0051] In practical applications, the first device can output a second report to a designated first channel via real-time network transmission or scheduled tasks. The first device can output a second report to one or more designated first channels; the output of a second report by the first device can also be understood as the first device distributing a second report.

[0052] In this embodiment, code files and test case files are analyzed based on a large model, and a report is then compiled and automatically output to a designated channel for relevant personnel to view and use. This realizes an intelligent automatic code analysis mechanism driven by a large model. Furthermore, by combining the analysis with test case files, the understanding of business logic is ensured. Compared with related technologies, for code files in a large-scale business code library, a relatively accurate code quality assessment can be achieved without the need for a large number of preset rules and manual intervention, thereby improving code analysis efficiency.

[0053] In addition, in related technologies, code splitting, case management, code analysis and report generation are handled by separate tools. This approach of using multiple independent tools to implement multiple processing steps usually has problems such as insufficient workflow orchestration capabilities, inconsistent interface standards, and fragmented state management.

[0054] In this embodiment, the entire process of code segmentation, case management, code analysis, and report generation is automated. Based on this, the processing logic corresponding to these processing steps can be integrated into the same device or system. Compared with related technologies, it is not necessary to use multiple tools to process each step separately, which reduces the cost of tool switching and further improves the efficiency of code analysis.

[0055] The code analysis process will be explained in further detail below.

[0056] In one embodiment, code segmentation is performed on multiple first code files, including: A first syntax tree is constructed based on multiple first code files; the first syntax tree includes multiple syntax structures. Based on one or more defined syntax structure types, the first syntax tree is subjected to syntax structure recognition to obtain multiple first syntax structures; each of the multiple first syntax structures corresponds to a syntax structure type. Determine the first code corresponding to each of the multiple first syntax structures in the multiple first code files, and output the complete first code to a blank second code file or a non-blank second code file.

[0057] In practical applications, an abstract syntax tree (API) can be understood as a tree-like data structure used to represent code structure. It reflects the syntactic elements and nesting relationships within the code, that is, it reflects the syntactic structure of the code. Each node in an API can be used to describe a syntactic structure in the code, such as an expression, statement, or function.

[0058] In practical applications, multiple first code files can be processed based on the syntax tree-related modules in the built-in modules of the programming language corresponding to the first code file to construct a first syntax tree.

[0059] For example, if the programming language corresponding to the first code file is Python, multiple first code files can be parsed based on Python's built-in ast module to obtain a first syntax tree.

[0060] In practical applications, the first device can identify the corresponding syntax structure from the first syntax tree based on one or more set syntax structure types, thereby obtaining multiple first syntax structures.

[0061] For example, one or more syntax structure types may include at least one or more of the following: function, class, and import statement.

[0062] In practical applications, the first device can iterate through multiple obtained first syntax structures. For each first syntax structure, the first device can locate its specific position in the first code file and extract the complete code segment, i.e., obtain the first code. Then, based on the number of lines of code in the second code file being processed and a first threshold, the first device can choose to either write the complete first code into a newly created blank second code file or append the first code to the currently processed second code file. This dynamic segmentation method ensures that the number of lines of code in each of the final second code files does not exceed the first threshold.

[0063] The second code file being processed can be understood as the code file in which the first code corresponding to the first syntax structure was written, that is, the non-blank second code file.

[0064] Code splitting methods in related technologies are typically based on string matching and simple statistics, or directly splitting by line number. These methods fail to utilize the syntactic structure of the code, lack an understanding of its semantics, cannot identify function boundaries and logical structures, and cannot maintain the integrity of variable scope and function call relationships. For example, if splitting is done solely by line number—placing the first 100 lines of the first code file in the first second code file, and lines 101-200 in the second second code file—this direct, hard splitting results in incomplete code logic, leading to incorrect execution and the inability to maintain original dependencies.

[0065] In this embodiment, the first code corresponding to each first syntactic structure is completely written into the second code file. This ensures the integrity of the code logic and semantics contained in each second code file, while maintaining the code dependencies in the first code file. This improves the readability and maintainability of the segmented code, enabling the first large model to more efficiently understand the processing logic described by the code during the processing of the code file, thereby improving the efficiency and accuracy of code analysis.

[0066] For example, the first device can place the complete code corresponding to each function or class into a single second code file without interruption, thus ensuring the integrity of the code logic. The first device can also place all import statements and their corresponding code into a single second code file, using this second code file as the main entry point file, i.e., the main file. Furthermore, the first device can import other second code files besides the main entry point file into the main entry point file based on a defined import statement such as "from .module_X import *", thereby maintaining the code dependencies within the second code files.

[0067] In one embodiment, the code analysis method provided in this application further includes: Obtain multiple first-case files; Each of the multiple first case files is split into one or more second case files corresponding to each first case file; the number of cases in the second case files is less than or equal to a set second threshold. Upload multiple second case files corresponding to multiple first case files to the first platform in batches, and receive multiple first identifiers returned by the first platform based on the multiple second case files; the first platform deploys a first large model; each of the multiple first identifiers is used to indicate one of the multiple second case files; Correspondingly, based on the first major model, the second code file and multiple case files are analyzed, including: The second code file and several second case files were analyzed based on the first major model.

[0068] In practical applications, the first device can traverse a preset file directory and read multiple first case files from that directory.

[0069] In practical applications, file splitting can divide a case file with a large number of cases into multiple case files with fewer cases. Here, each of the multiple first case files is split into multiple second case files through code splitting. In this way, in subsequent processing, the cases in the multiple first case files can be processed by processing the multiple second case files, and the amount of data in each case file is reduced during processing. This avoids the reduction in processing efficiency or processing failure caused by the large amount of data in a single case file. For example, when processing a single case file based on a large model, it can avoid exceeding the input limit of the large model when processing a single case file.

[0070] In practical applications, for a first case file whose number of cases does not exceed the second threshold, the first case file can be directly output during the file segmentation process, and the first case file can also be regarded as the second case file obtained after segmentation.

[0071] Here, the first major model is deployed on the first platform, which can also be understood as the major model platform. The first platform can provide one or more interfaces. Each interface can be used by an interface caller to request and process a corresponding request, and then return a response to the caller, which can carry the corresponding processing result. For example, the first platform can provide an interface for interface callers to upload files, and it can also provide an interface for interface callers to request and process the first major model.

[0072] For the interface provided by the first platform used to call the first major model for processing, this interface can be bound to a set major model prompt word. Different interfaces can have different major model prompt words. When the first major model processes the input based on the model call corresponding to the interface, it can perform corresponding processing based on the corresponding major model prompt word. For example, for the interface used to call the first major model for code analysis, the major model prompt word corresponding to this interface may include: "Perform code quality analysis on the input code file, in markdown format, output to a default variable, and the output length must be controlled to be less than 3000 characters."

[0073] The first device can invoke the interface provided by the first platform by sending a request. In this case, the first device can be understood as the interface caller. The first device sending a request to the interface provided by the first platform can also be regarded as the first device sending a request to the first platform.

[0074] When the first device sends a request to the first platform, it can explicitly specify the interface to be called, that is, actively send the request to the corresponding interface of the first platform. Alternatively, the first device may not explicitly specify the interface to be called, and the first platform, after receiving the request from the first device, can automatically select and call the corresponding interface for the request.

[0075] Here, the first device uploads multiple second case files to the first platform in batches. Batch upload means that the first device sends multiple second case files to the first platform at once, instead of uploading them one by one, thereby reducing network latency and improving processing efficiency.

[0076] In practical applications, the first device can send a fifth request to the interface provided by the first platform for uploading case files; the fifth request can be used to request the batch uploading of multiple second case files. After receiving the fifth request, the first platform can store the corresponding second case files in its storage medium and generate a corresponding file identifier, i.e., a first identifier, for each second case file. Then, the first platform can include multiple first identifiers corresponding to multiple second case files in the response returned to the first device. By receiving the response returned by the first platform based on the fifth request, the first device can obtain the first identifiers corresponding to the multiple second case files.

[0077] The response returned by the first platform based on the fifth request may include: the mapping relationship between the file paths of each second case file in the first device and the corresponding first identifier.

[0078] In practical applications, the first device can instruct the first platform to process the corresponding second case file through the first identifier. For example, when the first device requests the first platform to call the first large model to perform joint analysis of the second case file and the second code file, it can carry the first identifier corresponding to the second case file in the corresponding request, without having to carry the complete data in the second case file. This saves network overhead for the request and improves code analysis efficiency.

[0079] In one embodiment, the second code file and multiple case files are analyzed based on the first large model, including: A first request is sent to a first platform, and a first response is received from the first platform based on the first request; the first platform has a first large model deployed; the first request is used to request the first large model to perform code analysis on the second code file; the first response carries the first analysis result output by the first large model based on the model call corresponding to the first request; Multiple second requests are sent to the first platform, and a second response is received from the first platform based on each second request; each of the multiple second requests is used to request the first large model to perform joint analysis on the second code file and a case file; the second response carries the second analysis result output by the first large model based on the model call corresponding to the second request.

[0080] In practical applications, the first platform can provide a second interface for requesting the first major model to perform code analysis. The first device can send a first request to the second interface, that is, it can call the second interface to perform code analysis by calling the first major model.

[0081] When analyzing the second code file, the first model can analyze the second code file independently, assessing potential syntax errors and style conventions, and then outputting the first analysis result. This first analysis result can, for example, include code defect hints and performance optimization suggestions.

[0082] In practical applications, the first platform can provide a third interface for requesting the first major model to perform joint analysis of code files and case files. The first device can send a second request to the third interface, that is, it can call the third interface to realize the joint analysis of code files and case files by calling the first major model.

[0083] When the first model performs joint analysis on the second code file and the case file, it can determine whether the functionality implemented by the code in the second code file meets the business logic required by the first business, and then output the second analysis result. The second analysis result can include, for example, functional coverage assessment and functional optimization suggestions.

[0084] In practical applications, each second request sent by the first device can be used to request the first large model to perform joint analysis on the second code file and a second case file. In this way, by inputting the segmented code file and the segmented case file into the first large model, the input limit of the first large model when processing a single file can be avoided, thereby improving the stability and efficiency of code analysis.

[0085] In one embodiment, the first request carries a second identifier corresponding to the second code file; each of the second requests carries the second identifier corresponding to the second code file and a first identifier corresponding to a case file; The second identifier is received from the first platform, and the second identifier is generated by the first platform based on the second code file uploaded by the first device; the first identifier is received from the first platform, and the first identifier is generated by the first platform based on the case file uploaded by the first device.

[0086] In practical applications, the first device can pre-upload multiple second code files to the first platform in batches and receive multiple second identifiers returned by the first platform. Alternatively, the first device can upload a second code file to the first platform during the analysis of each second code file and multiple case files, and receive the second identifier assigned to that second code file by the first platform.

[0087] During the process of uploading the second code file, the first device can send a sixth request to the interface provided by the first platform for uploading code files; the sixth request can be used to request the upload of the second code file. After receiving the sixth request, the first platform can store the corresponding second code file in the storage medium of the second platform, and generate a corresponding file identifier, i.e., a second identifier, for each second code file, and then carry the multiple second identifiers corresponding to multiple second code files in the response returned to the first device. By receiving the response returned by the first platform based on the sixth request, the first device can obtain the second identifier corresponding to the second code file.

[0088] The response returned by the first platform based on the sixth request may include: the mapping relationship between the file path of the second code file in the first device and the corresponding second identifier.

[0089] Here, the first device carries a second identifier corresponding to the second code file to be analyzed in the first request, and carries the second identifier corresponding to the second code file to be analyzed and the first identifier corresponding to the case file to be analyzed in the second request. In practical applications, the first platform can query the corresponding file in the stored files based on the identifiers carried in the corresponding requests, and then call the first main model to process the file accordingly. In this way, when the first device requests the first platform to call the first main model to analyze the second code file and multiple case files, it does not need to carry the complete file content, thereby saving network overhead and improving code analysis efficiency.

[0090] In one embodiment, based on the first major model, multiple first reports corresponding to multiple second code files are summarized, including: Add each of the multiple first reports to the first report list in sequence; A third request is sent to the third interface of the first platform, and a third response is received from the third interface based on the third request; the first platform has a first large model deployed; the third interface represents the interface used to request the first platform to call the first large model for summary processing; the third request is used to request the first large model to summarize the reports in the first report list; the third response carries the second report output by the first large model based on the model call corresponding to the third request.

[0091] In practical applications, the model call corresponding to the third request can also be regarded as the model call corresponding to the third interface. The third request can indicate the input data for the model call corresponding to the third interface.

[0092] The third interface can be bound to a set large model prompt, which can include, for example, "summarize all inputs, formatted as markdown, output to the report variable, and the output length must be less than 3000 characters." When the first large model processes inputs based on the model call corresponding to the third interface, it can summarize and process the inputs based on the large model prompt corresponding to the third interface.

[0093] In practical applications, for each of the multiple second code files, after obtaining the first analysis result and multiple second analysis results corresponding to that second code file, a third interface can be called to summarize these results. Specifically, a seventh request can be sent to the third interface, requesting the invocation of the first main model to summarize the analysis results corresponding to that second code file. This achieves the summary processing of the analysis results corresponding to the second code file based on the first main model, resulting in a first report. The first report can also be understood as an independent analysis report generated specifically for that second code file.

[0094] In practical applications, after obtaining the first reports corresponding to multiple second code files, these first reports can be summarized again based on the first major model. This allows for the organization and refinement of multiple first reports, generating a more concise, clearly structured, complete, and focused report based on the first reports. In other words, a second report is generated.

[0095] Here, during the generation of the second report, each of the multiple first reports is sequentially added to the first report list. The first report list can be understood as a data structure used to temporarily store the report content of all the first reports to be summarized. In practical applications, the first report list can be implemented using arrays or lists. Through the first report list, multiple independently generated first reports can be centrally managed, thus providing a unified input data source for subsequent processing based on the first main model, improving code analysis efficiency.

[0096] In one embodiment, after each addition of one of a plurality of first reports to the first report list, the code analysis method provided in this application includes: Determine whether the number of characters corresponding to the first report list exceeds the set third threshold to obtain the first determination result; the number of characters represents the total number of characters in one or more reports in the first report list; If the first judgment result indicates that the number of the first character is greater than the third threshold: Send a fourth request to the third interface and receive a fourth response from the third interface based on the fourth request; the fourth request is used to request the first major model to summarize the reports in the current first report list, and the number of characters in the summarized report is less than or equal to the set fourth threshold; the fourth response carries the third report output by the first major model based on the model call corresponding to the fourth request; the fourth threshold is less than the third threshold; Clear the first report list; Add the third report to the first report list.

[0097] In practical applications, after adding one of the multiple first reports to the first report list, and before adding the next corresponding first report, it can be determined whether the total character count of all reports in the first report list exceeds a third threshold. If the total character count exceeds the third threshold, the reports in the first report list are re-aggregated to reduce the character count of the report content already included in the first report list. Based on this, the second report obtained by aggregating the first report list using the first major model can be more concise, easier to transmit, and easier to display.

[0098] Here, the fourth threshold is less than the third threshold. Thus, if the number of characters in the first report list exceeds the third threshold, the number of characters in the re-summarized report can accumulate before reaching the third threshold, reducing the number of subsequent re-summarizations. This reduces the number of calls to the first major model and improves code analysis efficiency.

[0099] The present application will be further described in detail below with reference to application examples.

[0100] This application provides a code analysis system whose physical architecture may mainly include the following components: an application server, a database storage module, an API (Application Programming Interface) gateway, a message queue module, and a monitoring and alarm module.

[0101] In practical applications, the application server can be used to execute the core processing logic of the code analysis method, which is equivalent to the first device in this application embodiment. The application server can be deployed with software corresponding to the processing logic, for example, it can be deployed with corresponding code files, which can be exemplary running in a Python 3.8+ environment.

[0102] The database storage module can be used to store the analysis results, related configuration parameters, and processing status generated by the application server during code analysis.

[0103] An interface gateway can be used to manage external service calls of various modules in a code analysis system. For example, it can be used to manage interfaces such as Git API, large model API, and message push API that the application server needs to call to provide services.

[0104] Message queues can be used to handle asynchronous tasks and progress status updates.

[0105] Monitoring and alerting can be used to monitor the running status of the system by analyzing the code and to issue alerts when anomalies occur.

[0106] In practical applications, the software architecture of a code analysis system may include the following modules: application entry point, system configuration management, log system configuration, interface control, core processing engine, code splitting module, case processing module, large model API management module, Git operation tools, and message push interface. These modules can be implemented with concrete code, for example, code written in Python. For example, the software architecture of a code analysis system can be found in [reference needed]. Figure 2 As shown.

[0107] In practical applications, see Figure 3 The overall process of code analysis by a code analysis system can be mainly divided into the following steps: Step 1: Environment preparation and repository acquisition.

[0108] In practical applications, relevant personnel can write code and submit it to the code repository. The code analysis system can determine the code repository and Git branch where the code to be analyzed is located based on preset configuration parameters, thereby obtaining the code to be analyzed.

[0109] The code analysis system can also clean up the output directory, which can be used to write the processing results during the code analysis process. For example, it can be used to write the split code files and reports summarized from the analysis results.

[0110] The code analysis system can also initialize the processing state, such as initializing the runtime environment of the software architecture.

[0111] Step 2: Intelligent code splitting.

[0112] In practical applications, the code repository directory can be traversed to identify multiple code files. Then, the code structure of multiple code files can be analyzed based on the abstract syntax tree to generate semantically complete modular files.

[0113] Step 3: Case file processing.

[0114] In practical applications, a preset case directory can be scanned, which is the directory where the case files are located. Then, the case files are segmented, and the segmented case files are uploaded to the large model platform to obtain the file identifier (ID) corresponding to the uploaded case files.

[0115] Step 4: Multi-dimensional code analysis of the large model.

[0116] In practical applications, large models can be deployed on a large model platform. The code analysis system can call the large model API provided by the platform to analyze the integrated code segmentation results, then call the large model API to perform joint analysis of code files and case files, and finally generate an intelligent analysis report. The large model API can be used to request and invoke large models for processing.

[0117] During the report generation process, an intelligent error handling and retry mechanism can be set up.

[0118] Step 5: Generate and send the summary report.

[0119] In practical applications, code analysis systems can collect all generated analysis reports and summarize these reports based on a large model to generate a structured summary report, which can then be intelligently distributed to multiple channels.

[0120] The following is about Figure 3 The steps in the overall process shown will be explained in further detail.

[0121] In practical applications, see Figure 4 Intelligent code segmentation can mainly include the following steps: Step 1: Traverse the code files in the code repository directory.

[0122] Here, the code file is equivalent to the first code file in the embodiments of this application.

[0123] Step 2: Read the unanalyzed code file.

[0124] Step 3: Based on the built-in syntax tree module of the programming language corresponding to the code file, perform syntax tree parsing on the read file content to construct the syntax tree corresponding to the code file, and extract one or more syntax structures from the syntax tree, such as functions, classes, and import statements.

[0125] Step 4: Create a new file to store the contents of the split file.

[0126] In practical applications, the newly created file can be equivalent to the second code file in the embodiments of this application.

[0127] Step 5: Traverse all nodes obtained after parsing the syntax tree, and determine whether the existing file content plus the code involved in the current node exceeds the maximum number of lines in a single file. If yes, jump to step 6; otherwise, jump to step 8.

[0128] Here, the maximum number of rows limit can be equivalent to the first threshold in the embodiments of this application.

[0129] Step 6: Save the current file content.

[0130] Step 7: Create a new file to store the contents of the split file.

[0131] Step 8: Output the code related to the current node to the current file.

[0132] In practical applications, see Figure 5 Case file processing can mainly include the following steps: Step 1: Traverse the case files in the case directory.

[0133] Step 2: Read the case file and determine whether the number of cases in the case file exceeds the maximum number of cases. If yes, proceed to step 3; otherwise, proceed to step 4.

[0134] Here, the maximum number of cases can be equivalent to the second threshold in the embodiments of this application.

[0135] Step 3: Split the case files so that the number of cases in each file does not exceed the maximum number of cases.

[0136] Step 4: Upload the split or unsplit case files to the large model platform and obtain the corresponding case file identifier.

[0137] Here, the case file identifier can be equivalent to the first identifier in the embodiments of this application.

[0138] In practical applications, see Figure 6 Large-scale, multi-dimensional code analysis can mainly include the following steps: Step 1: Traverse the code directory after code splitting.

[0139] Step 2: Read the contents of the unanalyzed code file.

[0140] Step 3: Analyze the code content by calling the large model interface.

[0141] In practical applications, the large model interface can be understood as the interface provided by the large model platform for calling large models for processing.

[0142] Step 4: Traverse all case files.

[0143] Step 5: Call the large model interface to perform joint analysis of the code and cases.

[0144] Step 6: Summarize the large model analysis results from Steps 3 and 5, and call the large model to summarize the results.

[0145] In practical applications, the report summarizing the analysis results from the large model can be equivalent to the first report in this embodiment. The first report corresponding to each code file can be added to the report list sequentially.

[0146] Step 7: Determine if the current report list content exceeds a certain word count. If yes, proceed to Step 8; otherwise, end the process.

[0147] Step 8: Use the large model to re-summarize the report to keep it within the specified word count.

[0148] In practical applications, a large model can be called to re-aggregate the reports in the report list, making the final generated report more concise, easier to transmit and display.

[0149] In practical applications, see Figure 7 Generating and sending summary reports can mainly include the following steps: Step 1: Call the large model to generate a formatted summary report.

[0150] Here, the summary report can be equivalent to the second report in the embodiments of this application.

[0151] Step 2: If generation fails and the number of failures is less than 3, go back to step 1; otherwise, go back to step 3.

[0152] Step 3: If the generation is successful, proceed to step 4; otherwise, the process ends.

[0153] Step 4: Send the summarized report content through the designated channel.

[0154] Here, the designated channel can be equivalent to the first channel in the embodiments of this application.

[0155] In practical applications, Figures 3 to 7 The processes shown can all be implemented based on the code corresponding to the software architecture modules of the code analysis system.

[0156] For example, Figure 4 The intelligent code segmentation process shown can be mainly based on Figure 8 The code implementation shown is as follows: Figure 5 The case file processing steps shown can be mainly based on Figure 9 The code implementation shown is as follows: Figure 6 The large-scale multi-dimensional code analysis step shown can be mainly based on Figure 10 The code implementation shown is as follows: Figure 7 The steps for generating and sending summary reports shown can be primarily based on... Figure 11 The code implementation is shown.

[0157] In this application embodiment, code files and test files used for testing code files are analyzed based on a large model, and then a report is compiled and automatically output to a designated channel for relevant personnel to view and use. In this way, an intelligent automatic code analysis mechanism driven by a large model is realized, which has the following technical advantages compared with related technologies: Improved processing efficiency: From code acquisition to analysis and report output, the entire process is automated, which improves efficiency compared to manual operation.

[0158] Improved analysis accuracy: By combining case files during the analysis process, the understanding of business logic is ensured, and a multi-dimensional analysis mechanism is implemented, which can effectively improve the accuracy of code quality assessment. Thus, relatively accurate code quality assessment can be achieved without manual intervention.

[0159] Report quality optimization: Automated report generation, through multiple summarization and refinement, improves the completeness and readability of reports.

[0160] Enhanced system integration: The processing logic for code splitting, case handling, report generation, and other processes is unified and integrated into the same system. Compared with related technologies, it is not necessary to use multiple tools to handle each process separately, which reduces the cost of switching tools.

[0161] Based on the embodiments described above, this application also provides a code analysis apparatus, applied to the first device, see [link to previous document]. Figure 12 The device includes: The segmentation unit 1201 is used to obtain multiple first code files corresponding to the first service, and to segment the multiple first code files to obtain multiple second code files; the multiple first code files are used to implement the functional requirements corresponding to the first service; the number of lines of code in the second code files is less than a set first threshold. The analysis unit 1202 is used to analyze each of the plurality of second code files and the plurality of case files based on a first large model to obtain multiple analysis results, and to summarize the plurality of analysis results based on the first large model to obtain a first report corresponding to the second code file; wherein, the plurality of case files are used to test whether the functions implemented based on the plurality of first code files meet the functional requirements corresponding to the first business. The aggregation unit 1203 is used to aggregate multiple first reports corresponding to the multiple second code files based on the first large model to obtain a second report; Output unit 1204 is used to output the second report to a set first channel; the first channel is used for relevant personnel of the first business to view the second report.

[0162] In one embodiment, the segmentation unit 1201 performs code segmentation on the plurality of first code files, including: Based on the plurality of first code files, a first syntax tree is constructed; the first syntax tree includes multiple syntax structures. Based on one or more defined syntax structure types, the first syntax tree is subjected to syntax structure recognition to obtain multiple first syntax structures; each of the multiple first syntax structures corresponds to one of the syntax structure types. Determine the first code corresponding to each of the plurality of first syntax structures in the plurality of first code files, and output the first code completely to a blank second code file or a non-blank second code file.

[0163] In one embodiment, the analysis unit 1202 is further configured to: Obtain multiple first-case files; Each of the plurality of first case files is split into one or more second case files corresponding to each first case file; the number of cases in the second case file is less than or equal to a set second threshold. The system uploads multiple second case files corresponding to the multiple first case files to a first platform in batches, and receives multiple first identifiers returned by the first platform based on the multiple second case files; the first platform deploys the first large model; each of the multiple first identifiers is used to indicate one of the multiple second case files; Correspondingly, the analysis unit 1202 analyzes the second code file and multiple case files based on the first large model, including: The second code file and the multiple second case files were analyzed based on the first major model.

[0164] In one embodiment, the analysis unit 1202 analyzes the second code file and the plurality of case files based on a first large model, including: A first request is sent to a first platform, and a first response is received from the first platform based on the first request; the first platform has a first large model deployed on it; the first request is used to request the first large model to perform code analysis on the second code file; the first response carries a first analysis result output by the first large model based on the model call corresponding to the first request; Multiple second requests are sent to the first platform, and a second response is received from the first platform based on each second request; each of the multiple second requests is used to request the first large model to perform joint analysis on the second code file and a case file; the second response carries the second analysis result output by the first large model based on the model call corresponding to the second request.

[0165] In one embodiment, the first request carries a second identifier corresponding to the second code file; each of the second requests carries the second identifier corresponding to the second code file and a first identifier corresponding to a case file; The second identifier is received from the first platform, and the second identifier is generated by the first platform based on the second code file uploaded by the first device; the first identifier is received from the first platform, and the first identifier is generated by the first platform based on the case file uploaded by the first device.

[0166] In one embodiment, the aggregation unit 1203, based on the first large model, aggregates multiple first reports corresponding to the multiple second code files, including: Add each of the multiple first reports to the first report list in sequence; A third request is sent to a third interface of the first platform, and a third response is received from the third interface based on the third request; the first platform has a first large model deployed thereon; the third interface represents an interface for requesting the first platform to call the first large model for aggregation processing; the third request is for requesting the first large model to aggregate the reports in the first report list; the third response carries a second report output by the first large model based on the model call corresponding to the third request.

[0167] In one embodiment, after the aggregation unit 1203 adds one of the plurality of first reports to the first report list each time, it is used to: Determine whether the number of characters corresponding to the first report list exceeds a set third threshold to obtain a first determination result; the number of characters represents the total number of characters in one or more reports in the first report list; When the first judgment result indicates that the number of the first character is greater than the third threshold: Send a fourth request to the third interface and receive a fourth response returned by the third interface based on the fourth request; the fourth request is used to request the first large model to summarize the reports in the current first report list, and the number of characters in the summarized report is less than or equal to a set fourth threshold; the fourth response carries a third report output by the first large model based on the model call corresponding to the fourth request; the fourth threshold is less than the third threshold; Clear the first report list; Add the third report to the first report list.

[0168] In practical applications, the segmentation unit 1201, analysis unit 1202, summarization unit 1203, and output unit 1204 can be implemented by the processor in the code analysis device.

[0169] It should be noted that the code analysis device provided in the above embodiments is only illustrated by the division of the above program modules. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. In addition, the code analysis device and the code analysis method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0170] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, this application also provides a first device, referring to... Figure 13 The first device includes: Communication interface 1 enables information exchange with other devices; Processor 2 is connected to communication interface 1 to enable information interaction with other devices and, when running a computer program, executes the methods provided by one or more technical solutions in the above embodiments. The computer program is stored in memory 3.

[0171] Specifically, the processor 2 is used to acquire multiple first code files corresponding to the first service, and to perform code segmentation on the multiple first code files to obtain multiple second code files; the multiple first code files are used to implement the functional requirements corresponding to the first service; the number of lines of code in the second code files is less than a set first threshold. For each of the plurality of second code files, the second code file and the plurality of case files are analyzed based on the first large model to obtain multiple analysis results, and the plurality of analysis results are summarized based on the first large model to obtain a first report corresponding to the second code file; wherein, the plurality of case files are used to test whether the functions implemented based on the plurality of first code files meet the functional requirements corresponding to the first business; Based on the first major model, multiple first reports corresponding to the multiple second code files are summarized to obtain a second report; and, The second report is output to a designated first channel; the first channel is used by relevant personnel of the first business to view the second report.

[0172] In one embodiment, the processor 2 performs code segmentation on the plurality of first code files, including: Based on the plurality of first code files, a first syntax tree is constructed; the first syntax tree includes multiple syntax structures. Based on one or more defined syntax structure types, the first syntax tree is subjected to syntax structure recognition to obtain multiple first syntax structures; each of the multiple first syntax structures corresponds to one of the syntax structure types. Determine the first code corresponding to each of the plurality of first syntax structures in the plurality of first code files, and output the first code completely to a blank second code file or a non-blank second code file.

[0173] In one embodiment, the processor 2 is further configured to: Obtain multiple first-case files; Each of the plurality of first case files is split into one or more second case files corresponding to each first case file; the number of cases in the second case file is less than or equal to a set second threshold. The system uploads multiple second case files corresponding to the multiple first case files to a first platform in batches, and receives multiple first identifiers returned by the first platform based on the multiple second case files; the first platform deploys the first large model; each of the multiple first identifiers is used to indicate one of the multiple second case files; Correspondingly, the processor 2 analyzes the second code file and multiple case files based on the first large model, including: The second code file and the multiple second case files were analyzed based on the first major model.

[0174] In one embodiment, the processor 2 analyzes the second code file and the plurality of case files based on a first large model, including: A first request is sent to a first platform, and a first response is received from the first platform based on the first request; the first platform has a first large model deployed on it; the first request is used to request the first large model to perform code analysis on the second code file; the first response carries a first analysis result output by the first large model based on the model call corresponding to the first request; Multiple second requests are sent to the first platform, and a second response is received from the first platform based on each second request; each of the multiple second requests is used to request the first large model to perform joint analysis on the second code file and a case file; the second response carries the second analysis result output by the first large model based on the model call corresponding to the second request.

[0175] In one embodiment, the first request carries a second identifier corresponding to the second code file; each of the second requests carries the second identifier corresponding to the second code file and a first identifier corresponding to a case file; The second identifier is received from the first platform, and the second identifier is generated by the first platform based on the second code file uploaded by the first device; the first identifier is received from the first platform, and the first identifier is generated by the first platform based on the case file uploaded by the first device.

[0176] In one embodiment, the processor 2, based on the first large model, summarizes multiple first reports corresponding to the multiple second code files, including: Add each of the multiple first reports to the first report list in sequence; A third request is sent to a third interface of the first platform, and a third response is received from the third interface based on the third request; the first platform has a first large model deployed thereon; the third interface represents an interface for requesting the first platform to call the first large model for aggregation processing; the third request is for requesting the first large model to aggregate the reports in the first report list; the third response carries a second report output by the first large model based on the model call corresponding to the third request.

[0177] In one embodiment, after each addition of one of the plurality of first reports to the first report list, the processor 2 is configured to: Determine whether the number of characters corresponding to the first report list exceeds a set third threshold to obtain a first determination result; the number of characters represents the total number of characters in one or more reports in the first report list; When the first judgment result indicates that the number of the first character is greater than the third threshold: Send a fourth request to the third interface and receive a fourth response returned by the third interface based on the fourth request; the fourth request is used to request the first large model to summarize the reports in the current first report list, and the number of characters in the summarized report is less than or equal to a set fourth threshold; the fourth response carries a third report output by the first large model based on the model call corresponding to the fourth request; the fourth threshold is less than the third threshold; Clear the first report list; Add the third report to the first report list.

[0178] It should be noted that the specific processing procedure of communication interface 1 can be understood by referring to the above method.

[0179] Of course, in practical applications, the various components in the first device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 13 The general will label all buses as Bus System 4.

[0180] The memory 3 in this embodiment is used to store various types of data to support operations in the first device. Examples of such data include any computer program used to operate on the first device.

[0181] The methods disclosed in the embodiments of this application can be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in the processor 2 or by instructions in the form of software. The processor 2 mentioned above may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly reflected as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in the memory 3. The processor 2 reads the information in the memory 3 and combines its hardware to complete the steps of the aforementioned method.

[0182] In an exemplary embodiment, the first device may be implemented by one or more ASICs, DSPs, PLDs, CPLDs, FPGAs, general-purpose processors, controllers, MCUs, microprocessors, or other electronic components to perform the aforementioned method.

[0183] It is understood that the memory 3 in the embodiments of this application can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memories described in the embodiments of this application are intended to include, but are not limited to, these and any other suitable types of memories.

[0184] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 that stores a computer program, which can be executed by the processor 2 of the first device to complete the steps described in the aforementioned code analysis method.

[0185] Computer-readable storage media can be FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM, etc.

[0186] In an exemplary embodiment, this application also provides a computer program product, including a computer program that can be executed by the processor 2 of a first device to complete the steps described in the aforementioned code analysis method.

[0187] It should be noted that terms such as "first" and "second" are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0188] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, the term "one or more" in this document refers to any combination of at least two of any one or more elements from a set of A, B, and C. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set of A, B, and C. Additionally, the term "one or more" in this document is an exemplary expression and can be replaced with any possible expressions, such as one or more, at least one, or at least one of, etc.

[0189] Furthermore, the technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.

[0190] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.

Claims

1. A code analysis method characterized by, Applied to a first device, the method includes: Multiple first code files corresponding to the first service are obtained, and the multiple first code files are split into multiple second code files; the multiple first code files are used to implement the functional requirements corresponding to the first service; the number of lines of code in the second code files is less than a set first threshold. For each of the plurality of second code files, the second code file and the plurality of case files are analyzed based on the first large model to obtain multiple analysis results, and the plurality of analysis results are summarized based on the first large model to obtain a first report corresponding to the second code file; wherein, the plurality of case files are used to test whether the functions implemented based on the plurality of first code files meet the functional requirements corresponding to the first business; Based on the first major model, the multiple first reports corresponding to the multiple second code files are summarized to obtain the second report; The second report is output to a designated first channel; the first channel is used by relevant personnel of the first business to view the second report.

2. The method according to claim 1, characterized in that, The code segmentation of the plurality of first code files includes: Based on the plurality of first code files, a first syntax tree is constructed; the first syntax tree includes multiple syntax structures. Based on one or more defined syntax structure types, the first syntax tree is subjected to syntax structure recognition to obtain multiple first syntax structures; each of the multiple first syntax structures corresponds to one of the syntax structure types. Determine the first code corresponding to each of the plurality of first syntax structures in the plurality of first code files, and output the first code completely to a blank second code file or a non-blank second code file.

3. The method according to claim 1, characterized in that, The method further includes: Obtain multiple first-case files; Each of the plurality of first case files is split into one or more second case files corresponding to each first case file; the number of cases in the second case file is less than or equal to a set second threshold. The system uploads multiple second case files corresponding to the multiple first case files to a first platform in batches, and receives multiple first identifiers returned by the first platform based on the multiple second case files; the first platform deploys the first large model; each of the multiple first identifiers is used to indicate one of the multiple second case files; Correspondingly, the analysis of the second code file and multiple case files based on the first major model includes: The second code file and the multiple second case files were analyzed based on the first major model.

4. The method according to claim 1, characterized in that, The analysis of the second code file and the multiple case files based on the first major model includes: A first request is sent to a first platform, and a first response is received from the first platform based on the first request; the first platform has a first large model deployed on it; the first request is used to request the first large model to perform code analysis on the second code file; the first response carries a first analysis result output by the first large model based on the model call corresponding to the first request; Multiple second requests are sent to the first platform, and a second response is received from the first platform based on each second request; each of the multiple second requests is used to request the first large model to perform joint analysis on the second code file and a case file; the second response carries the second analysis result output by the first large model based on the model call corresponding to the second request.

5. The method according to claim 4, characterized in that, The first request carries a second identifier corresponding to the second code file; each of the second requests carries the second identifier corresponding to the second code file and a first identifier corresponding to a case file. The second identifier is received from the first platform, and the second identifier is generated by the first platform based on the second code file uploaded by the first device; The first identifier is received from the first platform, and the first identifier is generated by the first platform based on the case file uploaded by the first device.

6. The method according to claim 1, characterized in that, Based on the first major model, multiple first reports corresponding to the multiple second code files are summarized, including: Add each of the multiple first reports to the first report list in sequence; A third request is sent to a third interface of the first platform, and a third response is received from the third interface based on the third request; the first platform has a first large model deployed thereon; the third interface represents an interface for requesting the first platform to call the first large model for aggregation processing; the third request is for requesting the first large model to aggregate the reports in the first report list; the third response carries a second report output by the first large model based on the model call corresponding to the third request.

7. The method according to claim 6, characterized in that, After each addition of one of the plurality of first reports to the first report list, the method includes: Determine whether the number of characters corresponding to the first report list exceeds a set third threshold to obtain a first determination result; the number of characters represents the total number of characters in one or more reports in the first report list; When the first determination result indicates that the number of the first character is greater than the third threshold: Send a fourth request to the third interface and receive a fourth response returned by the third interface based on the fourth request; the fourth request is used to request the first large model to summarize the reports in the current first report list, and the number of characters in the summarized report is less than or equal to a set fourth threshold; the fourth response carries a third report output by the first large model based on the model call corresponding to the fourth request; the fourth threshold is less than the third threshold; Clear the first report list; Add the third report to the first report list.

8. A first device, characterized in that, include: The processor and the memory used to store computer programs that can run on the processor. When the processor is used to run the computer program, it performs the steps of the method according to any one of claims 1 to 7.

9. A 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.

10. A computer program product, comprising a computer program, 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.