WO2020259034A1 - 下线源代码的识别方法、装置、设备及存储介质 - Google Patents

下线源代码的识别方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2020259034A1
WO2020259034A1 PCT/CN2020/085682 CN2020085682W WO2020259034A1 WO 2020259034 A1 WO2020259034 A1 WO 2020259034A1 CN 2020085682 W CN2020085682 W CN 2020085682W WO 2020259034 A1 WO2020259034 A1 WO 2020259034A1
Authority
WO
WIPO (PCT)
Prior art keywords
source code
offline
file
line
code
Prior art date
Application number
PCT/CN2020/085682
Other languages
English (en)
French (fr)
Inventor
陈晓丹
殷凇
李宗波
邬秋元
Original Assignee
深圳前海微众银行股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2020259034A1 publication Critical patent/WO2020259034A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Definitions

  • This application relates to the technical field of financial technology (Fintech), in particular to methods, devices, equipment and computer-readable storage media for identifying offline source code.
  • the main purpose of this application is to propose a method, device, device, and computer-readable storage medium for identifying offline source code, aiming to solve the existing technical problem of cumbersome and inefficient manual identification of offline source code.
  • this application provides a method for identifying offline source code, and the method for identifying offline source code includes the following steps:
  • the present application also provides a device for identifying offline source code, and the device for identifying offline source code includes:
  • the execution information obtaining module is used to obtain the coverage data corresponding to the file to be identified through the preset coverage proxy tool, and obtain the execution status identifier and execution time corresponding to each line of the source code in the file to be identified in the coverage data Interval, where the execution time interval is the difference between the current time and the latest update time corresponding to each line of source code;
  • the offline code determination module is used to 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 offline code in each line of source code according to the comparison result.
  • Line source code
  • the offline code reminder module is used to obtain the target line number of the offline source code, and generate and display the offline source corresponding to the file to be identified based on the target line number and the file identifier of the file to be identified Code reminder message.
  • the present application also provides a device for identifying offline source code.
  • the device for identifying offline source code includes: a memory, a processor, and a An identification program for offline source code that runs on top, which implements the steps of the method for identifying offline source code as described above when the offline source code identification program is executed by the processor.
  • the present application also provides a computer-readable storage medium, the computer-readable storage medium stores an identification program for offline source code, and the identification program for offline source code is executed by a processor When realizing the steps of the method for identifying offline source code as described above.
  • This application obtains the coverage data corresponding to the file to be identified through the preset coverage proxy tool, and obtains the execution status identifier and execution time interval corresponding to each line of the source code in the file to be identified in the coverage data.
  • the execution time interval is the difference between the current time and the latest 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 compared with the preset offline code conditions, and according to According to the comparison result, the offline source code is determined in each line of source code; the target line number of the offline source code is obtained, and the target line number and the file identifier of the file to be identified are generated and displayed A reminder message of the offline source code corresponding to the file to be identified.
  • this application collects 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 combines The offline code conditions, determine the offline source code in each line of source code, that is, the source code that has not been executed, to avoid manual comprehensive review of the entire file code, simplify the identification of offline source code, and improve the offline source code Recognition efficiency solves the technical problems of cumbersome and inefficient operation of manually identifying offline source code.
  • FIG. 1 is a schematic diagram of a device structure of a hardware operating environment involved in a solution of an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a first embodiment of a method for identifying offline source code of this application.
  • FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present application.
  • the identification device for offline source code in the embodiment of the present application may be a PC or a server device, on which a Java virtual machine runs.
  • the device for identifying offline source code 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.
  • the communication bus 1002 is used to implement connection and communication between these components.
  • the user interface 1003 may include a display screen (Display) and 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 non-volatile memory (non-volatile memory), such as a magnetic disk memory.
  • the memory 1005 may also be a storage device independent of the foregoing processor 1001.
  • FIG. 1 does not constitute a limitation on the device, and may include more or fewer components than those shown in the figure, or a combination of certain components, or different component arrangements.
  • 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.
  • the network interface 1004 is mainly used to connect to a back-end server and communicate with the back-end server;
  • the user interface 1003 is mainly used to connect to a client (user side) and communicate with the client;
  • the processor 1001 can be used to call a recognition program for offline source code stored in the memory 1005, and perform operations in the following offline source code recognition method.
  • Fig. 2 is a schematic flowchart of a first embodiment of a method for identifying offline source code of this application.
  • the method for identifying offline source code includes:
  • Step S10 Obtain the coverage data corresponding to the file to be identified through the preset coverage proxy tool, and obtain 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, where: The execution time interval is the difference between the current time and the latest update time corresponding to each line of source code;
  • this embodiment provides a method for identifying offline source code.
  • the coverage proxy tool collects code coverage data of the file to be identified, and determines the file to be identified based on the coverage data.
  • the execution status and execution time interval of each line of source code determine the offline source code in each line of source code, that is, the source code that has not been executed, avoiding manual comprehensive review of the entire file code, simplifying the download
  • the identification operation of the offline source code improves the identification efficiency of the offline source code.
  • the coverage proxy tool is accessed to count the coverage of each source code line corresponding to the file to be identified, that is, whether it is executed, and to obtain the file to be identified. Identify the coverage data corresponding to the file.
  • 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 performed by appropriately modifying the executed source code of a certain type of file when the source code corresponding to the type of file is executed.
  • 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 parts of the Java program code lack test coverage.
  • the coverage rate data is the result data of whether the code line collected by the coverage proxy tool is covered (that is, whether it is executed or not).
  • the process of collecting coverage data by the coverage proxy tool is specifically: inserting an identification field or identification statement after the executed source code instruction according to the instrumentation API provided by java to identify whether the source code is executed Over.
  • the executed and compiled source code Since the executed and compiled source code has a preset execution flag, it can be judged whether the line of source code is executed by judging whether the source code includes an execution flag. That is, the execution status identifier and execution time interval corresponding to each line of source code in the file to be identified are obtained according to the coverage data, where the execution time interval is the difference between the current time and the latest update time corresponding to each line of source code .
  • Step S20 comparing the execution status identifier and execution time interval corresponding to each line of source code with preset offline code conditions, and determining the offline source code in each line of source code according to the comparison result;
  • the execution status identifier and execution time interval corresponding to each line of source code are sequentially compared with the executed or unexecuted identification and time threshold of the user identification in the preset offline code conditions. . If the execution status identifier of a line of source code is the same as the unexecuted identifier and the execution time interval reaches the set interval threshold, the line of source code meets the offline code conditions, that is, the line of source code is offline source Code. In a specific embodiment, if the execution status of a line of source code is identified as being executed, but the execution time interval does not reach the interval threshold, the line of source code is identified as the code to be monitored, and the subsequent execution of the line of source code is continued The situation is monitored. If the execution status of a certain line of source code is marked as an unexecuted mark, the line of source code is not offline source code.
  • step S20 specifically includes:
  • each line of source code is grouped and identified.
  • each line of source code is divided into a main line code group and a branch code group in advance. Firstly, determine whether the offline main line source code exists in the main line code. If there is the offline main line source code, it is further determined whether the line branch source code corresponding to the offline main line source code is the offline line branch source Code, if it is, then branch the source code of the offline main line and the corresponding offline line to generate a reminder message corresponding to the associated offline source code. If not, a reminder message of offline source code is generated separately based on the offline main source code. If the main line code is not the offline main line source code, but one of its branches is the offline branch source code, a reminder message of the offline source code is generated separately based on the offline branch source code.
  • Step S30 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 based on 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 reminder message reminds developers that the source code corresponding to the target line number may be offline source code.
  • the developer can locate the line source code corresponding to the target line number to confirm according to the reminder message, which improves the identification efficiency.
  • the coverage rate data corresponding to the file to be recognized is obtained through a preset coverage rate proxy tool, and the execution status identifier and execution time interval corresponding to each line of the source code in the file to be recognized in the coverage rate data are obtained, where:
  • the execution time interval is the difference between the current time and the latest 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 According to the comparison result, the offline source code is determined in each line of source code; the target line number of the offline source code is obtained, and the target line number and the file identifier of the file to be identified are generated and displayed The reminder message of the offline source code corresponding to the file to be identified.
  • this application collects 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 combines The offline code conditions, determine the offline source code in each line of source code, that is, the source code that has not been executed, to avoid manual comprehensive review of the entire file code, simplify the identification of offline source code, and improve the offline source code Recognition efficiency solves the technical problems of cumbersome and inefficient operation of manually identifying offline source code.
  • step S10 specifically includes:
  • the coverage data corresponding to each line of the source code in the file to be identified and the GIT information corresponding to the file to be identified are obtained through a preset coverage proxy tool, where the GIT is a type of code warehouse, and the GIT information includes file correspondence The storage path of the GIT path and the version ID commit ID 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 coverage data corresponding to each line of the source code in the first version file is collected to obtain the execution status identifier and the execution time interval corresponding to each line of the source code in the first version file.
  • step S20 specifically includes:
  • the second execution status identifier and the second execution time interval are respectively compared with the offline code conditions, and the offline source code is determined in the suspected offline source code according to the comparison result.
  • the source code that has not been executed is a suspected offline source code
  • the subsequent updated version file it is further monitored whether the suspected offline source code file is still not executed. If it has not been executed, the suspected offline source code is the offline source code. If it is executed, then continue to detect the suspected offline source code, and continue to determine the new suspected offline source code as the monitoring object.
  • the suspected offline source code in the first version file is determined according to the execution status identifier and the execution time interval of each line of the source code in the first version file.
  • the line number of the suspected offline source code in the first version file that is, the first line number
  • quickly locate the suspected offline source code in the second version file and obtain the suspected offline source code.
  • the execution state identification and execution time interval of the line source code in the first version file are the second execution state identification and the second execution time interval. And determine whether the second execution status identifier and the second execution time interval meet the offline code conditions, so as to determine whether the suspected offline source code is still not executed in the second version file, so that all The suspected offline source code is determined to be the offline source code.
  • the first line number of the suspected offline source code in the first version file is determined, and the suspected offline source code is determined in the second version file according to the first line number.
  • the execution status identification and execution time interval of offline source code, as the second execution status identification and the second execution time interval specifically include:
  • the comparison flag 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 Suspected offline source code.
  • the line number of the suspected offline source code in the first version file in the first version file is taken as the first line number, and according to the GIT path information corresponding to the first version file, in the code warehouse GIT, Obtain each line of source code content corresponding to the first version file, and obtain the identification content of the suspected offline source code in the first version file according to the first line number, where the identification content is It can identify whether the source code to be identified is a code identifier that is suspected of offline source code.
  • the suspected offline source code content may 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 the meaning of the offline source code in the second version file is obtained. 2. Execution status identification and second execution time interval.
  • the method further includes :
  • matching 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, namely Is the target line number. And obtain the second execution status identifier and the second execution time interval corresponding to the suspected offline source code in the second version.
  • the step S30 specifically includes:
  • the offline source code of the file to be identified corresponding to the version is generated.
  • the first line number is the target line number
  • the line number 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.
  • the method further includes:
  • the offline source code is identified in the file to be identified in the corresponding version, so that the user can find all the files in the file to be identified in the corresponding version. Describe the offline source code.
  • the offline source code is compared in the corresponding version file
  • the offline identification such as yellow display, is convenient for developers to locate and view.
  • This application also provides a device for identifying offline source code, and the device for identifying offline source code includes:
  • the execution information obtaining module is used to obtain the coverage data corresponding to the file to be identified through the preset coverage proxy tool, and obtain the execution status identifier and execution time corresponding to each line of the source code in the file to be identified in the coverage data Interval, where the execution time interval is the difference between the current time and the latest update time corresponding to each line of source code;
  • the offline code determination module is used to 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 offline code in each line of source code according to the comparison result.
  • Line source code
  • the offline code reminder module is used to obtain the target line number of the offline source code, and generate and display the offline source corresponding to the file to be identified based on the target line number and the file identifier of the file to be identified Code reminder message.
  • execution information acquisition module specifically includes:
  • the file information obtaining unit is configured to obtain the coverage data corresponding to the file to be identified and the code warehouse information GIT information through the coverage proxy tool;
  • the first file acquisition unit is configured to acquire the version identifier corresponding to the file to be identified in the GIT information, and determine the current latest version of the file to be identified according to the version identifier corresponding to the file to be identified, as The first version of the document;
  • the first information obtaining unit is configured to obtain the execution status identifier and the execution time interval corresponding to each line of source code in the first version file.
  • the offline code determination module specifically includes:
  • the first code determination unit is configured to compare the execution status identifier and execution time interval corresponding to each line of source code with the offline code conditions, and determine the suspect in each line of source code according to the comparison result Offline source code;
  • the first file obtaining unit is configured to obtain the updated version file of the file to be recognized as the second version file when it is detected that the file to be recognized has an updated version file;
  • the second information acquisition unit is configured to determine the first line number of the suspected offline source code in the first version file, and determine the suspected source code in the second version file according to the first line number
  • the execution status identifier and the execution time interval of the offline source code are used as the second execution status identifier and the second execution time interval;
  • the offline code determination unit is configured to compare the second execution status identifier and the second execution time interval with the offline code conditions, and determine in the suspected offline source code according to the comparison result The offline source code.
  • the second information acquiring unit is further configured to:
  • the second information acquiring unit is further configured to:
  • offline code determination module is also used for:
  • the offline source code of the file to be identified corresponding to the version is generated.
  • offline code determination module is also used for:
  • the offline source code is identified in the file to be identified in the corresponding version, so that the user can find all the files in the file to be identified in the corresponding version. Describe the offline source code.
  • offline code determination module is also used for:
  • the application also provides a computer-readable storage medium.
  • the computer-readable storage medium of the present application stores an identification program of offline source code, and the identification program of offline source code is executed by a processor to realize the steps of the method for identifying offline source code as described above.
  • the method implemented when the offline source code identification program running on the processor is executed can refer to the various embodiments of the offline source code identification method of this application, which will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Stored Programmes (AREA)

