WO2020253080A1 - 项目代码的维护方法、装置、计算机设备和存储介质 - Google Patents
项目代码的维护方法、装置、计算机设备和存储介质 Download PDFInfo
- Publication number
- WO2020253080A1 WO2020253080A1 PCT/CN2019/119072 CN2019119072W WO2020253080A1 WO 2020253080 A1 WO2020253080 A1 WO 2020253080A1 CN 2019119072 W CN2019119072 W CN 2019119072W WO 2020253080 A1 WO2020253080 A1 WO 2020253080A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- method name
- code
- code file
- name
- called
- Prior art date
- Legal status (The legal status 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 status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/443—Optimisation
- G06F8/4434—Reducing the memory space required by the program code
- G06F8/4435—Detection or removal of dead or redundant code
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
Definitions
- This application relates to the field of research and development management, and in particular to a method, device, computer equipment, and storage medium for maintaining project code.
- developers will rewrite a lot of repeated code due to various factors such as time, location, and project, or after the methods in the code are abandoned, they remain in the class, which is not conducive to subsequent acceptance Developers or maintainers maintain or rectify the code in the project; and when the amount of code in a project accumulates too much, it may even cause the file to be too large when the product is released, which affects the release and promotion.
- the purpose of this application is to provide a method, device, computer equipment, and storage medium for maintaining project code in view of the deficiencies of the prior art. Through detection of method names and comments in code files, to obtain abandoned code segments, it can be effective Clean up the code, improve the efficiency of code operation, and facilitate the later maintenance of the code.
- the technical solution of the present application provides a method, device, computer equipment, and storage medium for maintaining project code.
- This application discloses a method for maintaining project code, including the following steps:
- the method names and comments in each code file are cleaned up according to the number of times the method name is called.
- the application also discloses a maintenance device for project code, the device includes:
- Code scanning module set to obtain multiple code files in the project, number each code file, scan the code in each code file, and obtain the method name and the code in each code file Annotation, corresponding the method name and annotation with the number of each code file, and store them in the database;
- Data summary module set to summarize the method names in the database and obtain the number of times each method name is called;
- Code maintenance module set to clean up method names and comments in each code file according to the number of times the method name is called.
- the application also discloses a computer device, the computer device includes a memory and a processor, the memory stores computer-readable instructions, and when the computer-readable instructions are executed by one or more of the processors, One or more of the processors perform the following steps:
- the method names and comments in each code file are cleaned up according to the number of times the method name is called.
- the application also discloses a computer-readable storage medium.
- the computer-readable storage medium can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.
- the storage medium can be processed
- the storage medium stores computer instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors perform the following steps:
- the method names and comments in each code file are cleaned up according to the number of times the method name is called.
- this application obtains abandoned code segments through detection of method names and comments in code files, which can effectively clean up the code, improve code operation efficiency, and facilitate subsequent maintenance of the code.
- FIG. 1 is a schematic flowchart of a method for maintaining project code according to the first embodiment of this application;
- FIG. 2 is a schematic flowchart of a method for maintaining project code according to a second embodiment of the application
- FIG. 3 is a schematic flowchart of a method for maintaining a project code according to a third embodiment of this application;
- FIG. 4 is a schematic flowchart of a method for maintaining a project code according to a fourth embodiment of this application.
- FIG. 5 is a schematic flowchart of a method for maintaining a project code according to a fifth embodiment of this application.
- FIG. 6 is a schematic flowchart of a method for maintaining a project code according to a sixth embodiment of this application.
- FIG. 7 is a schematic flowchart of a method for maintaining a project code according to a sixth embodiment of this application.
- Fig. 8 is a schematic structural diagram of a maintenance device for project codes according to an embodiment of the application.
- Fig. 1 The process of a method for maintaining a project code in the first embodiment of this application is shown in Fig. 1. This embodiment includes the following steps:
- Step s101 Obtain multiple code files in the project, number each code file, scan the code in each code file to obtain the method name and comment in the code of each code file, and The method name and comment correspond to the serial number of each code file and are stored in the database;
- each development project usually contains multiple code files, and each code file contains many methods, classes, and interfaces.
- the methods, classes, and interfaces may call each other, so the entire All code files of the project are scanned, and the code files can be numbered before scanning the code files.
- the numbering rule can be numbered with numbers or subtitles to distinguish each code.
- File; the scanning can be carried out through the reflection mechanism of java, the reflection mechanism of java means that in the running state, for any class, all attributes and methods of this class can be known; for any object, it can be called Its arbitrary methods and attributes; this function of dynamically obtaining information and dynamically calling object methods is called the reflection mechanism of the java language.
- the method name refers to the name of each calling method
- the comment refers to a comment on the calling method, wherein the calling method is a part of the program, and the comment is not a part of the program.
- the specific position of the method name and comment can be recorded, and the position includes the position of the first and last lines of the method name, and the comment
- the position of the first line and the end of the line, and the method name and comment are corresponding to the code file number, and stored in the database.
- Step s102 Collect the method names in the database to obtain the number of times each method name is called;
- the method name can be obtained by counting the number of times the method name appears in the code file. The number of times each method name was called.
- step s103 the method names and comments in each code file are cleaned up according to the number of times the method name is called.
- each method name in the code file has a corresponding comment. If the method name has a comment, then the method name and the comment can be directly cleaned up.
- the method name is found to be uncommented through detection, after the number of times the method name is called is obtained, it can be determined whether the method name is frequently called according to the number of times the method name is called, for example, Set a threshold for the number of calls, and compare the number of calls of the method name with the threshold of the number of calls. If the number of calls of the method name is greater than the threshold of the number of calls, it means that the method name is frequently called, Code segments that are not idle or redundant cannot be deleted directly, otherwise the method name can be cleaned up according to the position of the method name in the code file.
- the code can be effectively cleaned up, code operation efficiency is improved, and later maintenance of the code is beneficial.
- FIG. 2 is a schematic flow chart of a method for maintaining project codes according to the second embodiment of the application. As shown in the figure, in step s101, each code file is numbered and the code in each code file is Scan to obtain the method name in the code of each code file, including:
- each code file is numbered, and the codes in each code file are sequentially scanned according to the numbering sequence to obtain the method name in the code of each code file;
- each code file can be numbered to distinguish all code files; then, each code file can be sequentially numbered according to the sequence of the code files.
- the code of each code file can be scanned.
- the numbering sequence can be from large to small or from small to large. You only need to traverse and scan all the code files. After scanning, you can get the code of each code file The method name.
- Step s202 query in the code file corresponding to the method name according to the method name, obtain the first line position and the last line position of the method name in the code file corresponding to the method name, and store them in the database in.
- the corresponding code file can be queried according to the method name, and the number of lines of code corresponding to the method name can be obtained. Since a calling method usually contains a piece of code , Which includes many lines of code, so the number of lines of code includes the first line position and the last line position.
- the method name can be effectively deleted.
- Figure 3 is a schematic flow chart of a method for maintaining project code according to the third embodiment of the application. As shown in the figure, the step s101, obtaining the comments in the code of each code file, includes:
- Step s301 preset the first annotation mark, the second annotation mark, the first detection line number and the second detection line number;
- the first annotation mark and the second annotation mark are used to detect whether the annotation exists and the specific position in the code file.
- the first annotation mark may be a "//" symbol
- the The second comment mark can be the "/*" symbol, among which, because the comment mark is not part of the program, it usually appears in pairs to identify the beginning and the end. If it starts with a "//” symbol, it will start with "// "Symbol ends, if it starts with a "/*” symbol, it ends with a "*/” symbol.
- the number of detection lines corresponds to the annotation mark
- the number of detection lines is used to detect the annotation mark on the number of detection lines before calling the method, because usually the "//" symbol only appears In the same line, that is, in the previous line of the calling method, the number of the first detection line can be set to 1 line, and usually the "/*" symbol may appear in multiple lines, that is, before calling the method It appears in several rows, generally around 4-5 rows, and rarely more than 10 rows, so the second detection row number can be set to 10 rows.
- Step s302 Perform detection on the first detection line number before the first line position of the method name according to the first annotation mark, and if the first annotation mark exists, record the first annotation mark The first row position and the last row position;
- the detection is performed on the first detection line number before the first line position of the method name according to the first annotation mark in step s301, and if the first detection line number is set to 1, then Perform detection on the line before the first line of the method name to detect whether there is a symbol corresponding to the first comment mark. If so, it means that there is a comment, and record the first comment mark.
- Line position and last line position if there is only one line, the first line position and last line position are the same.
- Step s303 Perform detection on the second detection line number before the first line position of the method name according to the second annotation mark, and if the second annotation mark exists, record the second annotation mark The position of the first line and the end of the line.
- the detection is performed on the second detection line number before the first line position of the method name according to the second annotation mark in step s301, if the second detection line number is set to 10, then Detect one by one from the first 10 lines to the first line of the first line of the method name, and check whether there is a symbol corresponding to the first comment mark. If there is, it means that there is a comment. Record the first The position of the first line and the last line of the comment mark.
- FIG. 4 is a schematic flow chart of a method for maintaining project code according to the fourth embodiment of the application. As shown in the figure, in step s102, the method names in the database are summarized to obtain the call of each method name Frequency, including:
- Step s401 query in the database according to the method name to obtain the serial number of all code files corresponding to each method name;
- all method names can be summarized in the database, and then the number of times each method name has been called is counted separately.
- the counting of the number of times each method name is called can be calculated by counting the number of times each method name is called.
- the number of code files is performed, that is, the method name is used to query the database to obtain all the code file numbers corresponding to the method name, where one code file number represents one time.
- step s402 the number of code files corresponding to the method name is counted according to the number of the code file to obtain the number of times each method name is called.
- the number of code files corresponding to the method name can be counted according to the number of the code file, and the number of times each method name is called can be obtained and cached.
- Figure 5 is a schematic flow chart of a method for maintaining project code according to the fifth embodiment of this application. As shown in the figure, in step s103, the method in each code file is checked according to the number of times the method name is called. Names and comments are cleaned up, including:
- Step s501 preset the first method type, the second method type, the first cumulative times threshold and the second cumulative times threshold;
- calling methods can be divided into interface classes and implementation classes. Among them, the idle or redundant judgments of the calling methods corresponding to the interface class and the implementation class are also different. For example, the calling method of the implementation class only Once called once, the calling method can be considered to be more important and cannot be cleaned up; while the calling method of the interface class needs to be called multiple times before it can be considered to be more important and cannot be cleaned up.
- the first method type, the second method type, the first cumulative times threshold, and the second cumulative times threshold can be preset, wherein the first method type and the second method type are used to distinguish between an interface type and an implementation type
- the first cumulative count threshold and the second cumulative count threshold correspond to the method type, and are used to determine whether the calling method corresponding to the method type needs to be cleaned up.
- Step s502 Detect the method type called by the method name, and if the method type called by the method name is the first method type, compare the number of times the method name is called to the first cumulative number threshold For comparison, if the method type of the method name being called is the second method type, the number of times the method name is called is compared with the second cumulative times threshold.
- the method type called by the method name can be detected. If it is detected that the method type called by the method name is the first method type, the number of times the method name is called can be compared with the The first cumulative times threshold is compared. For example, if the first method type is an interface class, the first cumulative times threshold can be set to 2, and if the method name is called more than 2, it means The method name should not be cleared; if it is detected that the method type called by the method name is the second method type, the number of times the method name is called may be compared with the second cumulative number threshold Yes, for example, if the second method type is an implementation class, the first cumulative number of times threshold can be set to 1, if the number of times the method name is called is greater than 1, it means that the method name should not be cleaned up .
- the calling method by detecting the method type of the calling method and the number of times it is called, the calling method can be effectively cleaned up and the code running efficiency is improved.
- Figure 6 is a schematic flow chart of a method for maintaining project code according to the sixth embodiment of the application. As shown in the figure, in step s103, the method in each code file is checked according to the number of times the method name is called. Names and comments are cleaned up, including:
- Step s601 Detect each code file in turn, and if the method name in the code file has comments, record the method name, the position corresponding to the method name, the comment position and the code file number;
- all code files can be tested in turn.
- the test can be performed according to the corresponding relationship between the code files in the database and the method names and comments, and each code file can be queried in the database. If the code file If there is a method name in the method name, you can perform a comment query on the method name. If the method name has a comment, record the method name, the position corresponding to the method name, the comment position and the code file number.
- step s602 if the method name in the code file has no comments, then when the method type called by the method name is the first method type and the number of times the method name is called is less than or equal to the first cumulative number of times
- thresholding record the method name, the position corresponding to the method name, and the code file number;
- the method name in the code file has no comments, continue to determine whether the method name is idle or redundant, and the method of determination can be determined by judging the method type of the method name and checking the method.
- the determination of the number of times the name is called is performed, that is, when the method type of the method name being called is the first method type and the number of times the method name is called is less than or equal to the first cumulative times threshold, the Method name, position corresponding to method name and code file number.
- step s603 if the method name in the code file has no comments, then when the method type called by the method name is the second method type and the number of times the method name is called is less than or equal to the second cumulative number of times
- thresholding record the method name, the position corresponding to the method name, and the code file number;
- the method name in the code file has no comments, continue to determine whether the method name is idle or redundant, and the method of determination can be determined by judging the method type of the method name and checking the method.
- the determination of the number of times the name is called is performed, that is, when the method type of the method name being called is the second method type and the number of times the method name is called is less than or equal to the second cumulative times threshold, the Method name, position corresponding to method name and code file number.
- Step s604 Send the recorded method name, the position corresponding to the method name, the comment position and the code file number.
- the method name, the position corresponding to the method name, the comment position and the code file number recorded in all the code files are obtained.
- the method name recorded above is the method name that needs to be cleaned up, so The recorded method name, the position corresponding to the method name, the comment position, and the code file number can be output to inform the user to clean up.
- the code file can be effectively cleaned up and the code running efficiency is improved.
- FIG. 7 is a schematic flow chart of a method for maintaining project code according to the sixth embodiment of this application. As shown in the figure, in step s103, the method in each code file is checked according to the number of times the method name is called. Names and comments are cleaned up, including:
- each code file is detected in turn, and if the method name in the code file has a comment, delete the method name and comment according to the method name and the position of the comment;
- all code files can be tested in turn.
- the test can be performed according to the corresponding relationship between the code files in the database and the method names and comments, and each code file can be queried in the database. If the code file If the method name has a comment, you can query the method name and the position corresponding to the comment in the database, and you can query the method name according to the method name and Delete the method name and comment at the position corresponding to the comment.
- step s702 if the method name in the code file has no comments, then when the method type called by the method name is the first method type and the number of times the method name is called is less than or equal to the first cumulative number of times When the threshold is set, delete the method name according to the position of the method name;
- the method name in the code file has no comments, continue to determine whether the method name is idle or redundant, and the method of determination can be determined by judging the method type of the method name and checking the method.
- the judgment of the number of times the name is called is performed, that is, when the method type of the method name being called is the first method type and the number of times the method name is called is less than or equal to the first cumulative times threshold, the The position corresponding to the method name is queried in the, and the method name can be deleted according to the position corresponding to the method name.
- Step s703 If the method name in the code file has no comments, then when the method type of the method name called is the second method type and the number of times the method name is called is less than or equal to the second cumulative number of times When the threshold is set, the method name is deleted according to the position of the method name.
- the method name in the code file has no comments, continue to determine whether the method name is idle or redundant, and the method of determination can be determined by judging the method type of the method name and checking the method.
- the judgment of the number of times that the name is called is performed, that is, when the method type of the method name being called is the second method type and the number of times the method name is called is less than or equal to the second cumulative times threshold, the The position corresponding to the method name is queried in the, and the method name can be deleted according to the position corresponding to the method name.
- FIG. 8 The structure of a maintenance device for project code in an embodiment of the present application is shown in FIG. 8, and includes:
- Code scanning module 801, data summary module 802, and code maintenance module 803 among them, the code scanning module 801 is connected to the data summary module 802, and the data summary module 802 is connected to the code maintenance module 803; the code scanning module 801 is set to obtain multiple items in the project Code files, number each code file, scan the code in each code file, obtain the method name and comment in the code of each code file, and compare the method name and comment with the The number of each code file is corresponding and stored in the database; the data summary module 802 is set to summarize the method names in the database to obtain the number of times each method name is called; the code maintenance module 803 is set to be based on all The number of times the method name is called clears the method name and comments in each code file.
- the embodiment of the present application also discloses a computer device.
- the computer device includes a memory and a processor.
- the memory stores computer-readable instructions.
- the computer-readable instructions are executed by one or more of the processors, , Causing one or more of the processors to execute the steps in the maintenance methods in the foregoing embodiments.
- the embodiment of the application also discloses a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, and the storage medium may be It is read and written by a processor, and the memory stores computer-readable instructions.
- the computer-readable instructions are executed by one or more processors, one or more processors execute the maintenance methods described in the foregoing embodiments. A step of.
- the computer program can be stored in a computer readable storage medium. When executed, it may include the processes of the above-mentioned method embodiments.
- the aforementioned storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disc, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM), etc.
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
本申请涉及研发管理领域,本申请公开了一种项目代码的维护方法、装置、计算机设备和存储介质,所述方法包括:获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。本申请通过对代码文件中方法名以及注释的检测,获取弃用的代码段,可有效对代码进行清理,提高代码运行效率,有利代码的后期维护。
Description
本申请要求于2019年06月18日提交中国专利局、申请号为201910524813.3、发明名称为“项目代码的维护方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及研发管理领域,特别涉及一种项目代码的维护方法、装置、计算机设备和存储介质。
目前,在项目开发过程中,开发人员由于时间、地点以及项目等各种因素会重写很多重复的代码,或者代码中的方法被弃用之后,仍旧留在类中,这样不利于后面接受的开发人员或者维护人员对项目中的代码进行维护或者整改;而且当一个项目的代码量累计过多的时候,甚至会导致发布产品的时候,文件过大,影响发布和推广。
发明内容
本申请的目的在于针对现有技术的不足,提供一种项目代码的维护方法、装置、计算机设备和存储介质,通过对代码文件中方法名以及注释的检测,获取弃用的代码段,可有效对代码进行清理,提高代码运行效率,有利代码的后期维护。
为达到上述目的,本申请的技术方案提供一种项目代码的维护方法、装置、计算机设备和存储介质。
本申请公开了一种项目代码的维护方法,包括以下步骤:
获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;
对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;
根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
本申请还公开了一种项目代码的维护装置,所述装置包括:
代码扫描模块:设置为获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代 码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;
数据汇总模块:设置为对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;
代码维护模块:设置为根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
本申请还公开了一种计算机设备,所述计算机设备包括存储器和处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被一个或多个所述处理器执行时,使得一个或多个所述处理器执行以下步骤:
获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;
对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;
根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
本申请还公开了一种计算机可读存储介质,该计算机可读存储介质可以为非易失性计算机可读存储介质,也可以是易失性计算机可读存储介质,所述存储介质可被处理器读写,所述存储介质存储有计算机指令,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:
获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;
对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;
根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
本申请的有益效果是:本申请通过对代码文件中方法名以及注释的检测,获取弃用的代码段,可有效对代码进行清理,提高代码运行效率,有利代码的后期维护。
图1为本申请第一个实施例的一种项目代码的维护方法的流程示意图;
图2为本申请第二个实施例的一种项目代码的维护方法的流程示意图;
图3为本申请第三个实施例的一种项目代码的维护方法的流程示意图;
图4为本申请第四个实施例的一种项目代码的维护方法的流程示意图;
图5为本申请第五个实施例的一种项目代码的维护方法的流程示意图;
图6为本申请第六个实施例的一种项目代码的维护方法的流程示意图;
图7为本申请第六个实施例的一种项目代码的维护方法的流程示意图;
图8为本申请实施例的一种项目代码的维护装置结构示意图。
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本技术领域技术人员可以理解,除非特意声明,这里使用的单数形式“一”、“一个”、“所述”和“该”也可包括复数形式。应该进一步理解的是,本申请的说明书中使用的措辞“包括”是指存在所述特征、整数、步骤、操作、元件和/或组件,但是并不排除存在或添加一个或多个其他特征、整数、步骤、操作、元件、组件和/或它们的组。
本申请第一个实施例的一种项目代码的维护方法流程如图1所示,本实施例包括以下步骤:
步骤s101,获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;
具体的,每个开发项目通常会包含多个代码文件,而每个代码文件中会包含很多的方法、类以及接口,所述方法、类以及接口之间又会涉及互相调用,因此可对整个项目的所有代码文件进行扫描,在对所述代码文件进行扫描之前还可对所述代码文件进行编号,所述编号规则可以是用数字进行编号,也可以用字幕进行编号,用于区分各个代码文件;所述扫描可以通过java的反射机制进行,所述java反射机制指的是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法;对于任意一个对象,都能够调用它的任意方法和属性;这种动态获取信息以及动态调用对象方法的功能称为java语言的反射机制, 当对所有的代码文件进行扫描之后,可以获取到每个代码文件中的方法名和注释,所述方法名指的是每个调用方法的名称,所述注释指的是对所述调用方法的注释,其中,所述调用方法是程序的一部分,而所述注释不是程序的一部分。
具体的,每对一个代码文件扫描完并获取到方法名和注释后,可将所述方法名和注释的具体位置进行记录,所述位置包括所述方法名的首行位置及尾行位置、所述注释的首行位置及尾行位置,并将所述方法名和注释与代码文件的编号进行对应,存储在数据库中,当对所有代码文件扫描完之后,就会获得所有方法名和注释的位置及与代码文件编号之间的对应关系。
步骤s102,对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;
具体的,由于每个方法名都可能在任意一个代码文件中出现,即被任意一个代码文件进行调用,因此可通过对所述代码文件中方法名出现的次数对所述方法名进行统计,获得每个方法名被调用的次数。
步骤s103,根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
具体的,首先可对代码文件中每个方法名是否有对应的注释进行检测,如果所述方法名有注释,则可直接对所述方法名和所述注释进行清理。
具体的,如果通过检测发现所述方法名没有注释,则当获取到方法名被调用的次数后,可以根据所述方法名被调用的次数判断所述方法名是否经常被调用,例如,可预先设置调用次数阈值,并将所述方法名被调用的次数与所述调用次数阈值进行比较,如果所述方法名被调用的次数大于所述调用次数阈值,则说明所述方法名经常被调用,不是闲置或者冗余的代码段,不能被直接删除,否则可根据所述方法名在代码文件中的位置对所述方法名进行清理。
本实施例中,通过对代码文件中方法名以及注释的检测,获取弃用的代码段,可有效对代码进行清理,提高代码运行效率,有利代码的后期维护。
图2为本申请第二个实施例的一种项目代码的维护方法流程示意图,如图所示,所述步骤s101,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名,包括:
步骤s201,对每个代码文件进行编号,并根据所述编号顺序依次对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名;
具体的,在对代码文件进行扫描前,可先对每个代码文件进行编号,用以对所有的代码文件进行区分;然后可根据所述代码文件的编号顺序依次对所述每个代码文件中的代码进行扫描,所述编号顺序可以是由大到小或者由小到大,只需将所有的代码文件遍历扫描完成即可,通过扫描过后,即可获得所述每个代码文件的代码中的方法名。
步骤s202,根据所述方法名在与所述方法名对应的代码文件中进行查询,获得所述方法名在与所述方法名对应的代码文件中的首行位置和尾行位置,并存储在数据库中。
具体的,当在代码文件中扫描到方法名之后,可根据所述方法名在对应的代码文件中进行查询,获取到所述方法名对应的代码行数,由于一个调用方法通常会包含一段代码,即包括很多行代码,因此所述代码行数包括首行位置及尾行位置。
本实施例中,通过对方法名的扫描获取方法名以及在代码文件中的位置,可以对所述方法名进行有效删除。
图3为本申请第三个实施例的一种项目代码的维护方法流程示意图,如图所示,所述步骤s101,获得所述每个代码文件的代码中的注释,包括:
步骤s301,预设第一注释标志、第二注释标志、第一检测行数及第二检测行数;
具体的,所述第一注释标志及所述第二注释标志用于检测注释在代码文件中是否存在以及具体的位置,例如,所述第一注释标志可以是“//”符号,而所述第二注释标志可以是“/*”符号,其中,由于注释标志不是程序的一部分,因此通常成对出现,用于标识开始和结尾,如果是以“//”符号开头,则以“//”符号结尾,如果是以“/*”符号开头,则以“*/”符号结尾。
具体的,所述检测行数与所述注释标志对应,所述检测行数用于对调用方法前的所述检测行数上对所述注释标志进行检测,由于通常“//”符号只出现在同一行中,即在调用方法的上一行中出现,因此所述第一检测行数可以设定为1行,而通常“/*”符号出现的可能是多行,即在调用方法的前几行中出现,一般都在4-5行左右,很少出现超过10行,因此所述第二检测行数可以设定为10行。
步骤s302,根据所述第一注释标志在所述方法名的首行位置前的所述第一 检测行数上进行检测,如果有所述第一注释标志存在,则记录所述第一注释标志所处的首行位置及尾行位置;
具体的,根据步骤s301中的所述第一注释标志在所述方法名的首行位置前的所述第一检测行数上进行检测,如果所述第一检测行数设定为1,则在所述方法名的首行位置的前一行进行检测,检测是否有与所述第一注释标志对应的符号存在,如果有,则说明有注释存在,记录所述第一注释标志所处的首行位置及尾行位置,如果只有一行,则首行位置和尾行位置相同。
步骤s303,根据所述第二注释标志在所述方法名的首行位置前的所述第二检测行数上进行检测,如果有所述第二注释标志存在,则记录所述第二注释标志所处的首行位置及尾行位置。
具体的,根据步骤s301中的所述第二注释标志在所述方法名的首行位置前的所述第二检测行数上进行检测,如果所述第二检测行数设定为10,则在所述方法名的首行位置的前10行到前1行逐一进行检测,检测是否有与所述第一注释标志对应的符号存在,如果有,则说明有注释存在,记录所述第一注释标志所处的首行位置及尾行位置。
本实施例中,通过设置注释标注并进行检测,可以有效检测注释的存在,并进行相应代码段的删除,提高代码运行效率。
图4为本申请第四个实施例的一种项目代码的维护方法流程示意图,如图所示,所述步骤s102,对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数,包括:
步骤s401,根据所述方法名在所述数据库中进行查询,获得与每个方法名对应的所有代码文件的编号;
具体的,首先可在数据库中对所有的方法名进行汇总,然后分别统计每个方法名被调用的次数,所述统计每个方法名被调用的次数可通过统计所述每个方法名对应的代码文件的个数进行,即通过所述方法名在数据库中进行查询,获得所述方法名对应的所有的代码文件编号,其中,一个代码文件编号代表一次。
步骤s402,根据所述代码文件的编号进行与所述方法名对应的代码文件个数的统计,获得每个方法名被调用的次数。
具体的,由于一个代码文件编号代表一次,因此可根据所述代码文件的编 号进行与所述方法名对应的代码文件个数的统计,获得每个方法名被调用的次数,并进行缓存。
本实施例中,通过获取方法名被调用的次数,可以有效判别所述方法名是否需要被清理,提高代码维护效率。
图5为本申请第五个实施例的一种项目代码的维护方法流程示意图,如图所示,所述步骤s103,根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理之前,包括:
步骤s501,预设第一方法类型、第二方法类型、第一累计次数阈值及第二累计次数阈值;
具体的,由于在代码开发中,调用方法可分为接口类和实现类,其中,接口类和实现类对应的调用方法的闲置或者冗余的判断也是不同的,例如,实现类的调用方法只要被调用过一次即可认为所述调用方法是比较重要的,不能被清理;而接口类的调用方法需要被调用多次才可被认为所述调用方法是比较重要的,不能被清理。因此可预设第一方法类型、第二方法类型、第一累计次数阈值及第二累计次数阈值,其中,所述第一方法类型及所述第二方法类型用于区分是接口类还是实现类,所述第一累计次数阈值及第二累计次数阈值与所述方法类型进行对应,用于判断与所述方法类型对应的调用方法是否需要清理。
步骤s502,检测所述方法名被调用的方法类型,如果所述方法名被调用的方法类型为所述第一方法类型时,将所述方法名被调用的次数与所述第一累计次数阈值进行比对,如果所述方法名被调用的方法类型为所述第二方法类型时,将所述方法名被调用的次数与所述第二累计次数阈值进行比对。
具体的,可对所述方法名被调用的方法类型进行检测,如果检测到所述方法名被调用的方法类型为所述第一方法类型时,可将所述方法名被调用的次数与所述第一累计次数阈值进行比对,例如,如果所述第一方法类型是接口类,则所述第一累计次数阈值可设为2,如果所述方法名被调用的次数大于2,则说明所述方法名不应被清理;如果检测到所述方法名被调用的方法类型为所述第二方法类型时,可将所述方法名被调用的次数与所述第二累计次数阈值进行比对,例如,如果所述第二方法类型是实现类,则所述第一累计次数阈值可设为1,如果所述方法名被调用的次数大于1,则说明所述方法名不应被清理。
本实施例中,通过检测调用方法的方法类型以及被调用的次数,可以有效 对所述调用方法进行清理,提高代码运行效率。
图6为本申请第六个实施例的一种项目代码的维护方法流程示意图,如图所示,所述步骤s103,根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理,包括:
步骤s601,对每个代码文件依次进行检测,如果所述代码文件中的方法名有注释,则记录所述方法名、方法名对应的位置、注释位置及代码文件编号;
具体的,可对所有的代码文件依次进行检测,所述检测可以根据数据库中的代码文件与方法名和注释的对应关系进行,即可在数据库中对每个代码文件进行查询,如果所述代码文件中有方法名,可对所述方法名进行注释查询,如果所述方法名有注释,则记录所述方法名、方法名对应的位置、注释位置及代码文件编号。
步骤s602,如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第一方法类型且所述方法名被调用的次数小于等于所述第一累计次数阈值时,记录所述方法名、方法名对应的位置及代码文件编号;
具体的,如果所述代码文件中的方法名无注释,则继续判断所述方法名是否闲置或冗余,所述判断的方法可通过对所述方法名的方法类型进行判断及对所述方法名的被调用次数的判断进行,即当所述方法名被调用的方法类型为所述第一方法类型且所述方法名被调用的次数小于等于所述第一累计次数阈值时,记录所述方法名、方法名对应的位置及代码文件编号。
步骤s603,如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第二方法类型且所述方法名被调用的次数小于等于所述第二累计次数阈值时,记录所述方法名、方法名对应的位置及代码文件编号;
具体的,如果所述代码文件中的方法名无注释,则继续判断所述方法名是否闲置或冗余,所述判断的方法可通过对所述方法名的方法类型进行判断及对所述方法名的被调用次数的判断进行,即当所述方法名被调用的方法类型为所述第二方法类型且所述方法名被调用的次数小于等于所述第二累计次数阈值时,记录所述方法名、方法名对应的位置及代码文件编号。
步骤s604,将记录的所述方法名、方法名对应的位置、注释位置及代码文件编号进行发送。
具体的,当对所有代码文件进行检测过后,获取到所有代码文件中记录的 方法名、方法名对应的位置、注释位置及代码文件编号,上述记录的方法名即为需要清理的方法名,因此可将所述记录的方法名、方法名对应的位置、注释位置及代码文件编号进行输出,告知用户进行清理。
本实施例中,通过记录需要清理的方法名、方法名对应的位置、注释位置及代码文件编号并进行输出,可以有效对代码文件进行清理,提高代码运行效率。
图7为本申请第六个实施例的一种项目代码的维护方法流程示意图,如图所示,所述步骤s103,根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理,包括:
步骤s701,对每个代码文件依次进行检测,如果所述代码文件中的方法名有注释,根据所述方法名及所述注释的位置对所述方法名及注释进行删除;
具体的,可对所有的代码文件依次进行检测,所述检测可以根据数据库中的代码文件与方法名和注释的对应关系进行,即可在数据库中对每个代码文件进行查询,如果所述代码文件中有方法名,可对所述方法名进行注释查询,如果所述方法名有注释,则可在数据库中查询到所述方法名及所述注释对应的位置,并可根据所述方法名及所述注释对应的位置对所述方法名及注释进行删除。
步骤s702,如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第一方法类型且所述方法名被调用的次数小于等于所述第一累计次数阈值时,根据所述方法名的位置对所述方法名进行删除;
具体的,如果所述代码文件中的方法名无注释,则继续判断所述方法名是否闲置或冗余,所述判断的方法可通过对所述方法名的方法类型进行判断及对所述方法名的被调用次数的判断进行,即当所述方法名被调用的方法类型为所述第一方法类型且所述方法名被调用的次数小于等于所述第一累计次数阈值时,可在数据库中查询到所述方法名对应的位置,并可根据所述方法名对应的位置对所述方法名进行删除。
步骤s703,如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第二方法类型且所述方法名被调用的次数小于等于所述第二累计次数阈值时,根据所述方法名的位置对所述方法名进行删除。
具体的,如果所述代码文件中的方法名无注释,则继续判断所述方法名是否闲置或冗余,所述判断的方法可通过对所述方法名的方法类型进行判断及对 所述方法名的被调用次数的判断进行,即当所述方法名被调用的方法类型为所述第二方法类型且所述方法名被调用的次数小于等于所述第二累计次数阈值时,可在数据库中查询到所述方法名对应的位置,并可根据所述方法名对应的位置对所述方法名进行删除。
本实施例中,通过对代码文件中方法名调用次数和注释的检测对所述方法名和注释直接进行删除,可有效提高代码运行效率。
本申请实施例的一种项目代码的维护装置结构如图8所示,包括:
代码扫描模块801、数据汇总模块802及代码维护模块803;其中,代码扫描模块801与数据汇总模块802相连,数据汇总模块802与代码维护模块803相连;代码扫描模块801设置为获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;数据汇总模块802设置为对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;代码维护模块803设置为根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
本申请实施例还公开了一种计算机设备,所述计算机设备包括存储器和处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被一个或多个所述处理器执行时,使得一个或多个所述处理器执行上述各实施例中所述维护方法中的步骤。
本申请实施例还公开了一种计算机可读存储介质,该计算机可读存储介质可以为非易失性计算机可读存储介质,也可以是易失性计算机可读存储介质,所述存储介质可被处理器读写,所述存储器存储有计算机可读指令,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行上述各实施例中所述维护方法中的步骤。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,该计算机程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,前述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等非易失性存储介质,或随机存储记忆体(Random Access Memory,RAM)等。
以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。
Claims (20)
- 一种项目代码的维护方法,包括以下步骤:获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
- 如权利要求1所述的项目代码的维护方法,其中,所述对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名,包括:对每个代码文件进行编号,并根据所述编号顺序依次对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名;根据所述方法名在与所述方法名对应的代码文件中进行查询,获得所述方法名在与所述方法名对应的代码文件中的首行位置和尾行位置,并存储在数据库中。
- 如权利要求2所述的项目代码的维护方法,其中,所述获得所述每个代码文件的代码中的注释,包括:预设第一注释标志、第二注释标志、第一检测行数及第二检测行数;根据所述第一注释标志在所述方法名的首行位置前的所述第一检测行数上进行检测,如果有所述第一注释标志存在,则记录所述第一注释标志所处的首行位置及尾行位置;根据所述第二注释标志在所述方法名的首行位置前的所述第二检测行数上进行检测,如果有所述第二注释标志存在,则记录所述第二注释标志所处的首行位置及尾行位置。
- 如权利要求1所述的项目代码的维护方法,其中,所述对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数,包括:根据所述方法名在所述数据库中进行查询,获得与每个方法名对应的所有代码文件的编号;根据所述代码文件的编号进行与所述方法名对应的代码文件个数的统计,获得每个方法名被调用的次数。
- 如权利要求1所述的项目代码的维护方法,其中,所述根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理之前,包括:预设第一方法类型、第二方法类型、第一累计次数阈值及第二累计次数阈值;检测所述方法名被调用的方法类型,如果所述方法名被调用的方法类型为所述第一方法类型时,将所述方法名被调用的次数与所述第一累计次数阈值进行比对,如果所述方法名被调用的方法类型为所述第二方法类型时,将所述方法名被调用的次数与所述第二累计次数阈值进行比对。
- 如权利要求5所述的项目代码的维护方法,其中,所述根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理,包括:对每个代码文件依次进行检测,如果所述代码文件中的方法名有注释,则记录所述方法名、方法名对应的位置、注释位置及代码文件编号;如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第一方法类型且所述方法名被调用的次数小于等于所述第一累计次数阈值时,记录所述方法名、方法名对应的位置及代码文件编号;如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第二方法类型且所述方法名被调用的次数小于等于所述第二累计次数阈值时,记录所述方法名、方法名对应的位置及代码文件编号;将记录的所述方法名、方法名对应的位置、注释位置及代码文件编号进行发送。
- 如权利要求5所述的项目代码的维护方法,其中,所述根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理,包括:对每个代码文件依次进行检测,如果所述代码文件中的方法名有注释,根据所述方法名及所述注释的位置对所述方法名及注释进行删除;如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第一方法类型且所述方法名被调用的次数小于等于所述第一累计次数阈值时,根据所述方法名的位置对所述方法名进行删除;如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第二方法类型且所述方法名被调用的次数小于等于所述第二累计次数阈值时,根据所述方法名的位置对所述方法名进行删除。
- 一种项目代码的维护装置,所述装置包括:代码扫描模块:设置为获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;数据汇总模块:设置为对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;代码维护模块:设置为根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
- 根据权利要求8所述的项目代码的维护装置,其中,所述代码扫描模块,包括:编号单元:设置为对每个代码文件进行编号,并根据所述编号顺序依次对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名;查询单元:设置为根据所述方法名在与所述方法名对应的代码文件中进行查询,获得所述方法名在与所述方法名对应的代码文件中的首行位置和尾行位置,并存储在数据库中。
- 根据权利要求9所述的项目代码的维护装置,其中,所述代码扫描模块,包括:第一预置单元:设置为预设第一注释标志、第二注释标志、第一检测行数及第二检测行数;第一检测单元:设置为根据所述第一注释标志在所述方法名的首行位置前的所述第一检测行数上进行检测,如果有所述第一注释标志存在,则记录所述第一注释标志所处的首行位置及尾行位置;第二检测单元:设置为根据所述第二注释标志在所述方法名的首行位置前的所述第二检测行数上进行检测,如果有所述第二注释标志存在,则记录所述第二注释标志所处的首行位置及尾行位置。
- 根据权利要求8所述的项目代码的维护装置,其中,所述数据汇总模块,包括:编号获取单元:设置为根据所述方法名在所述数据库中进行查询,获得与 每个方法名对应的所有代码文件的编号;统计单元:设置为根据所述代码文件的编号进行与所述方法名对应的代码文件个数的统计,获得每个方法名被调用的次数。
- 根据权利要求8所述的项目代码的维护装置,其中,所述代码维护模块,包括:第二预置单元:设置为预设第一方法类型、第二方法类型、第一累计次数阈值及第二累计次数阈值;比对单元:设置为检测所述方法名被调用的方法类型,如果所述方法名被调用的方法类型为所述第一方法类型时,将所述方法名被调用的次数与所述第一累计次数阈值进行比对,如果所述方法名被调用的方法类型为所述第二方法类型时,将所述方法名被调用的次数与所述第二累计次数阈值进行比对。
- 根据权利要求12所述的项目代码的维护装置,其中,所述代码维护模块,包括:第一记录单元:设置为对每个代码文件依次进行检测,如果所述代码文件中的方法名有注释,则记录所述方法名、方法名对应的位置、注释位置及代码文件编号;第二记录单元:设置为如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第一方法类型且所述方法名被调用的次数小于等于所述第一累计次数阈值时,记录所述方法名、方法名对应的位置及代码文件编号;第三记录单元:设置为如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第二方法类型且所述方法名被调用的次数小于等于所述第二累计次数阈值时,记录所述方法名、方法名对应的位置及代码文件编号;发送单元:设置为将记录的所述方法名、方法名对应的位置、注释位置及代码文件编号进行发送。
- 根据权利要求12所述的项目代码的维护装置,其中,所述代码维护模块,包括:第一清理单元:设置为对每个代码文件依次进行检测,如果所述代码文件中的方法名有注释,根据所述方法名及所述注释的位置对所述方法名及注释进 行删除;第二清理单元:设置为如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第一方法类型且所述方法名被调用的次数小于等于所述第一累计次数阈值时,根据所述方法名的位置对所述方法名进行删除;第三清理单元:设置为如果所述代码文件中的方法名无注释,则当所述方法名被调用的方法类型为所述第二方法类型且所述方法名被调用的次数小于等于所述第二累计次数阈值时,根据所述方法名的位置对所述方法名进行删除。
- 一种计算机设备,所述计算机设备包括存储器和处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被一个或多个所述处理器执行时,使得一个或多个所述处理器执行以下步骤:获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
- 根据权利要求15所述的计算机设备,其中,所述对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名时,使得所述处理器执行以下步骤:对每个代码文件进行编号,并根据所述编号顺序依次对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名;根据所述方法名在与所述方法名对应的代码文件中进行查询,获得所述方法名在与所述方法名对应的代码文件中的首行位置和尾行位置,并存储在数据库中。
- 根据权利要求15所述的计算机设备,其中,所述对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数时,使得所述处理器执行以下步骤:根据所述方法名在所述数据库中进行查询,获得与每个方法名对应的所有代码文件的编号;根据所述代码文件的编号进行与所述方法名对应的代码文件个数的统计, 获得每个方法名被调用的次数。
- 一种计算机可读存储介质,所述存储介质可被处理器读写,所述存储介质存储有计算机指令,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:获取项目中的多个代码文件,对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名和注释,将所述方法名和注释与所述每个代码文件的编号进行对应,并存储在数据库中;对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数;根据所述方法名被调用的次数对所述每个代码文件中的方法名和注释进行清理。
- 根据权利要求18所述的存储介质,其中,所述对每个代码文件进行编号,并对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名时,使得一个或多个所述处理器执行以下步骤:对每个代码文件进行编号,并根据所述编号顺序依次对所述每个代码文件中的代码进行扫描,获得所述每个代码文件的代码中的方法名;根据所述方法名在与所述方法名对应的代码文件中进行查询,获得所述方法名在与所述方法名对应的代码文件中的首行位置和尾行位置,并存储在数据库中。
- 根据权利要求18所述的存储介质,其中,所述对所述数据库中的方法名进行汇总,获得每个方法名被调用的次数时,使得一个或多个所述处理器执行以下步骤:根据所述方法名在所述数据库中进行查询,获得与每个方法名对应的所有代码文件的编号;根据所述代码文件的编号进行与所述方法名对应的代码文件个数的统计,获得每个方法名被调用的次数。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910524813.3 | 2019-06-18 | ||
| CN201910524813.3A CN110399132B (zh) | 2019-06-18 | 2019-06-18 | 项目代码的维护方法、装置、计算机设备和存储介质 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020253080A1 true WO2020253080A1 (zh) | 2020-12-24 |
Family
ID=68323202
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/119072 Ceased WO2020253080A1 (zh) | 2019-06-18 | 2019-11-18 | 项目代码的维护方法、装置、计算机设备和存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110399132B (zh) |
| WO (1) | WO2020253080A1 (zh) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110399132B (zh) * | 2019-06-18 | 2023-12-22 | 平安科技(深圳)有限公司 | 项目代码的维护方法、装置、计算机设备和存储介质 |
| CN111722874B (zh) * | 2020-06-24 | 2024-04-02 | 中国平安财产保险股份有限公司 | 移动端代码的自动清理方法、装置、设备及存储介质 |
| CN114185594A (zh) * | 2021-12-14 | 2022-03-15 | 深圳壹账通智能科技有限公司 | 一种代码检测方法、装置、设备及介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20080022268A1 (en) * | 2006-05-24 | 2008-01-24 | Bea Systems, Inc. | Dependency Checking and Management of Source Code, Generated Source Code Files, and Library Files |
| CN104809071A (zh) * | 2015-05-14 | 2015-07-29 | 北京润科通用技术有限公司 | 一种代码测试方法及装置 |
| CN106484401A (zh) * | 2016-09-23 | 2017-03-08 | 东北大学 | 一种面向对象软件的自动化重构方法 |
| CN106598828A (zh) * | 2015-10-14 | 2017-04-26 | 阿里巴巴集团控股有限公司 | 一种源代码中的无效类确定方法及装置 |
| CN109871319A (zh) * | 2019-01-18 | 2019-06-11 | 深圳壹账通智能科技有限公司 | 项目代码扫描方法、装置、计算机设备及存储介质 |
| CN110399132A (zh) * | 2019-06-18 | 2019-11-01 | 平安科技(深圳)有限公司 | 项目代码的维护方法、装置、计算机设备和存储介质 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102662736B (zh) * | 2012-03-09 | 2015-04-22 | 北京思特奇信息技术股份有限公司 | 一种基于系统源代码获取组件调用关系的方法 |
| RU2016137176A (ru) * | 2016-09-16 | 2018-03-19 | Оракл Интернэйшнл Корпорейшн | Связывание преобразованного исходного кода с первоначальным исходным кодом с помощью метаданных |
| CN109783081A (zh) * | 2018-12-27 | 2019-05-21 | 百富计算机技术(深圳)有限公司 | 一种应用程序的开发方法、装置及集成开发工具 |
| CN109753286A (zh) * | 2018-12-28 | 2019-05-14 | 四川新网银行股份有限公司 | 一种基于功能标签的代码方法统计其调用次数的方法 |
-
2019
- 2019-06-18 CN CN201910524813.3A patent/CN110399132B/zh active Active
- 2019-11-18 WO PCT/CN2019/119072 patent/WO2020253080A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20080022268A1 (en) * | 2006-05-24 | 2008-01-24 | Bea Systems, Inc. | Dependency Checking and Management of Source Code, Generated Source Code Files, and Library Files |
| CN104809071A (zh) * | 2015-05-14 | 2015-07-29 | 北京润科通用技术有限公司 | 一种代码测试方法及装置 |
| CN106598828A (zh) * | 2015-10-14 | 2017-04-26 | 阿里巴巴集团控股有限公司 | 一种源代码中的无效类确定方法及装置 |
| CN106484401A (zh) * | 2016-09-23 | 2017-03-08 | 东北大学 | 一种面向对象软件的自动化重构方法 |
| CN109871319A (zh) * | 2019-01-18 | 2019-06-11 | 深圳壹账通智能科技有限公司 | 项目代码扫描方法、装置、计算机设备及存储介质 |
| CN110399132A (zh) * | 2019-06-18 | 2019-11-01 | 平安科技(深圳)有限公司 | 项目代码的维护方法、装置、计算机设备和存储介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110399132A (zh) | 2019-11-01 |
| CN110399132B (zh) | 2023-12-22 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN103716690B (zh) | 多媒体直播举报的方法、终端、服务器及系统 | |
| CN103246595B (zh) | 应用程序管理方法、装置、服务器及终端设备 | |
| WO2020253080A1 (zh) | 项目代码的维护方法、装置、计算机设备和存储介质 | |
| JP5708107B2 (ja) | 重複ファイル検出装置 | |
| CN105843720A (zh) | 一种测试硬盘热插拔稳定性的方法及装置 | |
| CN104123273B (zh) | 一种面向对象程序的注释质量评价和注释建议方法 | |
| CN112422581B (zh) | JVM中的Webshell网页检测方法、装置及设备 | |
| CN106897141A (zh) | 信息的处理方法及装置 | |
| US8195986B2 (en) | Method, system and computer program product for processing error information in a system | |
| WO2018120720A1 (zh) | 客户端程序的测试错误定位方法、电子装置及存储介质 | |
| CN106033516A (zh) | 一种检测终端源代码安全的方法、装置及系统 | |
| CN106021048A (zh) | 一种磁盘组乱序验证的方法及装置 | |
| CN110597694A (zh) | 一种监控前端页面的方法及终端 | |
| CN109542341B (zh) | 一种读写io监测方法、装置、终端及计算机可读存储介质 | |
| CN106201753B (zh) | 一种基于linux中PCIE错误的处理方法及系统 | |
| KR101690075B1 (ko) | 로그기반 소스코드파일 이슈도 구현 방법 | |
| CN102421074B (zh) | 一种短消息监控方法及装置 | |
| CN111831528A (zh) | 一种计算机系统日志关联方法及相关装置 | |
| CN116910675B (zh) | 数据质量检测方法、装置、设备及其存储介质 | |
| CN113850664A (zh) | 一种数据异常检测方法及数据上报服务 | |
| CN113742208A (zh) | 一种软件检测方法、装置、设备及计算机可读存储介质 | |
| CN114581808B (zh) | 图片一致性检测方法、装置、存储设备及可读存储介质 | |
| JP5313101B2 (ja) | 情報管理プログラム、情報管理方法、及び、情報管理装置 | |
| CN110781142A (zh) | 数据导入方法及装置、服务端及存储介质 | |
| CN110046078A (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: 19933504 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: 19933504 Country of ref document: EP Kind code of ref document: A1 |