Offline source code identification method, device, equipment and storage medium

By using the coverage agent tool to collect code coverage data of the files to be identified, and determining the offline source code in combination with the offline code conditions, the problem of cumbersome and inefficient identification of offline source code in the banking business system is solved, and a more efficient identification process is achieved.

CN110321144BActive Publication Date: 2025-03-25WEBANK (CHINA)
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910573917.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-27
Publication Date
2025-03-25
Estimated Expiration
2039-09-29

AI Technical Summary

Technical Problem

In the prior art, the offline source code identification operation that may exist in the banking business system is cumbersome and inefficient, especially because the relevant code logic has been abandoned but not cleared and has no maintenance, and there is a risk of being called.

Method used

The preset coverage agent tool obtains the coverage data of the file to be identified, obtains the execution status identification and execution time interval of each line of source code, and compares it with the preset offline code conditions to determine the offline source code. Then, generate and display a reminder message for the offline source code.

Benefits of technology

The identification operation of offline source code is simplified, the identification efficiency is improved, and the manual comprehensive review of the entire file code is avoided, which solves the problem of inefficient identification in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110321144B_ABST
    Figure CN110321144B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, equipment and storage medium for identifying offline source code. The method obtains coverage data corresponding to a file to be identified through a preset coverage proxy tool, and obtains the execution status identifier and execution time interval corresponding to each line of source code in the file to be identified in the coverage data; the execution status identifier and execution time interval corresponding to each line of source code are respectively compared with the preset offline code conditions, and the offline source code is determined in each line of source code according to the comparison result; the target line number of the offline source code is obtained, and according to the target line number and the file identifier of the file to be identified, a reminder message of the offline source code corresponding to the file to be identified is generated and displayed. The present invention determines the offline source code in each line of source code, avoids manual and comprehensive review of the entire file code, simplifies the identification operation of the offline source code, and improves the recognition efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of financial technology (Fintech), and in particular to a method, device, equipment and computer-readable storage medium for identifying offline source code. Background Art

[0002] With the development of computer technology, more and more technologies (big data, distributed, blockchain, artificial intelligence, etc.) are applied in the financial field. The traditional financial industry is gradually transforming to financial technology (Fintech). However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology. For offline source code that may exist in the business system of a bank, that is, the code whose relevant code logic has been abandoned but has not been cleared in the system project, no one maintains it, and there is a risk of being called, the existing identification method is to manually identify the offline source code. If the relevant developers do not add relevant comments or instructions to the offline source code in time, the subsequent manual identification and search for the offline source code will not only be cumbersome, but also inefficient. Summary of the invention

[0003] The main purpose of the present invention is to provide a method, device, equipment and computer-readable storage medium for identifying offline source code, aiming to solve the technical problem that the existing manual identification of offline source code is cumbersome and inefficient.

[0004] To achieve the above object, the present invention provides a method for identifying offline source code, the method comprising the following steps:

[0005] Obtain coverage data corresponding to the file to be identified through a preset coverage proxy tool, and obtain execution status identifiers and execution time intervals corresponding to each line of source code in the file to be identified in the coverage data, wherein the execution time interval is the difference between the current time and the most recent update time corresponding to each line of source code;

[0006] Compare the execution status identifier and the execution time interval corresponding to each line of source code with the preset offline code condition, and determine the offline source code in each line of source code according to the comparison result;

[0007] The target line number of the offline source code is obtained, and according to the target line number and the file identifier of the file to be identified, a reminder message of the offline source code corresponding to the file to be identified is generated and displayed.

[0008] Optionally, the step of obtaining coverage data corresponding to the file to be identified by using a preset coverage proxy tool, and obtaining execution status identifiers and execution time intervals corresponding to each line of source code in the file to be identified in the coverage data specifically includes:

[0009] Obtain coverage data and code repository information GIT information corresponding to the file to be identified through the coverage agent tool;

[0010] Obtaining a version identifier corresponding to the file to be identified in the GIT information, and determining the current latest version file of the file to be identified as the first version file according to the version identifier corresponding to the file to be identified;

[0011] Obtain execution status identifiers and execution time intervals corresponding to each line of source code in the first version file.

[0012] Optionally, the step of comparing the execution status identifier and the execution time interval corresponding to each line of source code with a preset offline code condition, and determining the offline source code in each line of source code according to the comparison result specifically includes:

[0013] Compare the execution status identifier and the execution time interval corresponding to each line of source code with the offline code condition, and determine the suspected offline source code in each line of source code according to the comparison result;

[0014] When it is detected that there is an updated version file of the file to be identified, obtaining the updated version file of the file to be identified as a second version file;

[0015] Determine a first line number of the suspected offline source code in the first version file, and determine an execution state identifier and an execution time interval of the suspected offline source code in the second version file according to the first line number as a second execution state identifier and a second execution time interval;

