Calling link acquisition method, electronic equipment and program product
By obtaining the differences and annotations between the sub-branch code and the main branch code, generating the call link and optimizing the test cases, the problem of incomplete asynchronous call link is solved, and the fault diagnosis and code quality is improved.
Patent Information
- Application Number
- CN202510399666.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-07-25
AI Technical Summary
In the prior art, the call link caused by asynchronous calls is incomplete, and the stack trace method is difficult to capture the complete call path, which affects fault diagnosis and performance optimization.
By obtaining the differences between the sub-branch code and the main branch code, combining code annotations to obtain synchronous and asynchronous call links, generating code change reports, and ensuring code quality through test cases and coverage, optimizing test cases and dependency analysis.
It realizes complete capture of asynchronous call links, improves fault diagnosis efficiency and code quality, and ensures compliance with online standards and system stability.
Smart Images

Figure CN120371692A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of computers and the like, and particularly to a method for obtaining a call chain, an electronic device, and a program product. Background Art
[0002] With the rapid development of Internet technology, software systems have become increasingly complex, and the microservice distributed architecture has gradually become the mainstream. In this architecture, the call relationships between services become complex and diverse, including various modes such as synchronous calls, asynchronous calls, and event-driven calls. Obtaining the call chain of code is a key technology for diagnosing performance problems, locating faults, and optimizing system behavior. It can help developers understand the running logic of the system, identify performance bottlenecks, and quickly locate the root cause of problems.
[0003] In the prior art, the process of obtaining the call chain of code generally uses the stack trace method to capture synchronous function calls and direct service calls. That is, when a function is called, the call path and call order of each function are recorded to form a call chain.
[0004] However, since asynchronous calls are non-linear, it is difficult to capture the complete call path through the stack trace method, resulting in an incomplete call chain. Summary of the Invention
[0005] The present disclosure provides a method for obtaining a call chain, an electronic device, and a program product.
[0006] According to one aspect of the present disclosure, there is provided a method for obtaining a call chain, including: Obtaining sub-branch code and main-branch code related to the sub-branch code; Comparing the main-branch code and the sub-branch code to obtain the code modification points of the sub-branch code; Obtaining the code annotation of the sub-branch code; Obtaining the call chain of the code modification points from the sub-branch code according to the code annotation of the sub-branch code.
[0007] According to the method for obtaining a call chain according to at least one embodiment of the present disclosure, after obtaining the call chain of the code modification points from the sub-branch code according to the code annotation of the sub-branch code, it further includes: Obtaining the code annotation related to the call chain from the code annotation of the sub-branch code; Generating a code change report according to the code annotation related to the call chain.
[0008] According to the method for obtaining a call chain according to at least one embodiment of the present disclosure, after generating the code change report according to the code annotation related to the call chain, it further includes: Obtain test cases related to the sub-branch code; Judge whether the test cases cover comprehensively according to the code change report; If the test cases do not cover comprehensively, supplement the test cases according to the code change report to obtain the supplemented test cases.
[0009] According to the call link acquisition method of at least one embodiment of the present disclosure, after obtaining the supplemented test cases, it further includes: During the process of code testing based on the test cases or the supplemented test cases, obtain the code execution situation; Obtain the code coverage rate according to the code execution situation; Confirm whether the sub-branch code meets the online standard according to the code coverage rate.
[0010] According to the call link acquisition method of at least one embodiment of the present disclosure, the step of confirming whether the sub-branch code meets the online standard according to the code coverage rate includes: Judge whether the code coverage rate is less than the standard coverage rate; If it is not less than, it is determined that the sub-branch code meets the online standard; If it is less than, it is determined that the sub-branch code does not meet the online standard.
[0011] According to the call link acquisition method of at least one embodiment of the present disclosure, when it is confirmed that the sub-branch code does not meet the online standard according to the code coverage rate, it further includes: Perform test optimization on the sub-branch code and / or the test cases used in the process of code testing.
[0012] According to the call link acquisition method of at least one embodiment of the present disclosure, the step of obtaining test cases related to the sub-branch code includes: Obtain the inter-module dependency relationship of the sub-branch code; Generate test cases according to the inter-module dependency relationship.
[0013] According to the call link acquisition method of at least one embodiment of the present disclosure, the step of obtaining the inter-module dependency relationship of the sub-branch code includes: Control the input of the sub-branch code to the intelligent agent, so that the intelligent agent performs dependency relationship analysis on the sub-branch code based on the stored dependency knowledge related to the sub-branch code to obtain the inter-module dependency relationship of the sub-branch code.
[0014] The method for obtaining a call chain according to at least one embodiment of the present disclosure, wherein comparing the main branch code and the sub-branch code to obtain the code modification points of the sub-branch code includes: Merge the sub-branch code with the main branch code to obtain the merged code; Compare the merged code with the main branch code to obtain the code modification points of the sub-branch code.
[0015] The method for obtaining a call chain according to at least one embodiment of the present disclosure, wherein obtaining the call chain of the code modification points from the sub-branch code according to the code annotations of the sub-branch code includes: Obtain the synchronous call chain of the code modification points based on the sub-branch code; Obtain the asynchronous call chain of the code modification points based on the code annotations of the sub-branch code; Merge the synchronous call chain and the asynchronous call chain of the code modification points to obtain the call chain of the code modification points.
[0016] According to another aspect of the present disclosure, there is provided an electronic device, including: a memory storing execution instructions; and a processor that executes the execution instructions stored in the memory, such that the processor executes the method for obtaining a call chain according to any one of the embodiments of the present disclosure.
[0017] According to still another aspect of the present disclosure, there is provided a computer program product, including a computer program that, when executed by a processor, implements the method for obtaining a call chain according to any one of the embodiments of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings illustrate exemplary embodiments of the present disclosure and, together with the description thereof, are used to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are included in this specification and form a part of this specification.
[0019] Figure 1 is the flow of the method for obtaining a call chain according to an embodiment of the present disclosure Figure 1 .
[0020] Figure 2 is the flow of the method for obtaining a call chain according to an embodiment of the present disclosure Figure 2 .
[0021] Figure 3 is the flow of the method for obtaining a call chain according to an embodiment of the present disclosure Figure 3 .
[0022] Figure 4It is the flowchart of the call link acquisition method according to an embodiment of the present disclosure Figure 4 。
[0023] Figure 5 is Figure 4 the flowchart of the online judgment method in the call link acquisition method shown
[0024] Figure 6 It is the flowchart of the call link acquisition method according to an embodiment of the present disclosure Figure 5 。
[0025] Figure 7 is Figure 3 the flowchart of the test case acquisition method in the call link acquisition method shown Figure 1 。
[0026] Figure 8 is Figure 3 the flowchart of the test case acquisition method in the call link acquisition method shown Figure 2 。
[0027] Figure 9 is Figure 1 the flowchart of the change impact analysis method in the call link acquisition method shown
[0028] Figure 10 is Figure 1 the flowchart of the link acquisition method based on annotation in the call link acquisition method shown
[0029] Figure 11 It is the schematic flowchart of the call link acquisition method according to an embodiment of the present disclosure
[0030] Figure 12 It is the schematic block diagram of the structure of the call link acquisition device according to an embodiment of the present disclosure
[0031] Figure 13 It is the schematic block diagram of the structure of an electronic device according to an embodiment of the present disclosure Detailed Embodiments
[0032] The present disclosure will be further described in detail below with reference to the accompanying drawings and examples. It can be understood that the specific examples described herein are only used to explain the relevant content and do not limit the present disclosure. Additionally, it should be noted that for the sake of description, only parts related to the present disclosure are shown in the accompanying drawings
[0033] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The technical solutions of the present disclosure will be described in detail below with reference to the accompanying drawings and embodiments
[0034] Taking an online shopping system adopting a microservices architecture as an example, the online shopping system includes multiple service modules such as user service, product service, order service, payment service, inventory service, etc. Each service module implements multiple functions, and the calls between different functions may involve synchronous calls, asynchronous calls, and event-driven call patterns.
[0035] In this online shopping system, the process from a user browsing products to submitting an order and finally completing the payment may include: the user selects products and adds them to the shopping cart, which involves the product service; the user submits an order, which involves the order service; after the order is confirmed, payment is made, which involves the payment service; after the payment is successful, the system updates the inventory, which involves the inventory service; after the payment is completed, an order completion event is published to notify the order completion, which involves the order service. Among them, after the payment is completed, the online shopping system generally asynchronously calls the inventory service to update the inventory, and this operation can be carried out through a message queue, that is, the payment service sends a message to the message queue, and the inventory service asynchronously consumes the message from the message queue and executes the inventory update operation.
[0036] Since asynchronous operations are not linearly executed, that is, asynchronous operations need to achieve decoupling and communication across services through mechanisms such as message queues, and stack traces can only trace the call stack of a single service and cannot cross-trace the calls between different services, it is difficult for stack trace methods to capture the call paths across services, resulting in incomplete call chains.
[0037] For this reason, the present disclosure proposes a call chain acquisition method, an electronic device, and a program product. The present disclosure can be implemented through a code change analysis tool provided on an electronic device such as a computer or a server.
[0038] For the convenience of description and to make the technical solutions of the specific implementation manners of the present disclosure easier to understand, the technical terms involved in the present disclosure are explained as follows: The main branch code generally refers to the main branch of the code repository, which represents the most core and stable code.
[0039] The sub-branch code is an independent branch derived from the main branch code and is used for developing new functions, fixing bugs, etc.
[0040] A call chain is an abstract representation used to describe the call order and dependency relationship between code elements.
[0041] Figure 1 Shows the overall flowchart of the call chain acquisition method M100 according to an embodiment of the present disclosure. As Figure 1 The call chain acquisition method shown includes steps S110 to S140. Among them, the call chain acquisition method can be executed by an electronic device such as a computer or a server.
[0042] Specifically, Figure 1 the shown call chain acquisition method includes: Step S110, obtain the sub-branch code and the main-branch code related to the sub-branch code.
[0043] In some embodiments of the present disclosure, during the requirement testing stage of the requirement iteration process, when a user needs to understand the code change situation, code change analysis can be instructed through a code change analysis instruction. The main-branch code obtained through step S110 is usually the version of the code system related to the code change analysis instruction that is currently stable and available for the production environment; the sub-branch code obtained through step S110 is usually a sub-branch code created based on the main-branch code of the code system to implement the requirements corresponding to the code change analysis instruction. This sub-branch code can be obtained by creating a new branch on the main-branch code of a certain version; it can also be obtained by modifying and / or deleting some code in the main-branch code of a certain version. The main-branch code and the sub-branch code belong to the same code repository, and they represent different development progress and code states.
[0044] The main-branch code on which the sub-branch code depends can be the same as the main-branch code obtained through step S110, or different from the main-branch code obtained through step S110; when they are different, the main-branch code has iterated during the generation process of the sub-branch code. For example: when dealing with the requirements corresponding to the sub-branch code, obtain the main-branch code of version V1.0, and generate the sub-branch code based on the main-branch code of version V1.0; however, during the generation process of the sub-branch code, the main-branch code has iterated to version V2.0 based on other requirements. At this time, the main-branch code obtained through step S110 is the main-branch code of version V2.0.
[0045] Step S120, compare the main-branch code and the sub-branch code to obtain the code modification points of the sub-branch code.
[0046] In some embodiments of the present disclosure, the code modification points obtained through step S120 are the specific code positions that are modified, added, or deleted during the code change process, and they can be a variable, a function, a class, or a module, etc. The code modification points of the sub-branch code obtained through step S120 are the differences between the sub-branch code and the main-branch code.
[0047] Step S130, obtain the code annotations of the sub-branch code.
[0048] In some embodiments of the present disclosure, which code annotations of the sub-branch code are obtained through step S130 can be preset; for example, the element type can be preset, and the code annotations obtained through step S130 are the code annotations of the elements related to the element type.
[0049] Through step S130, code annotations can be obtained from a preset annotation library. The code annotations in the preset annotation library can be manually edited or generated by an annotation generation method, etc. The code annotations obtained through step S130 include asynchronous operation-related annotations, which mark which methods or operations in the code are executed asynchronously; in addition to the asynchronous operation-related annotations, the code annotations obtained through step S130 can also include code annotations for elements such as interfaces, methods, and classes.
[0050] When generated by an annotation generation method, the specific process may include: performing lexical analysis, syntax analysis, semantic analysis, etc. on the sub-branch code for code structure parsing to obtain the code structure; obtaining preset annotation rules, which can be defined according to different programming languages and comment styles. For example, for the Java language, the preset annotation rules need to follow the comment specifications of Javadoc, and for the Python language, the preset annotation rules need to follow the comment specifications of docstring; identifying the elements in the sub-branch code that need to be annotated, such as functions and methods, classes and interfaces, variables and fields, etc.; generating code annotations for the elements that need to be annotated according to the code structure and the preset annotation rules.
[0051] Step S140, obtaining the call chain of the code modification point from the sub-branch code according to the code annotations of the sub-branch code.
[0052] In some embodiments of the present disclosure, the call chain obtained through step S140 may include a synchronous call chain and an asynchronous call chain.
[0053] For the call chain acquisition method provided by the present disclosure, since the code annotations include asynchronous operation-related annotations, the call chain obtained according to the code annotations includes an asynchronous call chain, thus making up for the deficiency of the stack trace method in dealing with asynchronous operations. The call chain acquisition method solves the problem in the prior art that since asynchronous calls are non-linear, it is difficult to capture the complete call path through the stack trace method, resulting in an incomplete call chain.
[0054] Furthermore, for the call chain acquisition method provided by the present disclosure, after step S140, it may further include steps S150 to S160 as Figure 2 shown.
[0055] Step S150, obtaining the call chain-related code annotations from the code annotations of the sub-branch code.
[0056] In some embodiments of the present disclosure, step S150 may use the call chain obtained through step S140 to filter the code annotations of the sub-branch code to obtain the call chain-related code annotations.
[0057] Step S160: Generate a code change report based on the code annotations related to the call chain.
[0058] In some embodiments of the present disclosure, step S160 may generate a code change report based on the call chain-related code annotations according to a report template, report generation rules, etc. The code change report in step S160 may include: change overview, modified content, specific code differences, impact analysis, etc.
[0059] After generating the code change report through step S160, the code change report may also be formatted, such as converting the code change report into HTML or PDF format, etc., to improve the readability, maintainability, and collaboration efficiency of the code change report, and reduce errors caused by format problems.
[0060] By performing steps S150 to S160 to generate the corresponding code change report after obtaining the call chain, the code change report can help users clearly identify the scope of influence of code changes and improve the test efficiency.
[0061] Furthermore, for the call chain acquisition method provided by the present disclosure, after step S160, it may further include steps S170 to S190 as shown in Figure 3 the following.
[0062] Step S170: Obtain test cases related to the sub-branch code.
[0063] In some embodiments of the present disclosure, the test cases obtained through step S170 are generally the test cases generated according to the requirements document and the test plan during the test design process; the test cases can be written by testers or generated using a test case generation method. Among them, when using the test case generation method to generate test cases, test cases for the sub-branch code can be automatically generated according to preset rules and templates.
[0064] The test cases obtained through step S170 usually include: description of the test case, input data, expected result, execution steps, test environment, etc.
[0065] Step S180: Determine whether the test cases cover comprehensively according to the code change report.
[0066] In some embodiments of the present disclosure, step S180 may include: obtaining code change points from a code change report, including one or more of newly added code, modified code, and deleted code; comparing test cases with the change points to check whether each change point corresponds to at least one test case; if each change point corresponds to at least one test case, it indicates that the test cases are comprehensively covered and no operation needs to be performed on the test cases; if one or several change points are not covered by corresponding test cases, it indicates that the test cases are not comprehensively covered, and step S190 is executed.
[0067] In particular, to ensure that test cases can cover all possible situations, in addition to the above judgment of whether each change point corresponds to at least one test case, step S180 may further include a judgment on the diversity of test cases (such as boundary conditions, abnormal situations, etc.). The diversity judgment mainly focuses on the differences between different test cases and their coverage of various dimensions, and determines the coverage of different types of inputs, boundary situations, abnormal situations, etc. The diversity judgment can be made from several aspects such as the diversity of input data, the diversity of functional scenarios, the diversity of control flows, the diversity of time and order, the diversity of resources and environments, and the diversity of user permissions and roles.
[0068] Step S190: Supplement the test cases according to the code change report to obtain the supplemented test cases.
[0069] In some embodiments of the present disclosure, the specific situation of the uncovered change points can be determined based on the code change report through step 190, and new test cases can be designed for the uncovered change points according to the specific situation, and the test cases obtained through step S170 can be supplemented with the new test cases to obtain the supplemented test cases.
[0070] When it is determined through step S180 that the test cases are not comprehensively covered, a relevant analysis report can also be generated to illustrate the omission of the test cases, which is convenient for users to analyze whether the supplement of the test cases is reasonable and improves the processing efficiency of the test cases.
[0071] By supplementing the test cases through steps S170 to S190 when the test cases are not comprehensively covered, it can ensure that all code changes are fully tested, thereby improving software quality and reducing potential defects and problems.
[0072] Furthermore, for the call chain acquisition method provided by the present disclosure, after step S190, it may further include steps S200 to S220 as Figure 4 shown.
[0073] Step S200: Obtain the code execution situation during the process of code testing based on the test cases or the supplemented test cases.
[0074] In some embodiments of the present disclosure, after determining the comprehensiveness of the test cases through step S180, when the test cases are comprehensive, the test cases obtained through step S170 can be directly used for code testing; when the test cases are not comprehensive, the supplemented test cases obtained through step S190 can be used for code testing. During the process of code testing based on the test cases or the supplemented test cases, step S200 can obtain the code execution situation during the code testing process through methods such as code instrumentation and logging. The code execution situation describes which codes in the sub-branch code are triggered during the code testing process.
[0075] Step S210, obtaining the code coverage rate according to the code execution situation.
[0076] In some embodiments of the present disclosure, the code execution situation can be analyzed through step S210 to obtain the code coverage rate; the code coverage rate can be one or more types such as statement coverage rate (the proportion of executed code statements in the total code statements during the code testing process), branch coverage rate (the proportion of the true and false branches of the judgment conditions in the executed code during the code testing process in the total branches), function coverage rate (the proportion of called functions in the total functions during the code testing process), path coverage rate (the proportion of executed paths in the total paths during the code testing process), etc. The specific type of the code coverage rate obtained through step S210 can be preset as needed.
[0077] Step S220, confirming whether the sub-branch code meets the online standard according to the code coverage rate.
[0078] In some embodiments of the present disclosure, step S220 can determine whether the sub-branch code meets the online standard according to the size of the code coverage rate; in particular, during the process of determining whether the sub-branch code meets the online standard, in addition to the code coverage rate, multiple dimensions such as code quality, regression test results, and abnormal scenario coverage can be comprehensively judged. When the code coverage rate includes multiple types of code coverage rates, the size of different types of code coverage rates can be comprehensively determined to determine whether the sub-branch code meets the online standard.
[0079] Controlling whether the sub-branch code goes online based on the code coverage rate through steps S200 to S220 can ensure that the sub-branch code is fully tested, improve the code quality, and reduce the risks after going online.
[0080] Regarding step S220, in some embodiments of the present disclosure, it may include steps S221 to S223 as Figure 5 shown.
[0081] Step S221: Determine whether the code coverage rate is less than the standard coverage rate.
[0082] In some embodiments of the present disclosure, different types of projects may have different requirements for code coverage rates, that is, the standard coverage rates may be different. For example: for safety-critical projects, a relatively high standard coverage rate can be set; for rapidly iterating Internet projects, the standard coverage rate can be appropriately reduced, but generally should not be less than 70%. Usually, the standard coverage rate is set between 80% - 90%. This standard coverage rate can ensure that most of the code has been executed, and some boundary and exception situations can also be covered.
[0083] In step S221, the standard coverage rate can be fixed; it can also be dynamically adjusted as the project develops and matures. For example, in the initial stage of the project, in order to quickly verify ideas and functions, a relatively low standard coverage rate can be set; as the project develops, the standard coverage rate can be gradually increased.
[0084] When it is determined through step S221 that the code coverage rate is not less than the standard coverage rate, execute step S222; when it is determined through step S221 that the code coverage rate is less than the standard coverage rate, execute step S223.
[0085] Step S222: Determine that the sub-branch code meets the online standard.
[0086] In some embodiments of the present disclosure, when it is determined through step S222 that the sub-branch code meets the online standard, relevant online operations can be performed on the sub-branch code, such as final review and confirmation, formulating an online plan, notifying relevant personnel, performing online operations, monitoring and emergency handling, etc.
[0087] Step S223: Determine that the sub-branch code does not meet the online standard.
[0088] In some embodiments of the present disclosure, when it is determined through step S223 that the sub-branch code does not meet the online standard, a series of measures can be taken to find and solve the problems to ensure that the sub-branch code can ultimately meet the online standard.
[0089] Steps S221 to S223 can efficiently determine whether the sub-branch code meets the online standard based on the standard coverage rate.
[0090] Furthermore, for the call link acquisition method provided by the present disclosure, when it is determined through step S220 that the sub-branch code does not meet the online standard, it may further include step S230 as Figure 6 shown.
[0091] Step S230: Optimize the testing of the sub-branch code and / or the test cases used in the process of code testing.
[0092] In some embodiments of the present disclosure, when it is determined that the sub-branch code does not meet the online standard, step S230 may analyze in detail the reasons for the insufficient code coverage rate to obtain an analysis result; and perform test optimization on the sub-branch code and / or the test cases used in the code testing process according to the analysis result, so as to improve the code coverage rate. Among them, the process of analyzing in detail the reasons for the insufficient code coverage rate may include: deeply analyzing the code coverage rate to determine whether the overall code coverage rate fails to meet the standard, or one or more items fail to meet the standard, so as to obtain the reasons for non-compliance; locating the specific areas with low coverage rate in the sub-branch code according to the reasons for non-compliance; and according to the specific areas with low coverage rate, analyzing the reasons for non-coverage, whether the test case design is incomplete, missing some boundary conditions or special cases, or the code logic is too complex to be covered by the existing test cases, or there is dead code in the code, that is, code that will never be executed.
[0093] When the reason for the insufficient code coverage rate is that the test case design is incomplete, step S230 may specifically perform test optimization on the test cases used in the code testing process, such as supplementing the missing test scenarios in the test cases used in the code testing process, optimizing the test data to ensure that the test data can cover various possible input situations, adjusting the test strategy, etc.; when the reason for the insufficient code coverage rate is that the code logic is too complex, step S230 may specifically perform test optimization on the sub-branch code, such as simplifying the code with complex logic in the sub-branch code, etc.; when the reason for the insufficient code coverage rate is dead code, step S230 may specifically perform test optimization on the sub-branch code, such as removing the dead code from the sub-branch code, etc.
[0094] After performing test optimization through step S230, the code testing and code coverage rate analysis process may be executed again based on the test cases after test optimization and / or the sub-branch code after test optimization until the final sub-branch code meets the online standard.
[0095] By performing test optimization through step S230 when it is determined that the sub-branch code does not meet the online standard, the quality of the sub-branch code and / or the test cases can be improved, so that the final sub-branch code meets the online standard.
[0096] Regarding step S170, in some embodiments of the present disclosure, it may include steps S171 to S172 as Figure 7 shown.
[0097] Step S171, obtaining the inter-module dependency relationship of the sub-branch code.
[0098] In some embodiments of the present disclosure, the inter-module dependency relationship obtained through step S171 can represent the relationship that the modules (or components) of the sub-branch code depend on the services or data provided by other modules during the function implementation process. Step S171 can obtain the inter-module dependency relationship by performing static analysis on the sub-branch code.
[0099] Step S172, generate test cases according to the inter-module dependency relationship.
[0100] In some embodiments of the present disclosure, step S172 can design test cases for normal situations, abnormal situations, boundary situations, etc. according to the inter-module dependency relationship.
[0101] Steps S171 to S172 generate test cases according to the inter-module dependency relationship, which can more comprehensively and effectively detect each module of the sub-branch code, ensure that each module can work as expected during collaboration, and improve the comprehensiveness of testing.
[0102] Regarding step S171, in some embodiments of the present disclosure, it can be replaced with the following steps as Figure 8 shown: Control the input of the sub-branch code to the intelligent agent, so that the intelligent agent performs dependency relationship analysis on the sub-branch code based on the stored dependency knowledge related to the sub-branch code, and obtains the inter-module dependency relationship of the sub-branch code.
[0103] In some embodiments of the present disclosure, the intelligent agent in this step is an intelligent system capable of perceiving, understanding, and processing the inter-module dependency relationships of the sub-branch code; the intelligent agent is associated with the dependency knowledge, and the intelligent agent can specifically be a question-and-answer intelligent agent, which can control the intelligent agent to output the dependency relationship based on the instruction guiding the intelligent agent to analyze the dependency relationship, and the dependency relationship output by the intelligent agent can be represented by the dependent party and the dependent-on party; in particular, for the convenience of the user to check whether the dependency relationship output by the intelligent agent is correct, the intelligent agent can also output information such as the dependency knowledge used in the process of analyzing the dependency relationship while outputting the dependency relationship.
[0104] The intelligent agent of the present disclosure can be constructed based on existing deep learning models (such as ChatGPT, etc.).
[0105] The dependency knowledge used by the intelligent agent can be the dependency relationship obtained by manually sorting out the first-level modules (i.e., the top-level or most core functional modules in the software system), and this dependency relationship can be finally stored as a file that can maintain consistency between different platforms, such as a file in the PDF format, etc.
[0106] Through this step, dependency analysis is performed based on the agent, which can not only analyze the direct dependencies of modules, but also analyze complex dependencies across services, modules, and asynchronous operations, so as to comprehensively and accurately capture the inter-module dependency relationships.
[0107] Dependency analysis through the agent can not only be used for test case generation, but also during the design of product requirement documents and the initial review of requirements. By analyzing dependencies through the agent, the efficiency and accuracy of requirement analysis can be significantly improved, and the maintainability of product requirement documents can be enhanced. It can also be used from the end of requirement review to the stages of R & D design and test design. By using the agent to obtain the dependencies of the requirement change modules, the impacts of requirement changes can be comprehensively identified, the collaboration between R & D and testing can be enhanced, test scenarios can be enriched and design schemes can be optimized. At the same time, the accuracy, traceability, and flexibility of design documents and test plans can be improved, which helps to speed up the development and testing progress, ensure that requirement changes are processed in a timely and accurate manner, and improve the overall quality and efficiency of software requirement iteration.
[0108] Step S120 can directly determine the code modification points between the sub-branch code and the main-branch code. In particular, regarding step S120, in some embodiments of the present disclosure, it may include steps S121 to S122 as Figure 9 shown.
[0109] Step S121, merge the sub-branch code and the main-branch code to obtain the merged code.
[0110] In some embodiments of the present disclosure, the process of merging the sub-branch code and the main-branch code through step S121 may include: determining the target branch (i.e., the branch to which the code is desired to be merged) and the source branch (i.e., the branch from which the code is desired to be merged) from the sub-branch code and the main-branch code; and merging the code of the source branch into the code of the target branch.
[0111] In particular, during the process of merging the sub-branch code and the main-branch code, conflicts may occur, such as different changes being made to the same line of code in the two branches. At this time, the code related to the conflict can be marked to prompt the user to resolve these conflicts, and after resolution, the merge process can be executed again based on the resolved code.
[0112] Before merging the sub-branch code and the main-branch code through step S121, branches or backups can also be created for the sub-branch code and the main-branch code to prevent unexpected problems during the merge process.
[0113] Step S122, compare the merged code with the main-branch code to obtain the code modification points of the sub-branch code.
[0114] By synchronizing the main branch code through steps S121 to S122, it is possible to solve the problem that the sub-branch code is based on a certain version of the main branch code when it is created, and as the main branch code changes during multiple requirement iterations, the sub-branch code fails to be synchronized with the latest main branch code in a timely manner, resulting in an obvious difference between the sub-branch code and the current main branch code. Directly performing code change impact analysis will introduce iterative changes in the main branch code, leading to inaccurate call links.
[0115] Regarding step S140, in some embodiments of the present disclosure, it may include steps S141 to S143 as Figure 10 shown.
[0116] Step S141, obtaining the synchronous call link of the code modification point based on the sub-branch code.
[0117] In some embodiments of the present disclosure, step S141 may use the code modification point as the starting point, continuously traverse the affected classes and methods until the uppermost control layer is found, and obtain the synchronous call link.
[0118] Step S142, obtaining the asynchronous call link of the code modification point based on the code annotations of the sub-branch code.
[0119] In some embodiments of the present disclosure, step S142 may obtain the asynchronous call link of the code modification point based on the asynchronous operation-related annotations in the code annotations of the sub-branch code.
[0120] Step S143, merging the synchronous call link and the asynchronous call link of the code modification point to obtain the call link of the code modification point.
[0121] In some embodiments of the present disclosure, the process of merging the synchronous call link and the asynchronous call link through step S143 may include: formatting the synchronous call link and the asynchronous call link of the code modification point to obtain the synchronous call link and the asynchronous call link represented by a unified data structure; respectively obtaining the dependency relationships of the synchronous call link and the asynchronous call link represented by the unified data structure; and integrating the synchronous call link and the asynchronous call link represented by the unified data structure according to the dependency relationship to obtain the call link of the code modification point.
[0122] Steps S141 to S143 can identify whether an asynchronous call is triggered by a certain synchronous call and correctly connect it by merging the synchronous call link and the asynchronous call link, supplement the missing part of the call link, and ensure an accurate call link.
[0123] The call chain acquisition method provided by the present disclosure can be applied in the iterative process of demand projects in software development and version control, ensuring that the design and development of multiple links meet high-quality standards, and ultimately delivering a stable, efficient, and easily maintainable system.
[0124] Specifically, in the requirements review and design stage of the demand project iteration, the call chain acquisition method can specifically perform dependency analysis through an agent as the input for solution design and test design, improving the quality of solution design and test design; in the demand testing stage of the demand project iteration, the call chain acquisition method can complement test cases based on the acquired call chain analysis, ensuring complete coverage of test scenarios without omission and improving test quality; before the code goes online after the demand testing of the demand project iteration is completed, the call chain acquisition method can introduce a coverage analysis process, determine whether the sub-branch code coverage meets the standard based on the coverage rate, and thus control the checkpoints and online quality, improving the quality of the finally online code. The above process covers the entire demand iteration cycle.
[0125] Figure 11 An exemplary flowchart implemented based on the call chain acquisition method of the present disclosure is shown.
[0126] Figure 11 In the shown flowchart, taking the code related to credit approval as an example, the call chain acquisition process may include: Step S310, obtaining the sub-branch code of credit approval and the main-branch code of the sub-branch code.
[0127] In some embodiments of the present disclosure, the credit approval process may include: obtaining basic user information; evaluating the user's credit risk; calculating the loan amount; generating an approval result. The requirement for this iteration wants to improve the process of evaluating the user's credit risk. In this case, the main-branch code obtained through step S310 is the code including the credit approval process currently running in the production environment; the sub-branch code obtained through step S310 may be the code after improving the process of evaluating the user's credit risk.
[0128] Step S320, comparing the main-branch code and the sub-branch code to obtain the code modification points of the sub-branch code.
[0129] In some embodiments of the present disclosure, based on the above example, the code modification points obtained through step S320 may be: introducing variables, functions, classes, or modules related to asynchronously calling an external credit risk assessment service, and modifying the calculation of the credit risk score based on the internal credit score to variables, functions, classes, or modules related to combining the external assessment score and the internal credit score to calculate the credit risk score.
[0130] When comparing the main branch code with the sub-branch code in step S320, the main branch code and the sub-branch code can be directly compared. In particular, to prevent changes generated by iterating the main branch code from being introduced into the call chain, resulting in an inaccurate call chain, the main branch code and the sub-branch code can also be merged to obtain the merged code first, and then the merged code and the main branch code can be compared.
[0131] When comparing the main branch code and the sub-branch code in step S320, the Abstract Syntax Tree (AST) can be used to accurately identify method-level changes and improve the comparison accuracy.
[0132] Step S330: Obtain the code annotations of the sub-branch code.
[0133] In some embodiments of the present disclosure, the code annotations obtained through step S330 include annotations related to asynchronous operations, that is, code annotations related to asynchronously calling an external credit risk assessment service. Code annotations can help quickly understand the logic introduced by code change points and also play a key role in the code review and debugging phases. Especially in scenarios involving external calls, clear code annotations can improve the efficiency of problem troubleshooting and reduce unnecessary costs.
[0134] After obtaining the code annotations of the sub-branch code through step S330, to ensure the integrity and accuracy of the code annotations, the code annotations can also be automatically scanned to identify missing code annotations or incorrect code annotations that may affect the call chain, obtain the identification results, and adjust the code annotations according to the identification results, such as supplementing missing code annotations in the code annotations and modifying incorrect code annotations in the code annotations.
[0135] Step S340: Obtain the call chain of the code modification point from the sub-branch code according to the code annotations of the sub-branch code.
[0136] In some embodiments of the present disclosure, the call chain obtained through step S340 includes synchronous calls determined based on the sub-branch code and asynchronous calls determined based on the code annotations.
[0137] Through steps S310 to S340, not only can the code change points be accurately located, but also the call chain of the code modification point can help the development team more efficiently understand the scope of influence of the code changes, ensuring that the code modification point does not interfere with other business logics. At the same time, the identification of the code modification point can also provide clear focus points for the testing phase, optimize the test plan, and improve the test coverage.
[0138] Based on any of the above embodiments, the present disclosure also provides a call chain acquisition device.
[0139] Figure 12 It is a structural schematic diagram of a call link acquisition device according to an embodiment of the present disclosure.
[0140] As Figure 12 shown, the call link acquisition device includes: A code acquisition module 110, configured to acquire sub-branch code and main-branch code related to the sub-branch code.
[0141] A code comparison module 120, configured to compare the main-branch code and the sub-branch code to obtain code modification points of the sub-branch code.
[0142] An annotation acquisition module 130, configured to acquire code annotations of the sub-branch code.
[0143] A link acquisition module 140, configured to obtain a call link of the code modification point from the sub-branch code according to the code annotations of the sub-branch code.
[0144] The above call link acquisition device may be in the form of computer software, and each module of the above call link acquisition device may be implemented by computer software modules.
[0145] For the specific implementation process of the functions and roles of each module in the above device, please refer to the implementation process of the corresponding steps in the above method for details, and will not be elaborated here.
[0146] The execution subject of the call link acquisition method in the specific embodiment of the present disclosure may be an electronic device such as a computer or a server.
[0147] Therefore, based on any of the above embodiments, the present disclosure further provides an electronic device, and the electronic device may execute the call link acquisition method of any of the above embodiments described in the present disclosure.
[0148] Figure 13 It is a structural schematic diagram of an electronic device 1000 according to an embodiment of the present disclosure.
[0149] The hardware structure of the electronic device 1000 may be implemented by using a bus architecture. The bus architecture may include any number of interconnected buses and bridges, depending on the specific application of the hardware and the overall design constraints. The bus 1100 connects various circuits including one or more processors 1200, a memory 1300, and / or hardware modules together. The bus 1100 may also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc.
[0150] The bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one connection line is used in this figure, but it does not mean that there is only one bus or one type of bus.
[0151] The present disclosure also provides a readable storage medium storing a computer program, which when executed by a processor is used to implement the above method. The "readable storage medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples of the readable storage medium include the following: an electrical connection part (electronic device) having one or more wirings, a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.
[0152] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, the processes or functions of the present disclosure are executed in whole or in part.
[0153] The computer program or instructions can be stored in a readable storage medium, or transmitted from one readable storage medium to another. For example, the computer program or instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired or wireless manner. The readable storage medium can be any available medium that can be accessed, or a data storage device such as a server or data center integrating one or more available mediums. The available medium can be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it can also be an optical medium, such as a digital video disc; it can also be a semiconductor medium, such as a solid state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or can include both volatile and non-volatile types of storage media.
[0154] Those skilled in the art should understand that the embodiments of the present disclosure can be provided as a method, a system, or a computer program product. Therefore, the present disclosure can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present disclosure can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0155] The present disclosure is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the present disclosure. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for realizing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.
[0156] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that realizes the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.
[0157] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for realizing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.
[0158] In the description of this specification, the description with reference to terms such as "one embodiment / way", "some embodiments / ways", "example", "specific example", or "some examples" means that the specific features, structures, or characteristics described in connection with the embodiment / way or example are included in at least one embodiment / way or example of the present disclosure. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment / way or example. Moreover, the specific features, structures, or characteristics described can be combined in a suitable manner in any one or more embodiments / ways or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments / ways or examples described in this specification and the features of different embodiments / ways or examples.
[0159] In addition, the terms "first" and "second" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "a plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.
[0160] Those skilled in the art should understand that the above embodiments are merely for clearly explaining the present disclosure and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications can be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.
Claims
1. A method for obtaining a call link, characterized in that Including: Obtain the sub-branch code and the main-branch code related to the sub-branch code; Compare the main-branch code and the sub-branch code to obtain the code modification points of the sub-branch code; Obtain the code annotations of the sub-branch code; And Obtain the call chain of the code modification points from the sub-branch code according to the code annotations of the sub-branch code.
2. The call link acquisition method according to claim 1, wherein After obtaining the call chain of the code modification points from the sub-branch code according to the code annotations of the sub-branch code, it further includes: Obtain the code annotations related to the call chain from the code annotations of the sub-branch code; and Generate a code change report according to the code annotations related to the call chain.
3. The call link acquisition method according to claim 2, wherein After generating the code change report according to the code annotations related to the call chain, it further includes: Obtain the test cases related to the sub-branch code; Judge whether the test cases are comprehensively covered according to the code change report; and If the test cases are not comprehensively covered, supplement the test cases according to the code change report to obtain the supplemented test cases.
4. The method for obtaining a call link according to claim 3, wherein After obtaining the supplemented test cases, it further includes: During the code testing based on the test cases or the supplemented test cases, obtain the code execution situation; Obtain the code coverage rate according to the code execution situation; and Confirm whether the sub-branch code meets the online standard according to the code coverage rate.
5. The call link acquisition method according to claim 3, wherein The obtaining the test cases related to the sub-branch code includes: Obtain the inter-module dependency relationship of the sub-branch code; and Generate test cases according to the inter-module dependency relationship.
6. The call link acquisition method according to claim 5, wherein The obtaining the inter-module dependency relationship of the sub-branch code includes: Control the input of the sub-branch code to the intelligent agent, so that the intelligent agent performs dependency relationship analysis on the sub-branch code based on the stored dependency knowledge related to the sub-branch code to obtain the inter-module dependency relationship of the sub-branch code.
7. The call link acquisition method according to any one of claims 1 to 6, characterized in that, The comparing the main-branch code and the sub-branch code to obtain the code modification points of the sub-branch code includes: Merge the sub-branch code and the main-branch code to obtain the merged code; and Compare the merged code with the main-branch code to obtain the code modification points of the sub-branch code.
8. The method for obtaining a call link according to any one of claims 1 to 6, characterized in that The obtaining the call chain of the code modification points from the sub-branch code according to the code annotations of the sub-branch code includes: Obtain the synchronous call chain of the code modification points based on the sub-branch code; Obtain the asynchronous call chain of the code modification points based on the code annotations of the sub-branch code; and Merge the synchronous call chain and the asynchronous call chain of the code modification points to obtain the call chain of the code modification points.
9. An electronic device, characterized in that, Including: A memory that stores execution instructions; And A processor that executes the execution instructions stored in the memory, so that the processor executes the call chain obtaining method according to any one of claims 1 to 8.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the call chain obtaining method according to any one of claims 1 to 8.