Abstract

一种下线源代码的识别方法、装置、设备及存储介质,该方法通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值(S10);将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码(S20);获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息(S30)。上述方法在各行源代码中确定下线源代码,避免人工全面复盘整个文件代码,简化了下线源代码的识别操作,提高了识别效率。

Description

下线源代码的识别方法、装置、设备及存储介质
本申请要求于2019年6月27日提交中国专利局、申请号为201910573917.3、发明名称为“下线源代码的识别方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及金融科技(Fintech)技术领域,尤其涉及下线源代码的识别方法、装置、设备及计算机可读存储介质。
背景技术
随着计算机技术的发展,越来越多的技术(大数据、分布式、区块链Blockchain、人工智能等)应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,但由于金融行业的安全性、实时性要求,也对技术提出了更高的要求。针对银行的业务系统中可能存在的下线源代码,即相关代码逻辑已经废弃但是在系统项目中未清除、无人维护且存在被调用风险的代码,现有标识方法为通过人工进行下线源代码的识别,若相关开发人员未及时对下线源代码增加相关注解或者说明,则后续人工识别查找下线源代码时,识别操作不仅繁琐,而且识别效率低下。
发明概述
技术问题
问题的解决方案
技术解决方案
本申请的主要目的在于提出一种下线源代码的识别方法、装置、设备及计算机可读存储介质,旨在解决现有人工识别下线源代码的操作繁琐且效率低下的技术问题。
为实现上述目的,本申请提供一种下线源代码的识别方法,所述下线源代码的识别方法包括如下步骤:
通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖 率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;
将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码;
获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。
此外,为实现上述目的,本申请还提供一种下线源代码的识别装置,所述下线源代码的识别装置包括:
执行信息获取模块,用于通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;
下线代码确定模块,用于将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码;
下线代码提醒模块,用于获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。
此外,为实现上述目的,本申请还提供一种下线源代码的识别设备,所述下线源代码的识别设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的下线源代码的识别程序,所述下线源代码的识别程序被所述处理器执行时实现如上所述的下线源代码的识别方法的步骤。
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有下线源代码的识别程序,所述下线源代码的识别程序被处理器执行时实现如上所述的下线源代码的识别方法的步骤。
本申请通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行 时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码;获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。通过上述方式,本申请通过所述覆盖率代理工具采集待识别文件的代码覆盖率数据,基于所述覆盖率数据确定所述待识别文件中的各行源代码的执行状态以及执行时间间隔,并结合下线代码条件,在各行源代码中确定下线源代码,即未执行过的源代码,避免人工全面复盘整个文件代码,简化了下线源代码的识别操作,提高了下线源代码的识别效率,解决了现有人工识别下线源代码的操作繁琐且效率低下的技术问题。
发明的有益效果
对附图的简要说明
附图说明
图1是本申请实施例方案涉及的硬件运行环境的设备结构示意图;
图2为本申请下线源代码的识别方法第一实施例的流程示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
发明实施例
本发明的实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
如图1所示,图1是本申请实施例方案涉及的硬件运行环境的设备结构示意图。
本申请实施例下线源代码的识别设备可以是PC机或服务器设备,其上运行有Java虚拟机。
如图1所示,该下线源代码的识别设备可以包括:处理器1001,例如CPU,网络接口1004,用户接口1003,存储器1005,通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display) 、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。
本领域技术人员可以理解,图1中示出的设备结构并不构成对设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
如图1所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及下线源代码的识别程序。
在图1所示的设备中,网络接口1004主要用于连接后台服务器,与后台服务器进行数据通信;用户接口1003主要用于连接客户端(用户端),与客户端进行数据通信;而处理器1001可以用于调用存储器1005中存储的下线源代码的识别程序,并执行下述下线源代码的识别方法中的操作。
基于上述硬件结构,提出本申请下线源代码的识别方法实施例。
参照图2,图2为本申请下线源代码的识别方法第一实施例的流程示意图,所述下线源代码的识别方法包括:
步骤S10,通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;
目前针对银行的业务系统中可能存在的下线源代码,即相关代码逻辑已经废弃但是在系统项目中未清除、无人维护且存在被调用风险的代码,现有标识方法为通过人工进行下线源代码的识别,若相关开发人员未及时对下线源代码增加相关注解或者说明,则后续人工识别查找下线源代码时,识别操作不仅繁琐,而且识别效率低下。为了解决上述问题,本实施例中提供一种下线源代码的识别方法,通过所述覆盖率代理工具采集待识别文件的代码覆盖率数据,基于所述覆盖率数据确定所述待识别文件中的各行源代码的执行状态以及执行时间间隔,并结合下线代码条件,在各行源代码中确定下线源代码,即未执行过的源 代码,避免人工全面复盘整个文件代码,简化了下线源代码的识别操作,提高了下线源代码的识别效率。具体地,在所述待识别文件对应的应用程序运行之前,接入覆盖率代理工具,用于统计所述待识别文件对应的各行源代码行的覆盖情况,即是否被执行,获取所述待识别文件对应的覆盖率数据。其中,所述覆盖率代理工具实现了java提供的instrumentation API,开发者可以通过该代理工具,监测运行在JVM上的应用程序。具体的监测操作一般是通过在执行某个类文件对应的源代码时,对该类文件的被执行的源代码进行适当的修改。常见的覆盖率代理工具为Cobertura或者Jacoco(Java Code Coverage),覆盖率代理工具可以计算被访问执行的代码的百分比,还可用于识别Java程序代码的哪些代码部分缺少测试覆盖率。其中,所述覆盖率数据为使用覆盖率代理工具采集回来的代码行有无覆盖(即有无执行)的结果数据。其中,所述覆盖率代理工具采集覆盖率数据的过程具体为:通过根据java提供的instrumentation API,在执行过的源代码指令后插入标识字段或标识语句,用于标识该条源代码是否被执行过。由于被执行编译过的源代码带有预设执行标识,因此可以通过判断源代码是否包括执行标识以判断该行源代码是否被执行。即根据所述覆盖率数据获取所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值。
步骤S20,将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码;
本实施例中,将所述各行源代码对应的执行状态标识以及执行时间间隔,依次分别与预设下线代码条件中的用户标识被执行的标识或未被执行的标识以及时间阈值进行比对。若某行源代码的执行状态标识与未被执行的标识相同且执行时间间隔达到了设定的间隔阈值,则该行源代码符合所述下线代码条件,即该行源代码为下线源代码。具体实施例中,若某行源代码的执行状态标识为被执行的标识,但执行时间间隔未达到间隔阈值,则将该行源代码标识为待监测代码,继续对该行源代码的后续执行情况进行监测。若某行源代码的执行状态标识为未被执行的标识,则该行源代码不是下线源代码。
进一步地,步骤S20具体包括:
将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对;
根据比对结果,在所述各行源代码的主行代码中确定下线主行源代码,并判断所述下线主行源代码在所述各行源代码中对应的行分支代码是否为下线行分支源代码;
根据所述下线主行源代码以及对应的下线行分支源代码,确定所述各行源代码中的下线源代码。
为了提高识别效率,将各行源代码进行分组识别。本实施例中,预先将各行源代码分为主行代码组以及分支代码组。首先在主行代码中确定是否存在下线主行源代码,若存在下线主行源代码,则进一步地确定所述下线主行源代码对应的行分支源代码是否为下线行分支源代码,若是,则将所述下线主行源代码以及对应的下线行分支源代码,生成对应关联的下线源代码的提醒消息。若不是,则根据下线主行源代码单独生成下线源代码的提醒消息。若主行代码不是下线主行源代码,但其某一条分支为下线行分支源代码,则根据下线行分支源代码单独生成下线源代码的提醒消息。
步骤S30,获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。
本实施例中,根据所述待识别文件的文件标识以及所述下线源代码在所述待识别文件中的目标行号,生成该待识别文件对应的下线源代码的提醒消息,并显示所述提醒消息提醒开发人员:目标行号对应的源代码可能为下线源代码。开发人员可根据所述提醒消息,定位至目标行号对应的行源代码处进行确认,提高识别效率。
本实施例通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;将所述各行源代码对应的执行状态标识以及执行时间间隔,分 别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码;获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。通过上述方式,本申请通过所述覆盖率代理工具采集待识别文件的代码覆盖率数据,基于所述覆盖率数据确定所述待识别文件中的各行源代码的执行状态以及执行时间间隔,并结合下线代码条件,在各行源代码中确定下线源代码,即未执行过的源代码,避免人工全面复盘整个文件代码,简化了下线源代码的识别操作,提高了下线源代码的识别效率,解决了现有人工识别下线源代码的操作繁琐且效率低下的技术问题。
进一步地,基于本申请下线源代码的识别方法第一实施例,提出本申请下线源代码的识别方法第二实施例。
在本实施例中,所述步骤S10具体包括:
通过所述覆盖率代理工具获取所述待识别文件对应的覆盖率数据以及代码仓库信息GIT信息;
获取所述GIT信息中的所述待识别文件对应的版本标识,并根据所述待识别文件对应的版本标识,确定所述待识别文件的当前最新版本文件,作为第一版本文件;
获取所述第一版本文件中的各行源代码对应的执行状态标识以及执行时间间隔。
为了提升识别的准确度,本实施例中,进一步对待识别文件的下一更新版本中的下线源代码进行确认是否仍未被执行。具体地,通过预设覆盖率代理工具获取待识别文件中各行源代码对应的覆盖率数据以及该待识别文件对应的GIT信息,其中,所述GIT为代码仓库的一种,GIT信息包括文件对应的存储路径GIT路径以及文件对应的版本标识commit ID。其中,版本标识为一个待识别文件进行一次编译后,生成的下一版本文件对应的版本号。获取GIT仓库中当前最新版本的待识别文件,作为第一版本文件。对所述第一版本文件中的各行源代码对应的覆盖率数据进行采集,以获取所述第一版本文件中各行源代码对应的执行状态标识以及执行时间间隔。
进一步地,所述步骤S20具体包括:
将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定疑似下线源代码;
在检测到所述待识别文件存在更新版本文件时,获取所述待识别文件的更新版本文件,作为第二版本文件;
确定所述疑似下线源代码在所述第一版本文件中的第一行号,并根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为第二执行状态标识以及第二执行时间间隔;
将所述第二执行状态标识以及第二执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述疑似下线源代码中确定所述下线源代码。
本实施例中,在第一版本文件中确定未执行过的源代码为疑似下线源代码,并在后续更新版本文件中进一步监测所述疑似下线源代码文件是否仍旧未被执行。若仍未被执行,则所述疑似下线源代码即为下线源代码。若被执行,则后续继续对所述疑似下线源代码进行检测,并继续确定新的疑似下线源代码,作为监测对象。具体地,根据第一版本文件中各行源代码的执行状态标识以及执行时间间隔,确定第一版本文件中的疑似下线源代码。在检测到所述GIT仓库中存在更新版本文件时,进一步检测所述更新版本文件,作为第二版本文件。根据所述疑似下线源代码在所述第一版本文件中的行号,即第一行号,在所述第二版本文件中快速定位所述疑似下线源代码,并获取所述疑似下线源代码在所述第一版本文件中的执行状态标识与执行时间间隔,即为第二执行状态标识以及第二执行时间间隔。并判断所述第二执行状态标识以及第二执行时间间隔是否符合所述下线代码条件,从而确定所述疑似下线源代码在所述第二版本文件中是否仍旧未被执行,从而将所述疑似下线源代码确定为下线源代码。
进一步地,基于本申请下线源代码的识别方法第二实施例,提出本申请下线源代码的识别方法第三实施例。
在本实施例中,所述确定所述疑似下线源代码在所述第一版本文件中的第一行号,并根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执 行状态标识以及执行时间间隔,作为第二执行状态标识以及第二执行时间间隔的步骤具体包括:
确定所述疑似下线源代码在所述第一版本文件中的第一行号,获取所述GIT信息中所述第一版本文件对应的GIT路径信息,作为第一路径信息;
根据所述第一路径信息以及所述第一行号,在所述第一版本文件中获取所述疑似下线源代码的标识内容;
获取所述GIT信息中所述第二版本文件对应的GIT路径信息,作为第二路径信息;
根据所述第二路径信息、第一行号以及标识内容,判断所述疑似下线源代码在所述第二版本文件中的代码行号是否发生变化;
若未发生变化,则根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为所述疑似下线源代码的第二执行状态标识以及第二执行时间间隔。
为了防止疑似下线源代码的行号发生变化,本实施例中,增加疑似下线源代码的比对标识,以便确定所述第二版本文件中所述第一行号对应的源代码是否为疑似下线源代码。具体地,将第一版本文件中的疑似下线源代码在第一版本文件中的行号作为第一行号,并根据所述第一版本文件对应的GIT路径信息,在代码仓库GIT中,获取所述第一版本文件对应的各行源代码内容,并根据所述第一行号,在所述第一版本文件中获取所述疑似下线源代码的标识内容,其中,所述标识内容为可以识别待识别源代码是否为疑似下线源代码的代码标识。如:疑似下线源代码的前几行代码以及最后几行代码,或者主要开头代码字节、中间的特定代码字节以及结尾代码字节等。具体实施例中,在疑似下线源代码对应的代码内容较少时,还可以将所述疑似下线源代码内容直接作为标识内容。定位至第二版本文件中的第一行号对应的代码内容,并根据所述标识内容,判断所述疑似下线源代码在所述第二版本文件中的代码行号是否发生变化。若没有发生变化,则确定所述第二版本文件中所述第一行号对应的源代码,为疑似下线源代码,获取所述意思下线源代码在所述第二版本文件中的第二执行状态标识以及第二执行时间间隔。
进一步地,所述根据所述第二路径信息、第一行号以及标识内容,判断所述疑似下线源代码在所述第二版本文件中的代码行号是否发生变化的步骤之后,还包括:
若发生变化,则根据所述标识内容,在所述第二版本文件中确定所述疑似下线源代码的第二行号;
根据所述第二行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为所述疑似下线源代码的第二执行状态标识以及第二执行时间间隔。
本实施例中,若发生变化,则根据所述标识内容在所述第二版本文件中进行匹配,以查找所述疑似下线源代码在所述第二版本文件中的第二行号,即为目标行号。并获取所述第二版本中所述疑似下线源代码对应的第二执行状态标识以及第二执行时间间隔。
进一步地,基于第三实施例,所述步骤S30具体包括:
获取所述下线源代码的目标行号,根据所述目标行号确定所述下线源代码的行号范围;
根据所述行号范围、版本标识以及文件标识,生成对应版本的待识别文件的下线源代码。
本实施例中,若所述疑似下线源代码在所述第二版本文件中未发生行号变化,则所述第一行号为所述目标行号,若发生行号变化,则所述第二行号为所述目标行号。根据所述目标行号对应的下线源代码的行号范围,即行号集合,以及对应的版本标识以及文件标识,生成对应的下线源代码提醒消息。
进一步地,所述根据所述行号范围、版本标识以及文件标识,生成对应版本的待识别文件的下线源代码的步骤之后,还包括:
根据所述下线源代码的行号范围、版本标识以及文件标识,在对应版本的待识别文件中将所述下线源代码进行下线标识,以便用户在对应版本的待识别文件中查找所述下线源代码。
为了便于开发人员在待识别文件中定位该下线源代码,本实施例中,进一步根据所述下线源代码的行号范围、版本标识以及文件标识,在对应版本文件中对 下线源代码进行下线标识,如标黄显示,便于开发人员定位查看。
本申请还提供一种下线源代码的识别装置,所述下线源代码的识别装置包括:
执行信息获取模块,用于通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;
下线代码确定模块,用于将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码;
下线代码提醒模块,用于获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。
进一步地,所述执行信息获取模块具体包括:
文件信息获取单元,用于通过所述覆盖率代理工具获取所述待识别文件对应的覆盖率数据以及代码仓库信息GIT信息;
第一文件获取单元,用于获取所述GIT信息中的所述待识别文件对应的版本标识,并根据所述待识别文件对应的版本标识,确定所述待识别文件的当前最新版本文件,作为第一版本文件;
第一信息获取单元,用于获取所述第一版本文件中的各行源代码对应的执行状态标识以及执行时间间隔。
进一步地,所述下线代码确定模块具体包括:
第一代码确定单元,用于将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定疑似下线源代码;
第一文件获取单元,用于在检测到所述待识别文件存在更新版本文件时,获取所述待识别文件的更新版本文件,作为第二版本文件;
第二信息获取单元,用于确定所述疑似下线源代码在所述第一版本文件中的第一行号,并根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码 的执行状态标识以及执行时间间隔,作为第二执行状态标识以及第二执行时间间隔;
下线代码确定单元,用于将所述第二执行状态标识以及第二执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述疑似下线源代码中确定所述下线源代码。
进一步地,所述第二信息获取单元还用于:
确定所述疑似下线源代码在所述第一版本文件中的第一行号,获取所述GIT信息中所述第一版本文件对应的GIT路径信息,作为第一路径信息;
根据所述第一路径信息以及所述第一行号,在所述第一版本文件中获取所述疑似下线源代码的标识内容;
获取所述GIT信息中所述第二版本文件对应的GIT路径信息,作为第二路径信息;
根据所述第二路径信息、第一行号以及标识内容,判断所述疑似下线源代码在所述第二版本文件中的代码行号是否发生变化;
若未发生变化,则根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为所述疑似下线源代码的第二执行状态标识以及第二执行时间间隔。
进一步地,所述第二信息获取单元还用于:
若发生变化,则根据所述标识内容,在所述第二版本文件中确定所述疑似下线源代码的第二行号;
根据所述第二行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为所述疑似下线源代码的第二执行状态标识以及第二执行时间间隔。
进一步地,所述下线代码确定模块还用于:
获取所述下线源代码的目标行号,根据所述目标行号确定所述下线源代码的行号范围;
根据所述行号范围、版本标识以及文件标识,生成对应版本的待识别文件的下线源代码。
进一步地,所述下线代码确定模块还用于:
根据所述下线源代码的行号范围、版本标识以及文件标识,在对应版本的待识别文件中将所述下线源代码进行下线标识,以便用户在对应版本的待识别文件中查找所述下线源代码。
进一步地,所述下线代码确定模块还用于:
将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对;
根据比对结果,在所述各行源代码的主行代码中确定下线主行源代码,并判断所述下线主行源代码在所述各行源代码中对应的行分支代码是否为下线行分支源代码;
根据所述下线主行源代码以及对应的下线行分支源代码,确定所述各行源代码中的下线源代码。
上述各程序模块所执行的方法可参照本申请下线源代码的识别方法各个实施例,此处不再赘述。
本申请还提供一种计算机可读存储介质。
本申请计算机可读存储介质上存储有下线源代码的识别程序,所述下线源代码的识别程序被处理器执行时实现如上所述的下线源代码的识别方法的步骤。
其中,在所述处理器上运行的下线源代码的识别程序被执行时所实现的方法可参照本申请下线源代码的识别方法各个实施例,此处不再赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个......”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件, 但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种下线源代码的识别方法,其中,所述下线源代码的识别方法包括如下步骤:
    通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;
    将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码;
    获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。
  2. 如权利要求1所述的下线源代码的识别方法,其中,所述通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔的步骤具体包括:
    通过所述覆盖率代理工具获取所述待识别文件对应的覆盖率数据以及代码仓库信息GIT信息;
    获取所述GIT信息中的所述待识别文件对应的版本标识,并根据所述待识别文件对应的版本标识,确定所述待识别文件的当前最新版本文件,作为第一版本文件;
    获取所述第一版本文件中的各行源代码对应的执行状态标识以及执行时间间隔。
  3. 如权利要求2所述的下线源代码的识别方法,其中,所述将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码的步骤具体包括:
    将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定疑似下线源代码;
    在检测到所述待识别文件存在更新版本文件时,获取所述待识别文件的更新版本文件,作为第二版本文件;
    确定所述疑似下线源代码在所述第一版本文件中的第一行号,并根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为第二执行状态标识以及第二执行时间间隔;
    将所述第二执行状态标识以及第二执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述疑似下线源代码中确定所述下线源代码。
  4. 如权利要求3所述的下线源代码的识别方法,其中,所述确定所述疑似下线源代码在所述第一版本文件中的第一行号,并根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为第二执行状态标识以及第二执行时间间隔的步骤具体包括:
    确定所述疑似下线源代码在所述第一版本文件中的第一行号,获取所述GIT信息中所述第一版本文件对应的GIT路径信息,作为第一路径信息;
    根据所述第一路径信息以及所述第一行号,在所述第一版本文件中获取所述疑似下线源代码的标识内容;
    获取所述GIT信息中所述第二版本文件对应的GIT路径信息,作为第二路径信息;
    根据所述第二路径信息、第一行号以及标识内容,判断所述疑似下线源代码在所述第二版本文件中的代码行号是否发生变化;
    若未发生变化,则根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为所 述疑似下线源代码的第二执行状态标识以及第二执行时间间隔。
  5. 如权利要求4所述的下线源代码的识别方法,其中,所述根据所述第二路径信息、第一行号以及标识内容,判断所述疑似下线源代码在所述第二版本文件中的代码行号是否发生变化的步骤之后,还包括:
    若发生变化,则根据所述标识内容,在所述第二版本文件中确定所述疑似下线源代码的第二行号;
    根据所述第二行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为所述疑似下线源代码的第二执行状态标识以及第二执行时间间隔。
  6. 如权利要求4所述的下线源代码的识别方法,其中,所述获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息的步骤具体包括:
    获取所述下线源代码的目标行号,根据所述目标行号确定所述下线源代码的行号范围;
    根据所述行号范围、版本标识以及文件标识,生成对应版本的待识别文件的下线源代码。
  7. 如权利要求6所述的下线源代码的识别方法,其中,所述根据所述行号范围、版本标识以及文件标识,生成对应版本的待识别文件的下线源代码的步骤之后,还包括:
    根据所述下线源代码的行号范围、版本标识以及文件标识,在对应版本的待识别文件中将所述下线源代码进行下线标识,以便用户在对应版本的待识别文件中查找所述下线源代码。
  8. 如权利要1所述的下线源代码的识别方法,其中,所述将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码的步骤具体包括:
    将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对;
    根据比对结果,在所述各行源代码的主行代码中确定下线主行源代码,并判断所述下线主行源代码在所述各行源代码中对应的行分支代码是否为下线行分支源代码;
    根据所述下线主行源代码以及对应的下线行分支源代码,确定所述各行源代码中的下线源代码。
  9. 一种下线源代码的识别装置,其中,所述下线源代码的识别装置包括:
    执行信息获取模块,用于通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;
    下线代码确定模块,用于将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码;
    下线代码提醒模块,用于获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。
  10. 如权利要求9所述的下线源代码的识别装置,其中,所述执行信息获取模块具体包括:
    文件信息获取单元,用于通过所述覆盖率代理工具获取所述待识别文件对应的覆盖率数据以及代码仓库信息GIT信息;
    第一文件获取单元,用于获取所述GIT信息中的所述待识别文件对应的版本标识,并根据所述待识别文件对应的版本标识,确定所述待识别文件的当前最新版本文件,作为第一版本文件;
    第一信息获取单元,用于获取所述第一版本文件中的各行源代码 对应的执行状态标识以及执行时间间隔。
  11. 如权利要求10所述的下线源代码的识别装置,其中,所述下线代码确定模块具体包括:
    第一代码确定单元,用于将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定疑似下线源代码;
    第一文件获取单元,用于在检测到所述待识别文件存在更新版本文件时,获取所述待识别文件的更新版本文件,作为第二版本文件;
    第二信息获取单元,用于确定所述疑似下线源代码在所述第一版本文件中的第一行号,并根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为第二执行状态标识以及第二执行时间间隔;
    下线代码确定单元,用于将所述第二执行状态标识以及第二执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述疑似下线源代码中确定所述下线源代码。
  12. 如权利要求11所述的下线源代码的识别装置,其中,所述第二信息获取单元还用于:
    确定所述疑似下线源代码在所述第一版本文件中的第一行号,获取所述GIT信息中所述第一版本文件对应的GIT路径信息,作为第一路径信息;
    根据所述第一路径信息以及所述第一行号,在所述第一版本文件中获取所述疑似下线源代码的标识内容;
    获取所述GIT信息中所述第二版本文件对应的GIT路径信息,作为第二路径信息;
    根据所述第二路径信息、第一行号以及标识内容,判断所述疑似下线源代码在所述第二版本文件中的代码行号是否发生变化;
    若未发生变化,则根据所述第一行号在所述第二版本文件中确定 所述疑似下线源代码的执行状态标识以及执行时间间隔,作为所述疑似下线源代码的第二执行状态标识以及第二执行时间间隔。
  13. 如权利要求12所述的下线源代码的识别装置,其中,所述第二信息获取单元还用于:
    若发生变化,则根据所述标识内容,在所述第二版本文件中确定所述疑似下线源代码的第二行号;
    根据所述第二行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为所述疑似下线源代码的第二执行状态标识以及第二执行时间间隔。
  14. 如权利要求9所述的下线源代码的识别装置,其中,所述下线代码确定模块还用于:
    将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对;
    根据比对结果,在所述各行源代码的主行代码中确定下线主行源代码,并判断所述下线主行源代码在所述各行源代码中对应的行分支代码是否为下线行分支源代码;
    根据所述下线主行源代码以及对应的下线行分支源代码,确定所述各行源代码中的下线源代码。
  15. 一种下线源代码的识别设备,其中,所述下线源代码的识别设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的下线源代码的识别程序,所述下线源代码的识别程序被所述处理器执行时实现如下步骤:
    通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;
    将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源 代码中确定下线源代码;
    获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。
  16. 如权利要求15所述的下线源代码的识别设备,其中,所述下线源代码的识别程序被所述处理器执行时还实现如下步骤:
    通过所述覆盖率代理工具获取所述待识别文件对应的覆盖率数据以及代码仓库信息GIT信息;
    获取所述GIT信息中的所述待识别文件对应的版本标识,并根据所述待识别文件对应的版本标识,确定所述待识别文件的当前最新版本文件,作为第一版本文件;
    获取所述第一版本文件中的各行源代码对应的执行状态标识以及执行时间间隔。
  17. 如权利要求15所述的下线源代码的识别设备,其中,所述下线源代码的识别程序被所述处理器执行时还实现如下步骤:
    将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述各行源
    代码中确定疑似下线源代码;在检测到所述待识别文件存在更新版本文件时,获取所述待识别文件的更新版本文件,作为第二版本文件;
    确定所述疑似下线源代码在所述第一版本文件中的第一行号,并根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为第二执行状态标识以及第二执行时间间隔;
    将所述第二执行状态标识以及第二执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述疑似下线源代码中确定所述下线源代码。
  18. 一种计算机可读存储介质,其中,所述计算机可读存储介质上存 储有下线源代码的识别程序,所述下线源代码的识别程序被处理器执行时实现如下步骤:
    通过预设覆盖率代理工具获取待识别文件对应的覆盖率数据,并获取所述覆盖率数据中所述待识别文件中的各行源代码对应的执行状态标识以及执行时间间隔,其中,所述执行时间间隔为当前时间与各行源代码对应的最近更新时间的差值;
    将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与预设下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定下线源代码;
    获取所述下线源代码的目标行号,并根据所述目标行号以及所述待识别文件的文件标识,生成并显示所述待识别文件对应的下线源代码的提醒消息。
  19. 如权利要求18所述的计算机可读存储介质,其中,所述下线源代码的识别程序被所述处理器执行时还实现如下步骤:
    通过所述覆盖率代理工具获取所述待识别文件对应的覆盖率数据以及代码仓库信息GIT信息;
    获取所述GIT信息中的所述待识别文件对应的版本标识,并根据所述待识别文件对应的版本标识,确定所述待识别文件的当前最新版本文件,作为第一版本文件;
    获取所述第一版本文件中的各行源代码对应的执行状态标识以及执行时间间隔。
  20. 如权利要求18所述的计算机可读存储介质,其中,所述下线源代码的识别程序被所述处理器执行时还实现如下步骤:
    将所述各行源代码对应的执行状态标识以及执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述各行源代码中确定疑似下线源代码;
    在检测到所述待识别文件存在更新版本文件时,获取所述待识别文件的更新版本文件,作为第二版本文件;
    确定所述疑似下线源代码在所述第一版本文件中的第一行号,并根据所述第一行号在所述第二版本文件中确定所述疑似下线源代码的执行状态标识以及执行时间间隔,作为第二执行状态标识以及第二执行时间间隔;
    将所述第二执行状态标识以及第二执行时间间隔,分别与所述下线代码条件进行比对,并根据对比结果,在所述疑似下线源代码中确定所述下线源代码。