[0016] The second execution state identifier and the second execution time interval are respectively compared with the offline code condition, and the offline source code is determined in the suspected offline source code according to the comparison result.

[0017] Optionally, the step of determining a first line number of the suspected offline source code in the first version file, and determining an execution state identifier and an execution time interval of the suspected offline source code in the second version file according to the first line number as a second execution state identifier and a second execution time interval specifically includes:

[0018] Determine the first line number of the suspected offline source code in the first version file, and obtain GIT path information corresponding to the first version file in the GIT information as first path information;

[0019] Acquire identification content of the suspected offline source code in the first version file according to the first path information and the first line number;

[0020] Obtaining GIT path information corresponding to the second version file in the GIT information as second path information;

[0021] According to the second path information, the first line number and the identification content, determining whether the code line number of the suspected offline source code in the second version file has changed;

[0022] If there is no change, the execution state identifier and the execution time interval of the suspected offline source code are determined in the second version file according to the first line number as the second execution state identifier and the second execution time interval of the suspected offline source code.

[0023] Optionally, after the step of determining whether the code line number of the suspected offline source code in the second version file has changed according to the second path information, the first line number and the identification content, the method further includes:

[0024] If there is a change, determining the second line number of the suspected offline source code in the second version file according to the identification content;

[0025] An execution state identifier and an execution time interval of the suspected offline source code are determined in the second version file according to the second line number as a second execution state identifier and a second execution time interval of the suspected offline source code.

[0026] Optionally, the step of obtaining the target line number of the offline source code, and generating and displaying a reminder message of the offline source code corresponding to the file to be identified according to the target line number and the file identifier of the file to be identified specifically includes:

[0027] Obtaining a target line number of the offline source code, and determining a line number range of the offline source code according to the target line number;

[0028] Generate offline source code of the corresponding version of the file to be identified according to the line number range, version identifier and file identifier.

[0029] Optionally, after the step of generating offline source code of the corresponding version of the file to be identified according to the line number range, version identifier and file identifier, the step further includes:

[0030] According to the line number range, version identifier and file identifier of the offline source code, the offline source code is marked offline in the corresponding version of the to-be-identified file, so that the user can find the offline source code in the corresponding version of the to-be-identified file.

[0031] Optionally, the step of comparing the execution status identifier and the execution time interval corresponding to each line of source code with a preset offline code condition, and determining the offline source code in each line of source code according to the comparison result specifically includes:

[0032] Comparing the execution status identifier and execution time interval corresponding to each line of source code with the preset offline code conditions respectively;

[0033] According to the comparison result, determining the offline main line source code in the main line code of each line of source code, and judging whether the line branch code corresponding to the offline main line source code in each line of source code is the offline line branch source code;

[0034] According to the offline main line source code and the corresponding offline line branch source code, the offline source code in each line of source code is determined.

[0035] In addition, to achieve the above-mentioned purpose, the present invention further provides a device for identifying offline source code, the device for identifying offline source code comprising:

[0036] An execution information acquisition module is used to obtain coverage data corresponding to the file to be identified through a preset coverage agent tool, and obtain the execution state identifier and execution time interval corresponding to each line of source code in the file to be identified in the coverage data, wherein the execution time interval is the difference between the current time and the most recent update time corresponding to each line of source code;

[0037] The offline code determination module is used to compare the execution state identifier and execution time interval corresponding to each line of source code with the preset offline code conditions, and determine the offline source code in each line of source code according to the comparison result;

[0038] The offline code reminder module is used to obtain the target line number of the offline source code, and generate and display a reminder message of the offline source code corresponding to the file to be identified according to the target line number and the file identifier of the file to be identified.

[0039] Optionally, the execution information acquisition module specifically includes:

[0040] A file information acquisition unit, used to acquire coverage data and code repository information GIT information corresponding to the file to be identified through the coverage agent tool;

[0041] A first file acquisition unit, configured to acquire a version identifier corresponding to the file to be identified in the GIT information, and determine, according to the version identifier corresponding to the file to be identified, a current latest version file of the file to be identified as a first version file;

[0042] The first information acquisition unit is used to acquire the execution state identifier and execution time interval corresponding to each line of source code in the first version file.

[0043] Optionally, the offline code determination module specifically includes:

[0044] A first code determination unit is used to compare the execution state identifier and the execution time interval corresponding to each line of source code with the offline code condition, and determine the suspected offline source code in each line of source code according to the comparison result;

[0045] A first file acquisition unit, configured to acquire the updated version file of the file to be identified as a second version file when detecting that the file to be identified has an updated version file;

[0046] A second information acquisition unit is used to determine a first line number of the suspected offline source code in the first version file, and determine an execution state identifier and an execution time interval of the suspected offline source code in the second version file according to the first line number as a second execution state identifier and a second execution time interval;

[0047] The offline code determining unit is configured to compare the second execution state identifier and the second execution time interval with the offline code condition respectively, and determine the offline source code in the suspected offline source code according to the comparison result.

