Code analysis method, system, device, electronic device and storage medium
By determining the calling links of financial product codes and submitting record data, and performing hierarchical analysis, the problem of low accuracy and low efficiency in code change analysis is solved, and the impact of code changes is quickly located and accurately assessed.
Patent Information
- Application Number
- CN202311052848.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-18
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-08-18
AI Technical Summary
Existing code change analysis methods have problems with limited accuracy and low efficiency when updating and iterating financial products. Especially when integrating financial systems with large-scale products, manual evaluation using code analysis tools of different coding types is required multiple times. , resulting in excessive consumption of time and energy.
By determining the call link data of the basic code data, obtain the submission record data of the data to be analyzed, determine the change call link data based on these data, and perform hierarchical analysis to quickly locate the scope and functional impact of code changes and improve code changes. Analytical accuracy and efficiency.
It achieves accurate analysis of code changes, promptly locates changes and functional impacts, improves the efficiency of code analysis, and reduces the time and energy consumption of manual evaluation.
Smart Images

Figure CN117009240B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a code analysis method, system, device, electronic device and storage medium. Background Art
[0002] When financial products are updated, the same basic code is used by multiple products. When the code of any product is updated, the basic code may be changed, which will affect the use of other products that use the basic code. Therefore, when the product code is updated, it is necessary to analyze the code changes according to the products whose codes are updated and evaluate the impact involved.
[0003] Existing code change analysis methods usually use code analysis tools for manual evaluation. However, the current code analysis tools have limited analysis accuracy when used for financial systems that integrate large-scale products, and require multiple use of different code analysis tools corresponding to different coding types to perform code analysis separately, which is time-consuming and labor-intensive. Since it is manually executed, it takes more time and energy, increases the workload of developers and testers, and affects the efficiency of code analysis. Summary of the invention
[0004] In view of the above problems, the embodiments of the present application provide a code analysis method, system, device, electronic device and storage medium to improve the problem of limited accuracy and low efficiency of code modification analysis results in related technologies.
[0005] According to one aspect of an embodiment of the present application, a code analysis method is provided, the method comprising:
[0006] Determine call link data of basic code data;
[0007] Acquire submission record data of the data to be analyzed, and determine the change call link data corresponding to the data to be analyzed based on the submission record data of the data to be analyzed and the call link data;
[0008] Based on the call link data, the changed call link data is hierarchically analyzed to obtain a change result of the data to be analyzed, and the change result is displayed.
[0009] According to one aspect of an embodiment of the present application, a code analysis system is provided, the code analysis system comprising a service end and a code server;
[0010] The server is used to determine the call link data of the basic code data, access the code server, obtain the submission record data of the data to be analyzed, determine the changed call link data corresponding to the data to be analyzed based on the submission record data of the data to be analyzed and the call link data, perform a hierarchical analysis on the changed call link data based on the call link data, obtain the change result of the data to be analyzed, and display the change result.
[0011] According to one aspect of an embodiment of the present application, a code analysis device is provided, the device comprising:
[0012] A link generation module, used to determine call link data of basic code data;
[0013] A branch analysis module, used to obtain submission record data of the data to be analyzed, and determine the change call link data corresponding to the data to be analyzed based on the submission record data of the data to be analyzed and the call link data;
[0014] The change analysis module is used to perform hierarchical analysis on the changed call link data based on the call link data, obtain the change result of the data to be analyzed, and display the change result.
[0015] According to one aspect of an embodiment of the present application, an electronic device is provided, including a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to perform the operations in the above-mentioned code analysis method.
[0016] According to one aspect of an embodiment of the present application, a storage medium is provided, wherein the storage medium stores a plurality of instructions, wherein the instructions are suitable for loading by a processor to execute the steps in the above-mentioned code analysis method.
[0017] The embodiments of the present application provide a code analysis method, system, device, electronic device and storage medium, which relate to the field of computer technology. The method determines the call link data of basic code data; obtains the submission record data of the data to be analyzed, and determines the change call link data corresponding to the data to be analyzed based on the submission record data of the data to be analyzed and the call link data; based on the call link data, hierarchical analysis is performed on the change call link data to obtain the change result of the data to be analyzed, and the change result is displayed; the embodiments of the present application perform link analysis on the basic code and the submission record data of the data to be analyzed, so as to timely and accurately locate the change between the data to be analyzed and the basic code data, and through hierarchical analysis, quickly locate the impact of each submission record data on the relevant product functions of the current application basic code data, so as to judge whether functional regression is needed, improve the accuracy of the code change analysis results, and improve the efficiency of code analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 It is a structural diagram of a code analysis system provided in an embodiment of the present application;
[0020] Figure 2 It is a schematic diagram of the structure of the server provided in the embodiment of the present application;
[0021] Figure 3 It is a flowchart of the code analysis method provided in the embodiment of the present application;
[0022] Figure 4 It is a flowchart of the hierarchical analysis method provided in the embodiment of the present application;
[0023] Figure 5 It is a flowchart of a method for obtaining call link data provided in an embodiment of the present application;
[0024] Figure 6 is a schematic diagram of a call linked list provided in an embodiment of the present application;
[0025] Figure 7 It is a flowchart of a method for obtaining submission record data provided in an embodiment of the present application;
[0026] Figure 8 It is a flowchart of a method for determining change call link data provided by an embodiment of the present application;
[0027] Fig. 9 is a block diagram of a code analysis device provided in an embodiment of the present application;
[0028] Fig.10 It is a structural diagram of an electronic device provided by an embodiment of the present application and suitable for implementing the embodiment of the present application. DETAILED DESCRIPTION
[0029] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0030] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0031] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0032] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0033] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0034] like Figure 1 As shown, Figure 1 is a schematic diagram of the code analysis system architecture provided in an embodiment of the present application, wherein the code analysis system shown includes a service end and a code server.
[0035] The server side can be an independent server or a server cluster consisting of multiple servers. The server side includes but is not limited to application servers, hardware servers, virtual servers, cloud servers, etc.
[0036] The code server is used to store code files, wherein the code server can also be an independent server or a server cluster composed of multiple servers. In some embodiments, the code server can be set up on the server side; in some embodiments, the code server can be set up in another server different from the server side, and exchange data with the server side through the network.
[0037] Exemplarily, taking the example that the code server is set in another server different from the server, a communication connection is established between the server and the code server through the network.
[0038] exist Figure 1 When the code analysis system shown performs code analysis, the server determines the call link data of the basic code data, accesses the code server, obtains the submission record data of the data to be analyzed, determines the changed call link data corresponding to the data to be analyzed based on the submission record data and the call link data of the data to be analyzed, and performs a hierarchical analysis on the changed call link data based on the call link data to obtain the change result of the data to be analyzed and display the change result.
[0039] Optionally, the network may be any type of wired or wireless network, or a combination thereof. As examples only, the network may include a wired network, a wireless network, a fiber optic network, a telecommunications network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a wide area network (WAN), a public switched telephone network (PSTN), a Bluetooth network, a ZigBee network, or a near field communication (NFC) network, or any combination thereof.
[0040] In some embodiments, Figure 2 As shown, Figure 2 It is a structural diagram of the server provided by the embodiment of the present application, and the server shown includes a front-end, an infrastructure application service layer and an infrastructure core service layer. Among them, the front-end is implemented based on the micro-front-end framework of VUEjs, runs in the Java virtual machine, and interacts with the infrastructure application service layer (am-application) to obtain back-end data for displaying the change results; the infrastructure application service layer is implemented based on the Spring boot open source framework of Java, runs in the Java virtual machine, and interacts with the infrastructure core service layer (am-core) to obtain the link parsing results, and selects data to return to the front-end display according to the request needs; the infrastructure core service layer is implemented based on the Spring boot open source framework of Java, runs in the Java virtual machine, and parses the link change data according to the call link data of the basic code data and the submission record data of the data to be analyzed, and returns the change results to the upper infrastructure application service layer.
[0041] Specifically, the code analysis method includes the steps of:
[0042] (1) The user triggers a code acquisition request through the front end;
[0043] (2) The infrastructure application service layer responds to the code acquisition request sent by the front end, accesses the code server, obtains the image file corresponding to the code acquisition request, compiles the image file, obtains basic code data, and initiates a link generation request to the infrastructure core service layer based on the basic code data;
[0044] (3) The infrastructure core service layer responds to the link generation request and generates call link data based on the basic code data; the call link data represents the call relationship of the nodes included in the basic code data;
[0045] (4) The infrastructure application service layer accesses the code server, obtains the submission record data of the data to be analyzed, and transmits the submission record data to the infrastructure core service layer;
[0046] (5) The infrastructure core service layer determines the changed call link data corresponding to the data to be analyzed based on the submission record data and the call link data of the data to be analyzed; based on the call link data, the changed call link data is hierarchically analyzed to obtain the change results of the data to be analyzed, and the change results are transmitted to the infrastructure application service layer.
[0047] (6) The infrastructure application service layer renders based on the change results, generates a change result display view, and sends the change result display view to the front end.
[0048] (7) The front end displays the change result display view.
[0049] The code analysis system provided in the embodiment of the present application can timely and accurately locate the changes between the data to be analyzed and the basic code data by performing link analysis on the basic code and the submission record data of the data to be analyzed, and through hierarchical analysis, it can quickly locate the impact of each submission record data on the relevant product functions of the current application basic code data, thereby determining whether functional regression is needed, improving the accuracy of code change analysis results, and at the same time improving the efficiency of code analysis.
[0050] based on Figure 1 The code analysis system provided and Figure 2 The server provided by the present application provides a code analysis method, which can be Figure 1 and Figure 2The code analysis method provided in the embodiment of the present application includes at least steps 210 to 230, which are described in detail as follows:
[0051] Step 210, determining the call link data of the basic code data.
[0052] Among them, the basic code data represents the trunk branch code data of the updated and iterated projects in the business system. It can be understood that each project in the business system adds functional points based on the trunk branch code data to form its own code data. Among them, the business system can be an education system, a financial system, etc.
[0053] The call link data basic code data contains the calling relationship of the nodes.
[0054] In some implementations, the call link data of the basic code data may be directly acquired.
[0055] Optionally, a code analysis task to be analyzed can be determined, and basic code data and call link data of the basic code data can be obtained from a code server based on a task identifier corresponding to the code analysis task. It is understandable that the code server stores business code data of the business system, wherein the business code data includes multiple task identifiers and basic code data corresponding to each task identifier, as well as call link data of the basic code data.
[0056] In some implementations, the call link data of the basic code data may be obtained by performing a link analysis on the basic code data.
[0057] Optionally, the code analysis task to be analyzed can be determined, the basic code data can be obtained from the code server based on the task identifier corresponding to the code analysis task, and the link analysis can be performed based on the basic code data to obtain the call link data of the basic code data. Exemplarily, the basic code data can be subjected to link analysis according to the code parsing tool to obtain the call link data of the basic code data. Among them, the code parsing tool can be java callgraph, and the tool and the project corresponding to the basic code data are set in the same directory, and the basic code data is parsed by specifying commands. After the parsing is completed, the code analysis tool will generate call link data according to the data of the data packet. Among them, the call link relationship data represents the call relationship of the nodes contained in the basic code data, and the components of the call link data can include but are not limited to: classes, methods, constants, call links, etc. The call link data includes multiple branches, each branch includes multiple nodes, and each branch represents an interface call path.
[0058] Step 220 , obtaining the submission record data of the data to be analyzed, and determining the change call link data corresponding to the data to be analyzed based on the submission record data of the data to be analyzed and the call link data.
[0059] The data to be analyzed may be branch code data of the code analysis task to be analyzed. It is understandable that the data to be analyzed is code data formed by adding functions to the main branch code with the basic code data as the main branch code.
[0060] The submission record data is used to characterize the changes in the data to be analyzed, which includes the submission time, the submitter, the submitted code data, and the submitted code file. The submitted code data represents that a certain section of code data of the data to be analyzed has been updated, and the improved code file represents that the class file and dependent file of the data to be analyzed have been updated. The update includes but is not limited to adding operations, deleting operations, replacing operations, etc.
[0061] The changed call link data includes at least one call path in which the data to be analyzed is updated relative to the basic code data.
[0062] In some implementations, submission record data of the data to be analyzed may be obtained from a code server according to the code analysis task to be analyzed.
[0063] In some implementations, code analysis can be performed using the submission record data and call link data of the data to be analyzed by a code analysis tool to determine the changed call link data corresponding to the data to be analyzed. The code analysis tools include but are not limited to ANTLR, SonarQube, tree-sitter, Javalang, JavaParser, Eclipse AstParser, etc.
[0064] In some implementations, the submission record data and call link data of the data to be analyzed can be compared to determine the changed nodes in the data to be analyzed, and link analysis can be performed based on the changed nodes to obtain the changed call link data corresponding to the data to be analyzed. The changed nodes are used to represent nodes in the data to be analyzed where the trunk code data and the basic code data are inconsistent.
[0065] Step 230, based on the call link data, perform hierarchical analysis on the changed call link data, obtain the change result of the data to be analyzed, and display the change result.
[0066] In some implementations, based on the call link data, the call link data can be hierarchically analyzed to obtain the call interface corresponding to the call link data and the interface information corresponding to the call interface, and the change result of the data to be analyzed can be obtained according to the interface information, and the change result can be displayed. Among them, the interface information represents the front-end interface information that can be obtained after calling the call interface and running the code, including all the contents displayed on the front-end interface.
[0067] The change result represents the impact on the business system after the data to be analyzed is changed, including the impact of all contents in the front-end interface.
[0068] Among them, hierarchical analysis is used to determine the interface information corresponding to the call path in the call link data. Among them, the interface information includes the information corresponding to each marked call interface and the interface information corresponding to each call interface. Among them, the interface information includes whether the interface is a new call interface or an old call interface. The interface information corresponding to each call interface is the front-end interface information that can be obtained after calling the call interface and running the code, including all the content displayed on the front-end interface. Among them, the new call interface represents the call interface newly added to the data to be analyzed, and the old call interface represents the call interface that has not been changed.
[0069] In some implementations, a hierarchical analysis may be performed on the change call link data to obtain an interface file corresponding to the change call link data, and interface information corresponding to the change call link data may be determined based on the interface file corresponding to the change call link data. Based on the interface information, a call interface corresponding to the change call link data and interface information corresponding to the call interface may be obtained.
[0070] Optionally, the changed call link data includes the data name corresponding to the changed data, and also includes a mapping relationship between the data name and the call link. The electronic device can recursively trace back to the call link data according to the mapping relationship to obtain an interface file corresponding to the changed call link data. Among them, the mapping relationship between the data name and the call link means that the change link related to the data name can be found in the call link data according to the data name, and the change code related to the data name can be found according to the link. Among them, recursive backtracking is a logical algorithm, through which the interface file corresponding to the changed call link data can be found in the call link data, and the currently found interface file is the path of the call interface.
[0071] Optionally, after the electronic device obtains the interface file, it statically scans the interface file, obtains the content of the interface file according to the address of the current interface file, and then determines the interface information corresponding to the change call link data according to the content of the interface file. The interface information includes the information corresponding to each marked call interface and the interface information corresponding to each call interface.
[0072] Exemplarily, the interface file can be processed to output the interface file in the target format; the interface information corresponding to the change call link data is determined according to the interface file, and specifically, the interface information corresponding to the change call link data is marked according to the interface file in the target format and characteristic information. Among them, after the electronic device obtains the interface file corresponding to the change call link data, it processes the interface file and outputs the interface file in the target format. In an embodiment of the present application, the interface file in the target format can be in the format of an API interface document, or in the format of other types of interface documents. The interface information corresponding to the change call link data is marked according to the interface file in the target format and characteristic information. The method can specifically include: treating the change call link data as a change branch, and also including a trunk branch in the call link data, and the electronic device marks all interfaces according to the characteristic information corresponding to the change call link data in combination with the interface file.
[0073] Exemplarily, processing an interface file and outputting an interface file in a target format includes: splicing the data contained in the interface file with the data corresponding to the interface file stored in a database to obtain an interface file in a target format; and outputting the interface file in a target format. Among them, the interface information in the data obtained by the electronic device according to the interface file may be incomplete, for example, part of the data is in the database, and part of the data is in the obtained interface file, and the format is not uniform. Therefore, after obtaining the interface file, it is necessary to splice the interface information in combination with the data in the interface file and the data in the database to output the interface file in the target format.
[0074] In some implementations, link data may also be called to perform a hierarchical analysis on each change call link in the change call link data, determine the top-level call node of each change call link, determine the call interface based on the top-level call node of the change call link, and determine the change result of the data to be analyzed based on the call result.
[0075] Specifically, Figure 4 As shown, Figure 4 2 is a flow chart of a hierarchical analysis method provided in an embodiment of the present application. The hierarchical analysis method shown includes steps 231 to 234:
[0076] Step 231 , based on the call link data, perform a hierarchical analysis on each changed call link in the changed call link data to determine the top-level call node of each changed call link.
[0077] The top-level call node refers to the head node of the path where the call link is changed in the call link data.
[0078] In some implementations, the call link data can be compared with each changed call link in the changed call link data to determine the path where the changed call link in the call link data is located, and a hierarchical analysis is performed on the path to obtain the head node of the path, and the head node of the path is determined as the top-level call node of the changed call link.
[0079] Step 232: Determine the calling interface corresponding to the top-level calling node of each changed calling link based on the preset interface configuration data.
[0080] The preset interface configuration data includes a plurality of calling interfaces and a calling node corresponding to each calling interface.
[0081] In some implementations, for each top-level call node of each change call link, preset interface configuration data may be queried according to the top-level call node of the change call link to obtain a call interface corresponding to the top-level call node of the change call link.
[0082] Step 233, based on the preset product configuration data, determine the application point corresponding to each calling interface.
[0083] The preset product configuration data includes multiple application points and interface clusters corresponding to each application point, and each interface cluster includes at least one calling interface.
[0084] The application point is used to represent the business functions provided by the business system, including but not limited to query function, write function, read function, etc.
[0085] In some implementations, preset product configuration data may be queried according to the calling interface to determine the target interface cluster where the calling interface is located, and the application point corresponding to the target interface cluster may be determined as the application point corresponding to the calling interface.
[0086] Step 234, obtaining the change result according to the application point corresponding to each calling interface.
[0087] In some implementations, the application points corresponding to the various calling interfaces may be summarized to determine the impact of the data to be analyzed on the business system and obtain the change result.
[0088] In some implementations, after obtaining the change result of the data to be analyzed, rendering may be performed according to the change result to generate a change result display view, and the change result display view may be displayed on the front end.
[0089] In some implementations, after the change result of the data to be analyzed is obtained, an impact report may be generated according to the change result and the impact report may be displayed.
[0090] The code analysis method provided in the embodiment of the present application can timely and accurately locate the changes between the data to be analyzed and the basic code data by performing link analysis on the basic code and the submission record data of the data to be analyzed, and through hierarchical analysis, it can quickly locate the impact of the submission record data of each submission on the relevant product functions of the current application basic code data, so as to determine whether functional regression is needed, improve the accuracy of the code change analysis results, and at the same time improve the efficiency of code analysis.
[0091] In some implementations, a code server may be accessed to obtain an image file, the image file may be compiled to obtain basic code data, and the basic code data may be subjected to link analysis to obtain call link data. The image file may be a compressed file containing basic code data.
[0092] Specifically, Figure 5 As shown, Figure 5 21 is a flow chart of a method for obtaining call link data provided in an embodiment of the present application. The method for obtaining call link data shown includes steps 211 to 213:
[0093] Step 211, responding to the code acquisition request, sending an access request to the code server to acquire the image file corresponding to the code acquisition request.
[0094] The image file may be a compressed package containing the main code data of the business system.
[0095] In some implementations, the front end displays a code analysis page, and the user triggers a code acquisition request based on the code analysis page.
[0096] In some embodiments, Figure 2 As shown, the infrastructure application service layer responds to the code acquisition request, sends an access request to the code server, and obtains the image file corresponding to the code acquisition request.
[0097] In some embodiments, to ensure data security, the infrastructure application service layer sends an access request to the code server based on the file information and verification information of the image file to be obtained. The code server obtains the access request and verifies the server based on the verification information carried in the access information. When the verification passes, the corresponding image file is obtained based on the file information carried in the access request, and the image file is returned to the infrastructure application service layer.
[0098] Optionally, the verification information includes a verification code and a user identifier. The infrastructure application service layer determines a base verification code corresponding to the user identifier, and compares the base verification code with the verification code. If the base verification code and the verification code are inconsistent, it is determined that the verification fails. If the base verification code and the verification code are consistent, the permission information corresponding to the user identifier is obtained based on the user identifier, the base permission information corresponding to the file information is determined, and the permission information corresponding to the user identifier is compared with the base permission information. If the permission information corresponding to the user identifier matches the base permission information, it is determined that the verification passes. If the permission information corresponding to the user identifier does not match the base permission information, it is determined that the verification fails.
[0099] In some implementations, after obtaining the image file corresponding to the code acquisition request, the infrastructure application service layer obtains a preset storage address and writes the image file corresponding to the code acquisition request to the preset storage address in the server.
[0100] Step 212, decompress the image file to obtain basic code data.
[0101] In some implementations, the infrastructure application service layer reads an image file from a preset storage address, decompresses the image file to obtain an initial basic code, compiles the initial basic code to obtain a basic code, and compresses the basic code to obtain basic code data.
[0102] Step 213, generating call link data based on the basic code data.
[0103] Among them, the call link data represents the call relationship of the nodes contained in the basic code data.
[0104] In some implementations, link analysis may be performed on the basic code data according to the above step S210 to generate call link data.
[0105] In some implementations, the infrastructure application service layer transmits the storage address of the basic code data and the link analysis request to the infrastructure core service layer, and the infrastructure core service layer responds to the link analysis request, reads the basic code data based on the storage address of the basic code data, parses the basic code data, obtains the class information in the basic code data, performs link analysis based on the class information, and obtains the call link data. The class information includes, but is not limited to, inheritance and implementation class information, class method information, class method call information, class attribute information, etc.
[0106] Specifically, the call link analysis method includes steps a1 to a3:
[0107] Step a1, parsing the basic code data to obtain the class files in the basic code data.
[0108] Step a2, parsing the class files in the basic code data to obtain class information of each type of file.
[0109] Step a3, based on the class information of each type of file, determine the calling information between each type of file.
[0110] The call information is used to represent the call relationship between nodes corresponding to the class files.
[0111] In some implementations, the calling relationship between nodes corresponding to each type of file can be determined based on the class method information, class method calling information, and class attribute information in the class information of the class file, and the calling information between each type of file can be determined based on the calling relationship between nodes corresponding to each type of file.
[0112] Step a4, based on the call information between various files, establish a call link table and generate call link data.
[0113] In some implementations, the nodes corresponding to various types of files can be sorted based on the call information between various types of files, and the preceding node and the following node of each node can be determined. Based on the preceding node and the following node of each node, the forward pointer and the backward pointer of each node can be set to establish a call list, and the class file corresponding to the node can be written into the data bit of the node to generate call link data. Among them, the preceding node of the head node is empty, and the following node of the tail node is empty. It can be understood that the forward pointer of the head node is empty, and the backward pointer points to the second node, the forward pointer of the tail node points to the second to last node, and the backward pointer of the tail node is empty. For example, Figure 6 As shown, Figure 6 It is a schematic diagram of a call linked list provided in an embodiment of the present application, wherein the subsequent pointer of a forward node points to the data bit of a subsequent node, and the forward pointer of a subsequent node points to the data bit of a forward node.
[0114] In some implementations, the code server stores submission record data of branch codes submitted by the business system at different times. To determine the impact of branch code updates on the business system, the code server can be accessed to obtain submission record data of the data to be analyzed.
[0115] Specifically, Figure 7 As shown, Figure 7 2 is a flow chart of a method for obtaining submission record data provided in an embodiment of the present application. The method for obtaining submission record data includes steps 221 to 223:
[0116] Step 221, responding to the code analysis request, determining the code identification information and time information of the data to be analyzed carried in the code analysis request.
[0117] In some embodiments, after determining the basic code data, the branch codes in the business system with the basic code data as the main code are determined based on the basic code data, and the code identification information of each branch code is displayed in the front-end page view. The front end responds to the branch code selection operation input by the user based on the front-end page view, determines the selected target branch code and time information, and sends a code analysis request to the infrastructure application service layer based on the code identification information and time information of the target branch code. The infrastructure application service layer responds to the code analysis request and determines the code identification information and time information of the data to be analyzed carried by the code analysis request.
[0118] Step 222: access the code server to obtain the initial submission record corresponding to the code identification information and the submission time corresponding to each initial submission record.
[0119] In some implementations, the infrastructure application service layer accesses the code server to obtain the initial submission record corresponding to the code identification information and the submission time corresponding to each initial submission record.
[0120] Optionally, the infrastructure application service layer sends an access request to the code server, and the code server verifies the access request. If the verification is successful, the infrastructure application service layer receives access, and the infrastructure application service layer pulls the initial submission record corresponding to the code identification information and the submission time corresponding to each initial submission record from the code server.
[0121] Step 223 , based on the submission time corresponding to each initial submission record, the target initial submission record whose submission time meets the time information is determined as the submission record data of the data to be analyzed.
[0122] In some implementations, if the submission time is within the time range corresponding to the time information, it is determined that the submission time satisfies the time information; if the submission time is not within the time range corresponding to the time information, it is determined that the submission time does not satisfy the time information.
[0123] In some implementations, after determining the call link data and the submission record data, the change record data may be determined based on the call link data and the submission record data, and link analysis may be performed based on the change record data to determine the change call link data corresponding to the data to be analyzed. Specifically, Figure 8 As shown, Figure 8 224 is a flowchart of a method for determining call link data change provided by an embodiment of the present application. The method for determining call link data change shown includes steps 224 to 227:
[0124] Step 224 , analyzing the submission record data of the data to be analyzed, and determining the target change file whose submission time in the submission record data is the shortest from the current time.
[0125] In some embodiments, the infrastructure application service layer transmits the submission record data of the data to be analyzed to the infrastructure core service layer, and the infrastructure core service layer analyzes the submission record data of the data to be analyzed to determine the target change file whose submission time of the change file in the submission record data is the shortest from the current time.
[0126] Optionally, the infrastructure core service layer analyzes each submission record in the submission record data to determine the submission time, submitted change file, change registration, etc. corresponding to each submission record, and based on the submission time corresponding to each submission record, the submission file with the submission time of the change file shortest to the current time is determined as the target submission file.
[0127] Step 225, parse the target change file to determine the change record data of the data to be analyzed.
[0128] The change record data includes the changed class address, class method and change level.
[0129] Step 226, compare the change record data with the call link data to determine the change node corresponding to the change record data and the change call link where the change node is located.
[0130] In some implementations, the change record data and the call link data may be compared to determine the change node corresponding to the change record data, and the change call link where the change node is located may be determined based on the call link data.
[0131] In some implementations, considering that there are change points between the change record data and the call link data that cannot be clearly identified by static analysis, it is necessary to identify nodes that cannot be statically analyzed in the change point identification. For nodes that cannot be statically analyzed, probability prediction is performed through class methods and class addresses, and the changed nodes are determined from the nodes in the call link data based on probability. Specifically, the change node identification method includes steps b1 to b3:
[0132] Step b1, compare the changed class address and class method in the change record data with the call link data to determine whether there is a node in the call link data corresponding to the changed class address and class method.
[0133] Step b2: If there is a node corresponding to the changed class address and class method in the call link data, the node is determined as a changed node, and the changed call link where the changed node is located is determined according to the call link data.
[0134] Step b3: If there is no node corresponding to the changed class address and class method in the call link data, the nodes in the call link data are screened according to the changed class address and class method to determine the changed node, and the changed call link where the changed node is located is determined according to the call link data.
[0135] In some embodiments, step b3 comprises:
[0136] If there is no node corresponding to the changed class address and class method in the call link data, then the class name and injection point name corresponding to the changed class address and class method are used.
[0137] The nodes in the call link data are screened based on the class name and the injection point name, and candidate nodes matching the class name and the injection point name in the nodes in the call link data and the probability of each candidate node are determined.
[0138] The candidate nodes whose probabilities are greater than a preset probability threshold are determined as the changed nodes, and the changed call link where the changed node is located is determined according to the call link data.
[0139] Step 227, summarize each change call link to obtain change call link data.
[0140] In some implementations, after obtaining the changed call link data, the changed call link data may be hierarchically analyzed according to the above step 230 to obtain the change result of the data to be analyzed, and the change result may be displayed.
[0141] In some implementations, after obtaining the change call link data, you can Figure 4 The provided hierarchical analysis method performs hierarchical analysis on the change call link data, obtains the change results of the data to be analyzed, and displays the change results.
[0142] The code analysis method provided in the embodiment of the present application can timely and accurately locate the changes between the data to be analyzed and the basic code data by performing link analysis on the basic code and the submission record data of the data to be analyzed, and through hierarchical analysis, it can quickly locate the impact of the submission record data of each submission on the relevant product functions of the current application basic code data, so as to determine whether functional regression is needed, improve the accuracy of the code change analysis results, and at the same time improve the efficiency of code analysis.
[0143] In order to better implement the code analysis method provided in the embodiment of the present application, based on the code analysis method, a code analysis device provided in the embodiment of the present application is provided. Figure 1 The server side of the code analysis system is shown in Fig. 9 As shown, Fig. 9: is a schematic diagram of the structure of a code analysis device provided in an embodiment of the present application, wherein the code analysis device shown includes:
[0144] A link generation module 901 is used to determine call link data of basic code data;
[0145] The branch analysis module 902 is used to obtain the submission record data of the data to be analyzed, and determine the change call link data corresponding to the data to be analyzed based on the submission record data and the call link data of the data to be analyzed;
[0146] The change analysis module 903 is used to perform hierarchical analysis on the change call link data based on the call link data, obtain the change result of the data to be analyzed, and display the change result.
[0147] In some implementations, the branch analysis module 902 is used to:
[0148] Analyze the submission record data of the data to be analyzed, and determine the target change file whose submission time of the change file in the submission record data is the shortest from the current time;
[0149] Parse the target change file to determine the change record data of the data to be analyzed, which includes the changed class address, class method and change level;
[0150] Compare the change record data with the call link data to determine the change node corresponding to the change record data and the change call link where the change node is located;
[0151] Summarize each change call link to obtain change call link data.
[0152] In some implementations, the branch analysis module 902 is used to:
[0153] Compare the changed class address and class method in the change record data with the call link data to determine whether there is a node in the call link data corresponding to the changed class address and class method;
[0154] If there is a node corresponding to the changed class address and class method in the call link data, the node is determined as a changed node, and the changed call link where the changed node is located is determined according to the call link data;
[0155] If there is no node corresponding to the changed class address and class method in the call link data, the nodes in the call link data are screened according to the changed class address and class method to determine the changed node, and the changed call link where the changed node is located is determined according to the call link data.
[0156] In some implementations, the branch analysis module 902 is used to:
[0157] According to the changed class address, class name corresponding to the class method and injection point name;
[0158] Filter the nodes in the call link data based on the class name and the injection point name, determine the candidate nodes in the call link data that match the class name and the injection point name, and the probability of each candidate node;
[0159] The candidate nodes whose probabilities are greater than a preset probability threshold are determined as change nodes.
[0160] In some implementations, the branch analysis module 902 is used to:
[0161] In response to the code analysis request, determine the code identification information and time information of the data to be analyzed carried in the code analysis request;
[0162] Access the code server to obtain the initial submission record corresponding to the code identification information and the submission time corresponding to each initial submission record;
[0163] Based on the submission time corresponding to each initial submission record, the target initial submission record whose submission time meets the time information is determined as the submission record data of the data to be analyzed.
[0164] In some implementations, the change parsing module 903 is used to:
[0165] According to the call link data, perform a hierarchical analysis on each change call link in the change call link data to determine the top-level call node of each change call link;
[0166] Based on the preset interface configuration data, determining the call interface corresponding to the top-level call node of each change call link; the preset interface configuration data includes multiple call interfaces and the call node corresponding to each call interface;
[0167] Based on the preset product configuration data, determining the application point corresponding to each calling interface; the preset product configuration data includes multiple application points and at least one calling interface corresponding to each application point;
[0168] The change result is obtained according to the application point corresponding to each calling interface.
[0169] In some embodiments, the code analysis apparatus includes:
[0170] The main code analysis module 904 is used to respond to the code acquisition request, send an access request to the code server, and obtain the image file corresponding to the code acquisition request; decompress the image file to obtain basic code data.
[0171] The link generation module 901 is used for basic code data to generate call link data; the call link data represents the call relationship of the nodes included in the basic code data.
[0172] In some implementations, the link generation module 901 is configured to:
[0173] Parse the basic code data to obtain the class files in the basic code data;
[0174] Parse the class files in the basic code data to obtain class information of various files;
[0175] Based on the class information of various files, determine the calling information between various files;
[0176] Based on the calling information between various files, a calling list is established to generate calling link data.
[0177] The code analysis device provided in the embodiment of the present application can timely and accurately locate the changes between the data to be analyzed and the basic code data by performing link analysis on the basic code and the submission record data of the data to be analyzed, and through hierarchical analysis, it can quickly locate the impact of the submission record data of each submission on the relevant product functions of the current application basic code data, so as to determine whether functional regression is needed, improve the accuracy of the code change analysis results, and at the same time improve the efficiency of code analysis.
[0178] The present application also provides an electronic device, such as Fig.10 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:
[0179] The electronic device may include components such as a processor 1001 with one or more processing cores, a memory 1002 with one or more computer-readable storage media, a power supply 1003, and an input unit 1004. Those skilled in the art will appreciate that Fig.10 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0180] The processor 1001 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 1002 and calling data stored in the memory 1002, it executes various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 1001 may include one or more processing cores; preferably, the processor 1001 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1001.
[0181] The memory 1002 can be used to store software programs and modules. The processor 1001 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002. The memory 1002 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1002 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 1002 may also include a memory controller to provide the processor 1001 with access to the memory 1002.
[0182] The electronic device also includes a power supply 1003 for supplying power to each component. Preferably, the power supply 1003 can be logically connected to the processor 1001 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 1003 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0183] The electronic device may further include an input unit 1004, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0184] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 1001 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 1002 according to the following instructions, and the processor 1001 will run the application programs stored in the memory 1002, thereby realizing various functions, as follows:
[0185] Determine call link data of basic code data;
[0186] Obtaining submission record data of the data to be analyzed, and determining change call link data corresponding to the data to be analyzed based on the submission record data and call link data of the data to be analyzed;
[0187] Based on the call link data, perform hierarchical analysis on the changed call link data, obtain the change results of the data to be analyzed, and display the change results.
[0188] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0189] To this end, an embodiment of the present application provides a storage medium in which a computer program is stored, and the computer program can be loaded by a processor to execute the steps in any code analysis method provided in the embodiment of the present application. For example, the computer program can execute the following steps:
[0190] Determine call link data of basic code data;
[0191] Obtaining submission record data of the data to be analyzed, and determining change call link data corresponding to the data to be analyzed based on the submission record data and call link data of the data to be analyzed;
[0192] Based on the call link data, perform hierarchical analysis on the changed call link data, obtain the change results of the data to be analyzed, and display the change results.
[0193] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0194] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0195] Since the computer program stored in the storage medium can execute the steps in any method for controlling a heater provided in the embodiments of the present application, the beneficial effects that can be achieved by any method for controlling a heater provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0196] The above is a detailed introduction to a code analysis method, system, device, electronic device and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A code analysis method, characterized in that: The method comprises: Determine call link data of basic code data; Acquire submission record data of the data to be analyzed, and determine the change call link data corresponding to the data to be analyzed based on the submission record data of the data to be analyzed and the call link data; Based on the call link data, perform hierarchical analysis on the changed call link data to obtain a change result of the data to be analyzed, and display the change result; The determining, based on the submission record data of the data to be analyzed and the call link data, the changed call link data corresponding to the data to be analyzed includes: Determine change record data according to the submission record data, wherein the change record data includes a changed class address, a class method, and a change level; If there is no node corresponding to the changed class address and class method in the call link data, then according to the class name and injection point name corresponding to the changed class address and class method, the nodes in the call link data are screened based on the class name and the injection point name, and candidate nodes matching the class name and the injection point name in the nodes in the call link data are determined, as well as the probability of each candidate node, and the candidate node with a probability greater than a preset probability threshold is determined as a changed node; Determine the change call link where the change node is located according to the call link data, and summarize the change call links to obtain the change call link data; The step of performing hierarchical analysis on the changed call link data based on the call link data to obtain a change result of the data to be analyzed, and displaying the change result includes: According to the call link data, perform hierarchical analysis on each change call link in the change call link data to determine a top-level call node of each change call link, wherein the top-level call node refers to a head node of a path where the change call link in the call link data is located; Obtaining a change result according to the top-level call node, wherein the change result represents the impact of the change of the to-be-analyzed data on the basic code data; The obtaining of the change result according to the top-level calling node includes: Based on preset interface configuration data, determining the call interface corresponding to the top-level call node of each of the change call links; the preset interface configuration data includes multiple call interfaces and the call node corresponding to each call interface; Based on preset product configuration data, determining the application point corresponding to each of the calling interfaces; the preset product configuration data includes multiple application points and at least one calling interface corresponding to each of the application points; The change result is obtained according to the application point corresponding to each of the calling interfaces.
2. The method according to claim 1, characterized in that The determining the change record data according to the submission record data comprises: Analyze the submission record data of the data to be analyzed, and determine the target change file whose submission time of the change file in the submission record data is the shortest from the current time; The target change file is parsed to determine the change record data of the data to be analyzed, wherein the change record data includes the changed class address, class method and change level.
3. The method according to claim 2, characterized in that The determining, based on the submission record data of the data to be analyzed and the call link data, the change call link data corresponding to the data to be analyzed further includes: If there is a node corresponding to the changed class address and class method in the call link data, the node is determined as a changed node, and the changed call link where the changed node is located is determined according to the call link data.
4. The method according to claim 1, characterized in that: The step of obtaining submission record data of the data to be analyzed includes: In response to the code analysis request, determine the code identification information and time information of the data to be analyzed carried in the code analysis request; Accessing the code server to obtain the initial submission record corresponding to the code identification information and the submission time corresponding to each initial submission record; Based on the submission time corresponding to each of the initial submission records, the target initial submission record whose submission time meets the time information is determined as the submission record data of the data to be analyzed.
5. The method according to any one of claims 1 to 4, characterized in that: The step of determining the call link data of the basic code data includes: In response to the code acquisition request, an access request is sent to the code server to obtain the image file corresponding to the code acquisition request; Decompressing the image file to obtain basic code data; Based on the basic code data, call link data is generated; the call link data represents the call relationship of the nodes included in the basic code data.
6. The method according to claim 5, characterized in that The step of generating call link data based on the basic code data includes: Parsing the basic code data to obtain class files in the basic code data; Parsing the class files in the basic code data to obtain class information of each class file; Based on the class information of each of the class files, determining the calling information between the class files; Based on the calling information between the class files, a calling chain table is established to generate calling chain data.
7. A code analysis system, characterized in that: The code analysis system includes a service end and a code server; The server is used to determine the call link data of the basic code data, access the code server, obtain the submission record data of the data to be analyzed, determine the changed call link data corresponding to the data to be analyzed based on the submission record data of the data to be analyzed and the call link data, perform hierarchical analysis on the changed call link data based on the call link data, obtain the change result of the data to be analyzed, and display the change result; The determining, based on the submission record data of the data to be analyzed and the call link data, the changed call link data corresponding to the data to be analyzed includes: Determine change record data according to the submission record data, wherein the change record data includes a changed class address, a class method, and a change level; If there is no node corresponding to the changed class address and class method in the call link data, then according to the class name and injection point name corresponding to the changed class address and class method, the nodes in the call link data are screened based on the class name and the injection point name, and candidate nodes matching the class name and the injection point name in the nodes in the call link data are determined, as well as the probability of each candidate node, and the candidate node with a probability greater than a preset probability threshold is determined as a changed node; Determine the change call link where the change node is located according to the call link data, and summarize the change call links to obtain the change call link data; The step of performing hierarchical analysis on the changed call link data based on the call link data to obtain a change result of the data to be analyzed, and displaying the change result includes: According to the call link data, perform hierarchical analysis on each change call link in the change call link data to determine a top-level call node of each change call link, wherein the top-level call node refers to a head node of a path where the change call link in the call link data is located; Obtaining a change result according to the top-level call node, wherein the change result represents the impact of the change of the to-be-analyzed data on the basic code data; The obtaining of the change result according to the top-level calling node includes: Based on preset interface configuration data, determining the call interface corresponding to the top-level call node of each of the change call links; the preset interface configuration data includes multiple call interfaces and the call node corresponding to each call interface; Based on preset product configuration data, determining the application point corresponding to each of the calling interfaces; the preset product configuration data includes multiple application points and at least one calling interface corresponding to each of the application points; The change result is obtained according to the application point corresponding to each of the calling interfaces.
8. The system according to claim 7, characterized in that The server includes a front end, an infrastructure application service layer and an infrastructure core service layer; The front end is used to trigger a code acquisition request to the infrastructure application service layer; The infrastructure application service layer is used to respond to the code acquisition request, send an access request to the code server, obtain the image file corresponding to the code acquisition request, compile the image file to obtain basic code data, and initiate a link generation request to the infrastructure core service layer based on the basic code data; The infrastructure core service layer is used to respond to the link generation request and generate call link data based on the basic code data; the call link data represents the call relationship of the nodes contained in the basic code data.
9. A code analysis device, characterized in that: The device comprises: A link generation module, used to determine call link data of basic code data; A branch analysis module, used to obtain submission record data of the data to be analyzed, and determine the change call link data corresponding to the data to be analyzed based on the submission record data of the data to be analyzed and the call link data; A change analysis module, used for performing hierarchical analysis on the change call link data based on the call link data, obtaining a change result of the data to be analyzed, and displaying the change result; The branch analysis module comprises: Determine change record data according to the submission record data, wherein the change record data includes a changed class address, a class method, and a change level; If there is no node corresponding to the changed class address and class method in the call link data, then according to the class name and injection point name corresponding to the changed class address and class method, the nodes in the call link data are screened based on the class name and the injection point name, and candidate nodes matching the class name and the injection point name in the nodes in the call link data are determined, as well as the probability of each candidate node, and the candidate node with a probability greater than a preset probability threshold is determined as a changed node; Determine the change call link where the change node is located according to the call link data, and summarize the change call links to obtain the change call link data; The change analysis module includes: According to the call link data, perform hierarchical analysis on each change call link in the change call link data to determine a top-level call node of each change call link, wherein the top-level call node refers to a head node of a path where the change call link in the call link data is located; Obtaining a change result according to the top-level call node, wherein the change result represents the impact of the change of the to-be-analyzed data on the basic code data; The obtaining of the change result according to the top-level calling node includes: Based on preset interface configuration data, determining the call interface corresponding to the top-level call node of each of the change call links; the preset interface configuration data includes multiple call interfaces and the call node corresponding to each call interface; Based on preset product configuration data, determining the application point corresponding to each of the calling interfaces; the preset product configuration data includes multiple application points and at least one calling interface corresponding to each of the application points; The change result is obtained according to the application point corresponding to each of the calling interfaces.
10. An electronic device, characterized in that: The electronic device includes a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to perform the operations in the code analysis method according to any one of claims 1 to 6.
11. A storage medium, characterized in that: The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the code analysis method according to any one of claims 1 to 6.