PCT/CN2020/085682 2019-06-27 2020-04-20 下线源代码的识别方法、装置、设备及存储介质 WO2020259034A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910573917.3A CN110321144A (zh) 2019-06-27 2019-06-27 下线源代码的识别方法、装置、设备及存储介质
CN201910573917.3 2019-06-27

Publications (1)

Publication Number Publication Date
WO2020259034A1 true WO2020259034A1 (zh) 2020-12-30

Family

ID=68120567

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/085682 WO2020259034A1 (zh) 2019-06-27 2020-04-20 下线源代码的识别方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN110321144A (zh)
WO (1) WO2020259034A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116701182A (zh) * 2023-05-10 2023-09-05 合芯科技有限公司 一种覆盖率标记文件更新方法、装置、设备及存储介质

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110321144A (zh) * 2019-06-27 2019-10-11 深圳前海微众银行股份有限公司 下线源代码的识别方法、装置、设备及存储介质
CN113537780B (zh) * 2021-07-19 2024-05-14 浪潮通用软件有限公司 一种通过api测试覆盖度考核的方法、设备及介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120192150A1 (en) * 2011-01-20 2012-07-26 Fujitsu Limited Software Architecture for Validating C++ Programs Using Symbolic Execution
CN103019933A (zh) * 2012-11-27 2013-04-03 网宿科技股份有限公司 测试用例覆盖度自动识别方法及装置
US20150169431A1 (en) * 2013-12-18 2015-06-18 Google Inc. Process for displaying test coverage data during code reviews
CN108132790A (zh) * 2017-12-22 2018-06-08 广州酷狗计算机科技有限公司 检测无用代码的方法、装置及计算机存储介质
CN108628615A (zh) * 2018-03-22 2018-10-09 阿里巴巴集团控股有限公司 一种废弃代码检测方法、装置以及设备
CN110321144A (zh) * 2019-06-27 2019-10-11 深圳前海微众银行股份有限公司 下线源代码的识别方法、装置、设备及存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120192150A1 (en) * 2011-01-20 2012-07-26 Fujitsu Limited Software Architecture for Validating C++ Programs Using Symbolic Execution
CN103019933A (zh) * 2012-11-27 2013-04-03 网宿科技股份有限公司 测试用例覆盖度自动识别方法及装置
US20150169431A1 (en) * 2013-12-18 2015-06-18 Google Inc. Process for displaying test coverage data during code reviews
CN108132790A (zh) * 2017-12-22 2018-06-08 广州酷狗计算机科技有限公司 检测无用代码的方法、装置及计算机存储介质
CN108628615A (zh) * 2018-03-22 2018-10-09 阿里巴巴集团控股有限公司 一种废弃代码检测方法、装置以及设备
CN110321144A (zh) * 2019-06-27 2019-10-11 深圳前海微众银行股份有限公司 下线源代码的识别方法、装置、设备及存储介质

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116701182A (zh) * 2023-05-10 2023-09-05 合芯科技有限公司 一种覆盖率标记文件更新方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN110321144A (zh) 2019-10-11