[0048] Optionally, the second information acquiring unit is further used to:

[0049] Determine the first line number of the suspected offline source code in the first version file, and obtain GIT path information corresponding to the first version file in the GIT information as first path information;

[0050] Acquire identification content of the suspected offline source code in the first version file according to the first path information and the first line number;

[0051] Obtaining GIT path information corresponding to the second version file in the GIT information as second path information;

[0052] According to the second path information, the first line number and the identification content, determining whether the code line number of the suspected offline source code in the second version file has changed;

[0053] If there is no change, the execution state identifier and the execution time interval of the suspected offline source code are determined in the second version file according to the first line number as the second execution state identifier and the second execution time interval of the suspected offline source code.

[0054] Optionally, the second information acquiring unit is further used to:

[0055] If there is a change, determining the second line number of the suspected offline source code in the second version file according to the identification content;

[0056] An execution state identifier and an execution time interval of the suspected offline source code are determined in the second version file according to the second line number as a second execution state identifier and a second execution time interval of the suspected offline source code.

[0057] Optionally, the offline code determination module is further used for:

[0058] Comparing the execution status identifier and execution time interval corresponding to each line of source code with the preset offline code conditions respectively;

[0059] According to the comparison result, determining the offline main line source code in the main line code of each line of source code, and judging whether the line branch code corresponding to the offline main line source code in each line of source code is the offline line branch source code;

[0060] According to the offline main line source code and the corresponding offline line branch source code, the offline source code in each line of source code is determined.

[0061] In addition, to achieve the above-mentioned purpose, the present invention also provides an offline source code identification device, the offline source code identification device comprising: a memory, a processor, and an offline source code identification program stored in the memory and executable on the processor, the offline source code identification program, when executed by the processor, implements the steps of the offline source code identification method as described above.

[0062] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a program for identifying offline source code is stored, and when the program for identifying offline source code is executed by a processor, the steps of the method for identifying offline source code as described above are implemented.

[0063] The present invention obtains the coverage data corresponding to the file to be identified through a preset coverage proxy tool, and obtains the execution status identifier and execution time interval corresponding to each line of source code in the file to be identified in the coverage data, wherein the execution time interval is the difference between the current time and the most recent update time corresponding to each line of source code; the execution status identifier and execution time interval corresponding to each line of source code are respectively compared with the preset offline code conditions, and the offline source code is determined in each line of source code according to the comparison results; the target line number of the offline source code is obtained, and according to the target line number and the file identifier of the file to be identified, a reminder message of the offline source code corresponding to the file to be identified is generated and displayed. In the above manner, the present invention collects the code coverage data of the file to be identified through the coverage proxy tool, determines the execution status and execution time interval of each line of source code in the file to be identified based on the coverage data, and determines the offline source code, that is, the source code that has not been executed, in each line of source code in combination with the offline code conditions, avoiding manual comprehensive review of the entire file code, simplifying the identification operation of the offline source code, improving the identification efficiency of the offline source code, and solving the technical problem that the operation of the existing manual identification of the offline source code is cumbersome and inefficient. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention;

[0065] Figure 2 It is a flowchart diagram of the first embodiment of the offline source code identification method of the present invention.

[0066] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0067] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0068] like Figure 1 As shown, Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention.

[0069] The offline source code identification device of the embodiment of the present invention may be a PC or a server device, on which a Java virtual machine is running.

[0070] like Figure 1As shown, the offline source code identification device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0071] Those skilled in the art will understand that Figure 1 The device structure shown in the figure does not constitute a limitation of the device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0072] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an identification program for offline source code.

[0073] exist Figure 1 In the device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the offline source code recognition program stored in the memory 1005, and perform the operations in the offline source code recognition method described below.

[0074] Based on the above hardware structure, an embodiment of a method for identifying offline source code of the present invention is proposed.

[0075] Reference Figure 2 , Figure 2 The flowchart of the first embodiment of the offline source code identification method of the present invention is as follows. The offline source code identification method includes:

[0076] Step S10, obtaining coverage data corresponding to the file to be identified through a preset coverage proxy tool, and obtaining the execution state identifier and execution time interval corresponding to each line of source code in the file to be identified in the coverage data, wherein the execution time interval is the difference between the current time and the most recent update time corresponding to each line of source code;

[0077] At present, for offline source code that may exist in the business system of a bank, that is, the code whose relevant code logic has been abandoned but has not been cleared in the system project, no one maintains it, and there is a risk of being called, the existing identification method is to manually identify the offline source code. If the relevant developers do not add relevant comments or instructions to the offline source code in time, the subsequent manual identification and search for offline source code will not only be cumbersome, but also have low recognition efficiency. In order to solve the above problems, this embodiment provides an offline source code identification method, which collects code coverage data of the file to be identified through the coverage agent tool, determines the execution status and execution time interval of each line of source code in the file to be identified based on the coverage data, and determines the offline source code in each line of source code in combination with the offline code condition, that is, the source code that has not been executed, avoids manual comprehensive review of the entire file code, simplifies the offline source code identification operation, and improves the offline source code identification efficiency. Specifically, before the application corresponding to the file to be identified is run, the coverage agent tool is connected to count the coverage of each line of source code corresponding to the file to be identified, that is, whether it is executed, and obtains the coverage data corresponding to the file to be identified. The coverage proxy tool implements the instrumentation API provided by Java, and developers can use the proxy tool to monitor applications running on the JVM. The specific monitoring operation is generally to appropriately modify the source code of a class file when executing the source code corresponding to the class file. Common coverage proxy tools are Cobertura or Jacoco (Java Code Coverage). The coverage proxy tool can calculate the percentage of the code that is accessed and executed, and can also be used to identify which code parts of the Java program code lack test coverage. The coverage data is the result data of whether the code line collected by the coverage proxy tool is covered (i.e., whether it is executed). The process of collecting coverage data by the coverage proxy tool is specifically as follows: according to the instrumentation API provided by Java, an identification field or identification statement is inserted after the executed source code instruction to identify whether the source code has been executed. Since the source code that has been compiled and executed has a preset execution identifier, it is possible to determine whether the line of source code has been executed by determining whether the source code includes an execution identifier. That is, the execution state identifier and execution time interval corresponding to each line of source code in the to-be-identified file are obtained according to the coverage data, wherein the execution time interval is the difference between the current time and the most recent update time corresponding to each line of source code.

[0078] Step S20, comparing the execution state identifier and execution time interval corresponding to each line of source code with the preset offline code condition, and determining the offline source code in each line of source code according to the comparison result;

[0079] In this embodiment, the execution status identifier and execution time interval corresponding to each line of source code are respectively compared with the user identifier executed identifier or non-executed identifier and the time threshold in the preset offline code condition. If the execution status identifier of a line of source code is the same as the non-executed identifier and the execution time interval reaches the set interval threshold, then the line of source code meets the offline code condition, that is, the line of source code is the offline source code. In a specific embodiment, if the execution status identifier of a line of source code is an executed identifier, but the execution time interval does not reach the interval threshold, then the line of source code is identified as the code to be monitored, and the subsequent execution of the line of source code continues to be monitored. If the execution status identifier of a line of source code is a non-executed identifier, then the line of source code is not an offline source code.

[0080] Furthermore, step S20 specifically includes:

[0081] Comparing the execution status identifier and execution time interval corresponding to each line of source code with the preset offline code conditions respectively;

[0082] According to the comparison result, determining the offline main line source code in the main line code of each line of source code, and judging whether the line branch code corresponding to the offline main line source code in each line of source code is the offline line branch source code;

[0083] According to the offline main line source code and the corresponding offline line branch source code, the offline source code in each line of source code is determined.

[0084] In order to improve the recognition efficiency, each line of source code is grouped for recognition. In this embodiment, each line of source code is pre-divided into a main line code group and a branch code group. First, determine whether there is an offline main line source code in the main line code. If there is an offline main line source code, further determine whether the line branch source code corresponding to the offline main line source code is an offline line branch source code. If so, generate a reminder message of the corresponding associated offline source code for the offline main line source code and the corresponding offline line branch source code. If not, generate a reminder message of the offline source code separately according to the offline main line source code. If the main line code is not an offline main line source code, but one of its branches is an offline line branch source code, generate a reminder message of the offline source code separately according to the offline line branch source code.

[0085] Step S30, obtaining the target line number of the offline source code, and generating and displaying a reminder message of the offline source code corresponding to the file to be identified according to the target line number and the file identifier of the file to be identified.

[0086] In this embodiment, according to the file identifier of the file to be identified and the target line number of the offline source code in the file to be identified, a reminder message of the offline source code corresponding to the file to be identified is generated, and the reminder message is displayed to remind the developer that the source code corresponding to the target line number may be the offline source code. The developer can locate the line source code corresponding to the target line number according to the reminder message for confirmation, thereby improving the recognition efficiency.

[0087] In this embodiment, the coverage rate data corresponding to the file to be identified is obtained through a preset coverage rate proxy tool, and the execution status identifier and execution time interval corresponding to each line of source code in the file to be identified in the coverage rate data are obtained, wherein the execution time interval is the difference between the current time and the most recent update time corresponding to each line of source code; the execution status identifier and execution time interval corresponding to each line of source code are respectively compared with the preset offline code condition, and the offline source code is determined in each line of source code according to the comparison result; the target line number of the offline source code is obtained, and according to the target line number and the file identifier of the file to be identified, a reminder message of the offline source code corresponding to the file to be identified is generated and displayed. In the above manner, the present invention collects the code coverage rate data of the file to be identified through the coverage rate proxy tool, determines the execution status and execution time interval of each line of source code in the file to be identified based on the coverage rate data, and determines the offline source code, that is, the source code that has not been executed, in each line of source code in combination with the offline code condition, avoiding manual comprehensive review of the entire file code, simplifying the offline source code recognition operation, improving the offline source code recognition efficiency, and solving the technical problem that the existing manual recognition of offline source code is cumbersome and inefficient.