Similar Documents

Publication Publication Date Title
WO2020259034A1 (zh) 下线源代码的识别方法、装置、设备及存储介质
CN110113200A (zh) 链路系统与日志系统的关联方法、装置及存储介质
CN107273280B (zh) 一种日志处理方法、装置、电子设备和存储介质
CN107453960B (zh) 一种在服务测试中处理测试数据的方法、装置和系统
US7305465B2 (en) Collecting appliance problem information over network and providing remote technical support to deliver appliance fix information to an end user
US20200242015A1 (en) Automated test case management systems and methods
CN111752843B (zh) 用于确定影响面的方法、装置、电子设备及可读存储介质
US10353762B2 (en) Hierarchical fault determination in an application performance management system
US10402310B1 (en) Systems and methods for reducing storage required for code coverage results
US7913233B2 (en) Performance analyzer
JP2008508597A (ja) ヘルプユーティリティアプリケーションプログラム
US9965252B2 (en) Method and system for generating stateflow models from software requirements
WO2020244307A1 (zh) 一种漏洞检测方法及装置
CN111158741A (zh) 监控业务模块对第三方类库依赖关系变化的方法及装置
CN108536867A (zh) 用于生成信息的方法和装置
CN111654495B (zh) 用于确定流量产生来源的方法、装置、设备及存储介质
CN113360376A (zh) 埋点测试方法和装置
CN111047434A (zh) 一种操作记录生成方法、装置、计算机设备和存储介质
CN113641544B (zh) 用于检测应用状态的方法、装置、设备、介质和产品
CN110990346A (zh) 基于区块链的文件数据处理方法、装置、设备及存储介质
CN110688305B (zh) 测试环境同步方法、装置、介质、电子设备
US20110107318A1 (en) Simplifying Maintenance of Large Software Systems
CN113094236A (zh) 一种系统数据采集方法、装置、计算机设备及存储介质
CN113495723B (zh) 一种调用功能组件的方法、装置及存储介质
CN107872493B (zh) 一种信息处理方法、终端和服务器

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20831389

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20831389

Country of ref document: EP

Kind code of ref document: A1