[0088] Furthermore, based on the first embodiment of the method for identifying offline source code of the present invention, a second embodiment of the method for identifying offline source code of the present invention is proposed.

[0089] In this embodiment, the step S10 specifically includes:

[0090] Obtain coverage data and code repository information GIT information corresponding to the file to be identified through the coverage agent tool;

[0091] Obtaining a version identifier corresponding to the file to be identified in the GIT information, and determining the current latest version file of the file to be identified as the first version file according to the version identifier corresponding to the file to be identified;

[0092] Obtain execution status identifiers and execution time intervals corresponding to each line of source code in the first version file.

[0093] In order to improve the accuracy of recognition, in this embodiment, it is further confirmed whether the offline source code in the next updated version of the file to be recognized has not been executed. Specifically, the coverage data corresponding to each line of source code in the file to be recognized and the GIT information corresponding to the file to be recognized are obtained through a preset coverage agent tool, wherein the GIT is a type of code repository, and the GIT information includes the storage path GIT path corresponding to the file and the version identifier commitID corresponding to the file. The version identifier is the version number corresponding to the next version file generated after a file to be recognized is compiled once. The latest version of the file to be recognized in the GIT warehouse is obtained as the first version file. The coverage data corresponding to each line of source code in the first version file is collected to obtain the execution status identifier and execution time interval corresponding to each line of source code in the first version file.

[0094] Furthermore, the step S20 specifically includes:

[0095] Compare the execution status identifier and the execution time interval corresponding to each line of source code with the offline code condition, and determine the suspected offline source code in each line of source code according to the comparison result;

[0096] When it is detected that there is an updated version file of the file to be identified, obtaining the updated version file of the file to be identified as a second version file;

[0097] Determine a first line number of the suspected offline source code in the first version file, and determine an execution state identifier and an execution time interval of the suspected offline source code in the second version file according to the first line number as a second execution state identifier and a second execution time interval;

[0098] The second execution state identifier and the second execution time interval are respectively compared with the offline code condition, and the offline source code is determined in the suspected offline source code according to the comparison result.

[0099] In this embodiment, the source code that has not been executed is determined to be the suspected offline source code in the first version file, and the suspected offline source code file is further monitored in the subsequent updated version file to see if it is still not executed. If it is still not executed, the suspected offline source code is the offline source code. If it is executed, the suspected offline source code will continue to be detected, and new suspected offline source code will continue to be determined as the monitoring object. Specifically, the suspected offline source code in the first version file is determined according to the execution status identifier and execution time interval of each line of source code in the first version file. When it is detected that there is an updated version file in the GIT warehouse, the updated version file is further detected as the second version file. According to the line number of the suspected offline source code in the first version file, that is, the first line number, the suspected offline source code is quickly located in the second version file, and the execution status identifier and execution time interval of the suspected offline source code in the first version file are obtained, that is, the second execution status identifier and the second execution time interval. And judging whether the second execution state identifier and the second execution time interval meet the offline code condition, thereby determining whether the suspected offline source code is still not executed in the second version file, and determining the suspected offline source code as the offline source code.

[0100] Furthermore, based on the second embodiment of the method for identifying offline source code of the present invention, a third embodiment of the method for identifying offline source code of the present invention is proposed.

[0101] In this embodiment, the step of determining the first line number of the suspected offline source code in the first version file, and determining the execution state identifier and the execution time interval of the suspected offline source code in the second version file according to the first line number as the second execution state identifier and the second execution time interval specifically includes:

[0102] Determine the first line number of the suspected offline source code in the first version file, and obtain GIT path information corresponding to the first version file in the GIT information as first path information;

[0103] Acquire identification content of the suspected offline source code in the first version file according to the first path information and the first line number;

[0104] Obtaining GIT path information corresponding to the second version file in the GIT information as second path information;

[0105] According to the second path information, the first line number and the identification content, determining whether the code line number of the suspected offline source code in the second version file has changed;

[0106] If there is no change, the execution state identifier and the execution time interval of the suspected offline source code are determined in the second version file according to the first line number as the second execution state identifier and the second execution time interval of the suspected offline source code.

[0107] In order to prevent the line number of the suspected offline source code from changing, in this embodiment, a comparison mark of the suspected offline source code is added to determine whether the source code corresponding to the first line number in the second version file is the suspected offline source code. Specifically, the line number of the suspected offline source code in the first version file in the first version file is used as the first line number, and according to the GIT path information corresponding to the first version file, the source code content of each line corresponding to the first version file is obtained in the code warehouse GIT, and according to the first line number, the identification content of the suspected offline source code is obtained in the first version file, wherein the identification content is a code identifier that can identify whether the source code to be identified is the suspected offline source code. For example: the first few lines of code and the last few lines of code of the suspected offline source code, or the main beginning code bytes, the specific code bytes in the middle, and the ending code bytes, etc. In a specific embodiment, when the code content corresponding to the suspected offline source code is small, the suspected offline source code content can also be directly used as the identification content. Locate the code content corresponding to the first line number in the second version file, and determine whether the code line number of the suspected offline source code in the second version file has changed according to the identification content. If there is no change, it is determined that the source code corresponding to the first line number in the second version file is a suspected offline source code, and a second execution state identifier and a second execution time interval of the suspected offline source code in the second version file are obtained.

[0108] Furthermore, after the step of determining whether the code line number of the suspected offline source code in the second version file has changed according to the second path information, the first line number and the identification content, the method further includes:

[0109] If there is a change, determining the second line number of the suspected offline source code in the second version file according to the identification content;

[0110] An execution state identifier and an execution time interval of the suspected offline source code are determined in the second version file according to the second line number as a second execution state identifier and a second execution time interval of the suspected offline source code.

[0111] In this embodiment, if there is a change, a match is performed in the second version file according to the identification content to find the second line number of the suspected offline source code in the second version file, which is the target line number, and obtain the second execution state identification and the second execution time interval corresponding to the suspected offline source code in the second version.

[0112] Further, based on the third embodiment, the step S30 specifically includes:

[0113] Obtaining a target line number of the offline source code, and determining a line number range of the offline source code according to the target line number;

[0114] Generate offline source code of the corresponding version of the file to be identified according to the line number range, version identifier and file identifier.

[0115] In this embodiment, if the line number of the suspected offline source code does not change in the second version file, the first line number is the target line number, and if the line number changes, the second line number is the target line number. According to the line number range of the offline source code corresponding to the target line number, that is, the line number set, and the corresponding version identifier and file identifier, a corresponding offline source code reminder message is generated.

[0116] Furthermore, after the step of generating offline source code of the corresponding version of the file to be identified according to the line number range, version identifier and file identifier, the method further includes:

[0117] According to the line number range, version identifier and file identifier of the offline source code, the offline source code is marked offline in the corresponding version of the to-be-identified file, so that the user can find the offline source code in the corresponding version of the to-be-identified file.

[0118] In order to facilitate developers to locate the offline source code in the file to be identified, in this embodiment, the offline source code is further marked as offline in the corresponding version file according to the line number range, version identifier and file identifier of the offline source code, such as displayed in yellow, to facilitate developers to locate and view.

[0119] The present invention also provides a device for identifying offline source code, the device for identifying offline source code comprising:

[0120] An execution information acquisition module is used to obtain coverage data corresponding to the file to be identified through a preset coverage agent tool, and obtain the execution state identifier and execution time interval corresponding to each line of source code in the file to be identified in the coverage data, wherein the execution time interval is the difference between the current time and the most recent update time corresponding to each line of source code;

[0121] The offline code determination module is used to compare the execution state identifier and execution time interval corresponding to each line of source code with the preset offline code conditions, and determine the offline source code in each line of source code according to the comparison result;

[0122] The offline code reminder module is used to obtain the target line number of the offline source code, and generate and display a reminder message of the offline source code corresponding to the file to be identified according to the target line number and the file identifier of the file to be identified.

[0123] Furthermore, the execution information acquisition module specifically includes:

[0124] A file information acquisition unit, used to acquire coverage data and code repository information GIT information corresponding to the file to be identified through the coverage agent tool;

[0125] A first file acquisition unit, configured to acquire a version identifier corresponding to the file to be identified in the GIT information, and determine, according to the version identifier corresponding to the file to be identified, a current latest version file of the file to be identified as a first version file;

[0126] The first information acquisition unit is used to acquire the execution state identifier and execution time interval corresponding to each line of source code in the first version file.

[0127] Furthermore, the offline code determination module specifically includes:

[0128] A first code determination unit is used to compare the execution state identifier and the execution time interval corresponding to each line of source code with the offline code condition, and determine the suspected offline source code in each line of source code according to the comparison result;

[0129] A first file acquisition unit, configured to acquire the updated version file of the file to be identified as a second version file when detecting that the file to be identified has an updated version file;

[0130] A second information acquisition unit is used to determine a first line number of the suspected offline source code in the first version file, and determine an execution state identifier and an execution time interval of the suspected offline source code in the second version file according to the first line number as a second execution state identifier and a second execution time interval;

[0131] The offline code determining unit is configured to compare the second execution state identifier and the second execution time interval with the offline code condition respectively, and determine the offline source code in the suspected offline source code according to the comparison result.

[0132] Furthermore, the second information acquisition unit is also used for:

[0133] Determine the first line number of the suspected offline source code in the first version file, and obtain GIT path information corresponding to the first version file in the GIT information as first path information;

[0134] Acquire identification content of the suspected offline source code in the first version file according to the first path information and the first line number;

[0135] Obtaining GIT path information corresponding to the second version file in the GIT information as second path information;

[0136] According to the second path information, the first line number and the identification content, determining whether the code line number of the suspected offline source code in the second version file has changed;

[0137] If there is no change, the execution state identifier and the execution time interval of the suspected offline source code are determined in the second version file according to the first line number as the second execution state identifier and the second execution time interval of the suspected offline source code.

[0138] Furthermore, the second information acquisition unit is also used for:

[0139] If there is a change, determining the second line number of the suspected offline source code in the second version file according to the identification content;

[0140] An execution state identifier and an execution time interval of the suspected offline source code are determined in the second version file according to the second line number as a second execution state identifier and a second execution time interval of the suspected offline source code.

[0141] Furthermore, the offline code determination module is also used for:

[0142] Obtaining a target line number of the offline source code, and determining a line number range of the offline source code according to the target line number;

[0143] Generate offline source code of the corresponding version of the file to be identified according to the line number range, version identifier and file identifier.

[0144] Furthermore, the offline code determination module is also used for:

[0145] According to the line number range, version identifier and file identifier of the offline source code, the offline source code is marked offline in the corresponding version of the to-be-identified file, so that the user can find the offline source code in the corresponding version of the to-be-identified file.

[0146] Furthermore, the offline code determination module is also used for:

[0147] Comparing the execution status identifier and execution time interval corresponding to each line of source code with the preset offline code conditions respectively;

[0148] According to the comparison result, determining the offline main line source code in the main line code of each line of source code, and judging whether the line branch code corresponding to the offline main line source code in each line of source code is the offline line branch source code;

[0149] According to the offline main line source code and the corresponding offline line branch source code, the offline source code in each line of source code is determined.

[0150] The methods executed by the above-mentioned program modules can refer to the various embodiments of the offline source code identification method of the present invention, which will not be described in detail here.

[0151] The present invention also provides a computer-readable storage medium.

[0152] The computer-readable storage medium of the present invention stores a program for identifying offline source code, and when the program for identifying offline source code is executed by a processor, the steps of the offline source code identification method described above are implemented.

[0153] The method implemented when the offline source code recognition program running on the processor is executed can refer to the various embodiments of the offline source code recognition method of the present invention, which will not be described in detail here.

[0154] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0155] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0156] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0157] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for identifying offline source code, characterized in that: The offline source code identification method comprises the following steps: Obtain coverage data and code repository information GIT information corresponding to the file to be identified through the preset coverage proxy tool; Obtaining a version identifier corresponding to the file to be identified in the GIT information, and determining the current latest version file of the file to be identified as the first version file according to the version identifier corresponding to the file to be identified; Obtaining an execution status identifier and an execution time interval corresponding to each line of source code in the first version file, wherein the execution time interval is a difference between a current time and a most recently updated time corresponding to each line of source code; Compare the execution status identifier and execution time interval corresponding to each line of source code with the preset offline code conditions, and determine the suspected offline source code in each line of source code according to the comparison result; When it is detected that there is an updated version file of the file to be identified, obtaining the updated version file of the file to be identified as a second version file; Determine a first line number of the suspected offline source code in the first version file, and determine an execution state identifier and an execution time interval of the suspected offline source code in the second version file according to the first line number as a second execution state identifier and a second execution time interval; Compare the second execution state identifier and the second execution time interval with the preset offline code condition respectively, and determine the offline source code in the suspected offline source code according to the comparison result; The target line number of the offline source code is obtained, and according to the target line number and the file identifier of the file to be identified, a reminder message of the offline source code corresponding to the file to be identified is generated and displayed.

2. The offline source code identification method according to claim 1, characterized in that: The step of determining the first line number of the suspected offline source code in the first version file, and determining the execution state identifier and the execution time interval of the suspected offline source code in the second version file according to the first line number as the second execution state identifier and the second execution time interval specifically includes: Determine the first line number of the suspected offline source code in the first version file, and obtain GIT path information corresponding to the first version file in the GIT information as first path information; Acquire identification content of the suspected offline source code in the first version file according to the first path information and the first line number; Obtaining GIT path information corresponding to the second version file in the GIT information as second path information; According to the second path information, the first line number and the identification content, determining whether the code line number of the suspected offline source code in the second version file has changed; If there is no change, the execution state identifier and the execution time interval of the suspected offline source code are determined in the second version file according to the first line number as the second execution state identifier and the second execution time interval of the suspected offline source code.

3. The offline source code identification method according to claim 2, characterized in that: After the step of determining whether the code line number of the suspected offline source code in the second version file has changed according to the second path information, the first line number and the identification content, the method further includes: If there is a change, determining the second line number of the suspected offline source code in the second version file according to the identification content; An execution state identifier and an execution time interval of the suspected offline source code are determined in the second version file according to the second line number as a second execution state identifier and a second execution time interval of the suspected offline source code.

4. The offline source code identification method according to claim 2, characterized in that: The step of obtaining the target line number of the offline source code, and generating and displaying a reminder message of the offline source code corresponding to the file to be identified according to the target line number and the file identifier of the file to be identified specifically includes: Obtaining a target line number of the offline source code, and determining a line number range of the offline source code according to the target line number; Generate offline source code of the corresponding version of the file to be identified according to the line number range, version identifier and file identifier.

5. The offline source code identification method according to claim 4, characterized in that: After the step of generating offline source code of the corresponding version of the file to be identified according to the line number range, version identifier and file identifier, the method further includes: According to the line number range, version identifier and file identifier of the offline source code, the offline source code is marked offline in the corresponding version of the to-be-identified file, so that the user can find the offline source code in the corresponding version of the to-be-identified file.

6. The method for identifying offline source code according to any one of claims 1 to 5, characterized in that: The step of comparing the second execution state identifier and the second execution time interval with the preset offline code condition respectively, and determining the offline source code in the suspected offline source code according to the comparison result specifically includes: Comparing the second execution state identifier and the second execution time interval with the preset offline code condition respectively; According to the comparison result, determining the offline main line source code in the main line code of the suspected offline source code, and judging whether the line branch code corresponding to the offline main line source code in the suspected offline source code is the offline line branch source code; According to the offline main line source code and the corresponding offline line branch source code, the offline source code in the suspected offline source code is determined.

7. A device for identifying offline source code, characterized in that: The offline source code identification device comprises: A file information acquisition unit, used to acquire coverage data and code repository information GIT information corresponding to the file to be identified through a preset coverage agent tool; A first file acquisition unit, configured to acquire a version identifier corresponding to the file to be identified in the GIT information, and determine, according to the version identifier corresponding to the file to be identified, a current latest version file of the file to be identified as a first version file; A first information acquisition unit is used to acquire an execution state identifier and an execution time interval corresponding to each line of source code in the first version file, wherein the execution time interval is a difference between a current time and a most recently updated time corresponding to each line of source code; A first code determination unit is used to compare the execution state identifier and the execution time interval corresponding to each line of source code with the preset offline code condition, and determine the suspected offline source code in each line of source code according to the comparison result; A first file acquisition unit, configured to acquire the updated version file of the file to be identified as a second version file when detecting that the file to be identified has an updated version file; A second information acquisition unit is used to determine a first line number of the suspected offline source code in the first version file, and determine an execution state identifier and an execution time interval of the suspected offline source code in the second version file according to the first line number as a second execution state identifier and a second execution time interval; an offline code determining unit, configured to compare the second execution state identifier and the second execution time interval with the preset offline code condition, respectively, and determine the offline source code in the suspected offline source code according to the comparison result; The offline code reminder module is used to obtain the target line number of the offline source code, and generate and display a reminder message of the offline source code corresponding to the file to be identified according to the target line number and the file identifier of the file to be identified.

8. The offline source code identification device according to claim 7, characterized in that: The second information acquisition unit is further used for: Determine the first line number of the suspected offline source code in the first version file, and obtain GIT path information corresponding to the first version file in the GIT information as first path information; Acquire identification content of the suspected offline source code in the first version file according to the first path information and the first line number; Obtaining GIT path information corresponding to the second version file in the GIT information as second path information; According to the second path information, the first line number and the identification content, determining whether the code line number of the suspected offline source code in the second version file has changed; If there is no change, the execution state identifier and the execution time interval of the suspected offline source code are determined in the second version file according to the first line number as the second execution state identifier and the second execution time interval of the suspected offline source code.

9. The offline source code identification device according to claim 8, characterized in that: The second information acquisition unit is further used for: If there is a change, determining the second line number of the suspected offline source code in the second version file according to the identification content; An execution state identifier and an execution time interval of the suspected offline source code are determined in the second version file according to the second line number as a second execution state identifier and a second execution time interval of the suspected offline source code.

10. The offline source code identification device according to any one of claims 7 to 9, characterized in that: The offline code determination unit is also used for: Comparing the second execution state identifier and the second execution time interval with the preset offline code condition respectively; According to the comparison result, determining the offline main line source code in the main line code of the suspected offline source code, and judging whether the line branch code corresponding to the offline main line source code in the suspected offline source code is the offline line branch source code; According to the offline main line source code and the corresponding offline line branch source code, the offline source code in the suspected offline source code is determined.

11. A device for identifying offline source code, characterized in that: The offline source code identification device comprises: a memory, a processor, and an offline source code identification program stored in the memory and executable on the processor, wherein the offline source code identification program, when executed by the processor, implements the steps of the offline source code identification method according to any one of claims 1 to 6.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program for identifying offline source code, and when the program for identifying offline source code is executed by a processor, the steps of the method for identifying offline source code according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Discarded code detection method, apparatus and device

    CN108628615A