CN117687685A - Incremental code line determining method and device, computer equipment and storage medium - Google Patents
Incremental code line determining method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN117687685A CN117687685A CN202311694340.4A CN202311694340A CN117687685A CN 117687685 A CN117687685 A CN 117687685A CN 202311694340 A CN202311694340 A CN 202311694340A CN 117687685 A CN117687685 A CN 117687685A
- Authority
- CN
- China
- Prior art keywords
- code
- determining
- modification
- change
- line
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 216
- 230000008859 change Effects 0.000 claims abstract description 123
- 238000002715 modification method Methods 0.000 claims abstract description 106
- 238000012986 modification Methods 0.000 claims abstract description 84
- 230000004048 modification Effects 0.000 claims abstract description 84
- 230000008569 process Effects 0.000 claims description 22
- 238000004590 computer program Methods 0.000 claims description 19
- 238000012545 processing Methods 0.000 claims description 17
- 238000002372 labelling Methods 0.000 claims description 6
- 238000004458 analytical method Methods 0.000 claims description 3
- 238000012360 testing method Methods 0.000 abstract description 5
- 238000005516 engineering process Methods 0.000 abstract description 3
- 238000010586 diagram Methods 0.000 description 18
- 230000006870 function Effects 0.000 description 8
- 238000004422 calculation algorithm Methods 0.000 description 6
- 238000004891 communication Methods 0.000 description 6
- 230000007246 mechanism Effects 0.000 description 5
- 238000012552 review Methods 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 3
- 230000003190 augmentative effect Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/75—Structural analysis for program understanding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present disclosure relates to the field of testing technologies, and in particular, to a method, an apparatus, a computer device, and a storage medium for determining an incremental code row, where the incremental code row determining method includes performing differential comparison between a code to be detected and an original code corresponding to the code to be detected, and determining a modification method list; determining a commit identifier corresponding to each change method in the change method list; and determining a change code line based on the commit identifier and the historical modification record corresponding to the change method. With the present specification embodiment, for each modification method, a modified code line is automatically determined based on the commit representation and the history modification record corresponding to the modification method, thereby achieving accuracy in determining the incremental code to the code line dimension.
Description
Technical Field
The present disclosure relates to the field of testing technologies, and in particular, to a method and apparatus for determining an incremental code row, a computer device, and a storage medium.
Background
The identification of the increment code is currently only accurate to the method dimension. Comparing the code to be detected with the original code corresponding to the code to be detected, determining whether the code to be detected is changed relative to the original code, and determining a changing method. Specifically, if a line code of a line in the code to be detected is changed relative to the original code, the method including the line code is identified as a changed method. Since the determined modified method cannot be accurate to the corresponding modified row code, the accuracy of the resulting incremental code coverage is low. Further, for complex transaction scenes of a banking system, the granularity of the incremental code coverage rate is only accurate to the method dimension, the increase and modification of the code line level cannot be reflected, and whether some abnormal scenes or branch scenes are necessary to be subjected to test coverage cannot be judged.
How to accurately determine the accuracy of incremental code to the code line dimension is a problem that needs to be addressed in the prior art.
Disclosure of Invention
In order to solve the problems in the prior art, the embodiment of the specification provides a method, a device, computer equipment and a storage medium for determining an incremental code row, which realize that the accuracy of determining the incremental code is accurate to the dimension of the code row.
In order to solve the technical problems, the specific technical scheme in the specification is as follows:
in one aspect, the present embodiments provide a method for determining an incremental code line, including,
performing differential comparison on a code to be detected and an original code corresponding to the code to be detected, and determining a change method list;
determining a commit identifier corresponding to each modification method in the modification method list; and
and determining a change code row based on the submission identification and a history modification record corresponding to the change method.
Further, after determining to change the code line based on the commit identifier and the historical modification record corresponding to the change method, the method further includes:
and for each modification method, modifying and labeling the modification code row corresponding to the modification method.
Further, after determining a change code line based on the commit identification and the historical modification record corresponding to the change method, the method further comprises,
for each modification method, determining a modification code row coverage corresponding to the modification method based on the modification code row.
Further, the method for determining the modification method list further comprises the steps of differentially comparing the code to be detected and the original code corresponding to the code to be detected,
comparing the code to be detected with the original code by using a comparison instruction to obtain an increment file list; and
and analyzing the increment file list by utilizing an analysis instruction to obtain the change method list.
Further, the determining, for each modification method in the modification method list, a commit identifier corresponding to the modification method further includes:
processing each modification method by utilizing a query submission history instruction to obtain a process file; and
consistency matching is carried out on candidate item identifiers and each record identifier included in the process file, and target record identifiers corresponding to the candidate item identifiers are determined; and
and taking target record information corresponding to the target record identifier as the submitting identifier from the process file.
Further, the determining a change code line based on the commit identification and a historical modification record corresponding to the change method further includes,
processing the submitting identifications by utilizing a query modification instruction to determine the history modification record; and
The change code line is determined based on the history modification record and the change method.
Further, the determining, for each of the modification methods, a modified code line coverage corresponding to the modification method based on the modified code line further includes,
determining a change line number of the change code line according to each change method;
traversing the altering method, determining an unaltered code row and determining an unaltered row number with the unaltered code row; and
and determining the coverage rate of the modified code row corresponding to the modification method based on the modified row number and the unmodified row number.
Further, the determining the modified code line coverage corresponding to the modification method based on the modified line number and the unmodified line number further includes,
determining the sum of the changed line number and the unchanged line number as a total line number; and
and determining the quotient of the changed line number and the total line number as the coverage rate of the modified code line.
On the other hand, the embodiment of the specification also provides an incremental code row determining device, which comprises,
the comparison unit is used for carrying out differential comparison on the code to be detected and the original code corresponding to the code to be detected, and determining a change method list;
A first determining unit, configured to determine, for each modification method in the modification method list, a commit identifier corresponding to the modification method; and
and the second determining unit is used for determining a change code row based on the submission identification and the historical modification record corresponding to the change method.
Further, the device also comprises a control unit,
and the marking unit is used for marking the change code row corresponding to each change method in a change way.
Further, the device also comprises a control unit,
and a third determining unit configured to determine, for each modification method, a modification code line coverage corresponding to the modification method based on the modification code line.
In another aspect, embodiments of the present disclosure further provide a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the method described above when executing the computer program.
In another aspect, embodiments of the present disclosure also provide a computer-readable storage medium having stored thereon computer instructions that, when executed by a processor, perform the above-described method.
In another aspect, the present description embodiments also provide a computer program product comprising a computer program/instruction which, when executed by a processor, implements a method.
By utilizing the embodiment of the specification, for each code to be detected, the code to be detected and the original code corresponding to the code to be detected are subjected to differential comparison, and a change method list is determined; for each modification method in the modification method list, determining a submission identifier corresponding to the modification method; and determining a change code line based on the commit identifier and the historical modification record corresponding to the change method. With the embodiment of the present disclosure, first, for each code to be detected, it is determined whether the code to be detected includes a modification method, and if so, the modification method included in the code to be detected is determined, thereby forming a modification method list. And then each modification method in the modification method list determines the corresponding submission identification and the history modification record, and further determines modified modification code lines based on the history modification record. Thereby, it is achieved that the accuracy of determining the incremental code is accurate to the code line dimension.
Drawings
In order to more clearly illustrate the embodiments of the present description or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present description, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an implementation system of an incremental code row determining method according to an embodiment of the present disclosure;
FIG. 2 is a flow chart of a method for determining an incremental code row according to an embodiment of the present disclosure;
FIG. 3 is a flow chart illustrating a method of determining incremental code lines according to another embodiment of the present disclosure;
FIG. 4A is a flow chart illustrating a method of incremental code row determination according to another embodiment of the present disclosure;
FIG. 4B is a flowchart illustrating a method for determining the coverage rate of modified code lines according to an embodiment of the present disclosure;
FIG. 4C is a flowchart illustrating a method for determining coverage of modified code lines according to another embodiment of the present disclosure;
FIG. 5 is a flow chart illustrating a commit identifier determination method according to an embodiment of the present disclosure;
FIG. 6 is a flow chart illustrating a method of determining a modified code line according to an embodiment of the present disclosure;
FIG. 7A is a schematic diagram showing the configuration of an incremental code line determining apparatus according to an embodiment of the present disclosure;
FIG. 7B is a schematic diagram of an incremental code row determining apparatus according to another embodiment of the present disclosure;
FIG. 7C is a schematic diagram of an incremental code row determining apparatus according to another embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of a computer device according to an embodiment of the present disclosure.
[ reference numerals description ]
101. A user terminal;
102. a server;
710. a comparison unit;
720. a first determination unit;
730. a second determination unit;
7140. a labeling unit;
7240. a third determination unit;
802. a computer device;
804. a processing device;
806. storing the resource;
808. a driving mechanism;
810. an input/output module;
812. an input device;
814. an output device;
816. a presentation device;
818. a graphical user interface;
820. a network interface;
822. a communication link;
824. a communication bus.
Detailed Description
The technical solutions of the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is apparent that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
It should be noted that the terms "first," "second," and the like in the description and the claims of the specification and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the present description described herein may be capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, apparatus, article, or device that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or device.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
Fig. 1 is a schematic diagram of an implementation system of an incremental code row determining method according to an embodiment of the present disclosure, which may include: the user terminal 101 and the server 102 communicate with each other through a network, which may include a local area network (Local Area Network, abbreviated as LAN), a wide area network (Wide Area Network, abbreviated as WAN), the internet, or a combination thereof, and are connected to a website, user equipment (e.g., a computing device), and a backend system. The user may send an incremental code line determination request to the server 102 through the user terminal 101, and the server 102 determines the code identification to be detected from the incremental code line determination request after receiving the incremental code line determination request. Further, determining a code to be detected corresponding to the code to be detected based on the code to be detected identifier; performing differential comparison on the code to be detected and an original code corresponding to the code to be detected, and determining a change method list; determining a commit identifier corresponding to each change method in the change method list; and determining a change code line based on the commit identifier and the historical modification record corresponding to the change method. It should be noted that, after determining the change code line, the server 102 may also change and label the change code line corresponding to each change method for the user to review from the user terminal 101. It should be noted that, after determining the modified code line, the server 102 may also traverse the modification method, determine an unmodified code line, and make an unmodified label on the unmodified code line for the user to review from the user terminal 101. It should be noted that, after determining the change code line, the server 102 may also determine, for each change method, a change code line coverage rate corresponding to the change method based on the change code line. It should be noted that, after determining the coverage rate of the modified code line, the server 102 may also send the coverage rate of the modified code line to the user terminal 101 for the user to review from the user terminal 101.
Alternatively, the servers 102 may be nodes of a cloud computing system (not shown), or each server 102 may be a separate cloud computing system, including multiple computers interconnected by a network and operating as a distributed processing system.
In an alternative embodiment, the user terminal 101 may include electronic devices not limited to smart phones, acquisition devices, desktop computers, tablet computers, notebook computers, smart speakers, digital assistants, augmented Reality (AR, augmented Reality)/Virtual Reality (VR) devices, smart wearable devices, and the like. Alternatively, the operating system running on the electronic device may include, but is not limited to, an android system, an IOS system, linux, windows, and the like.
In addition, it should be noted that, fig. 1 is only one application environment provided in the present specification, and in practical application, a plurality of user terminals 101 may also be included, which is not limited in the present specification.
Fig. 2 is a flowchart of a method for generating incremental code row determination according to an embodiment of the present disclosure. The incremental code row determination process is described in this figure, but may include more or fewer operational steps based on conventional or non-inventive labor. The order of steps recited in the embodiments is merely one way of performing the order of steps and does not represent a unique order of execution. When a system or apparatus product in practice is executed, it may be executed sequentially or in parallel according to the method shown in the embodiments or the drawings. As shown in fig. 2, the method may include:
S210, carrying out differential comparison on a code to be detected and an original code corresponding to the code to be detected, and determining a change method list;
s220, determining a submission identifier corresponding to each change method in the change method list;
s230, determining a modified code line based on the submission identification and the historical modification record corresponding to the modification method.
By utilizing the embodiment of the specification, for each code to be detected, the code to be detected and the original code corresponding to the code to be detected are subjected to differential comparison, and a change method list is determined; for each modification method in the modification method list, determining a submission identifier corresponding to the modification method; and determining a change code line based on the commit identifier and the historical modification record corresponding to the change method. With the embodiment of the present disclosure, first, for each code to be detected, it is determined whether the code to be detected includes a modification method, and if so, the modification method included in the code to be detected is determined, thereby forming a modification method list. And then each modification method in the modification method list determines the corresponding submission identification and the history modification record, and further determines modified modification code lines based on the history modification record. Thereby, it is achieved that the accuracy of determining the incremental code is accurate to the code line dimension.
According to one embodiment of the present disclosure, for each code to be detected, the code to be detected is differentially compared with an original code corresponding to the code to be detected, and a modification method list is determined; for each modification method in the modification method list, determining a submission identifier corresponding to the modification method; and determining a change code line based on the commit identifier and the historical modification record corresponding to the change method. With the embodiment of the present disclosure, first, for each code to be detected, it is determined whether the code to be detected includes a modification method, and if so, the modification method included in the code to be detected is determined, thereby forming a modification method list. And then each modification method in the modification method list determines the corresponding submission identification and the history modification record, and further determines modified modification code lines based on the history modification record. Thereby, it is achieved that the accuracy of determining the incremental code is accurate to the code line dimension.
When the user needs to detect the increment of a certain part of codes, the code identification corresponding to the part of codes is used as the code identification to be detected and sent to the server. And after receiving the code identification to be detected, the server obtains the corresponding partial code based on the code identification index to be detected, and takes the partial code as the code to be detected. The code identification to be detected may be, for example, unique identification information characterizing the partial code corresponding thereto. For example, if a part of the codes is a test code, the test code is identified as the code corresponding to the part of the codes.
In the case that the code to be detected is a code modified from the original code, the original code may be, for example, an initial code developed by a developer for a certain service, or a code after the initial code is completed. The code to be detected is a code which is perfected on the perfected code. That is, the original code may be an initial code generated for a certain service for the first time, or may be an intermediate modified code, which is not limited in this specification.
After determining the code to be detected and the original code corresponding to the code to be detected, performing differential comparison on the code to be detected and the original code, determining whether the code to be detected has a modification part relative to the original code, and under the condition that the code to be detected has no incremental code relative to the original code, outputting a result without the incremental code to a user terminal for the user to review.
When the modification of the code to be detected relative to the original code is determined, a method for detecting the modification of the code relative to the original code is determined, and a list formed by the modified method is taken as a modified method list. Specifically, the method for determining the modification may be that the code to be detected is divided into a plurality of methods to be detected according to the included method; dividing the original code into a plurality of original methods according to the included methods; for each method to be detected, determining an original method corresponding to the method to be detected; for each method to be detected, determining whether the original method corresponding to the method is changed; under the condition that the change is determined, determining the method to be detected as a change method; and under the condition that no change is determined, determining the method to be detected as an unchanged method.
Dividing the code to be detected into a plurality of methods to be detected according to the included methods can be specifically that all methods included in the methods to be detected are determined; for each method, determining a code corresponding to the method and taking the corresponding code as a method to be detected. The method of determining the method to be detected may be any method that can be determined from the methods to be detected, for example, based on the existing methods, and this specification is not limited thereto. The original code is divided into a plurality of original methods according to the included method, and the original method is determined based on, for example, a method similar to the method to be determined.
For each method to be detected, determining whether the original method corresponding to the method is changed or not specifically can be, and for each method to be detected, determining first information abstract data corresponding to the method to be detected; determining, for each original method, second message digest data corresponding thereto; for each method to be detected, determining whether the first information abstract data and the third information abstract data corresponding to the first information abstract data are consistent; under the condition of inconsistent determination, determining the method to be detected as a modification method; and under the condition of confirming consistency, determining the method to be detected as an unmodified algorithm. Specifically, the first information abstract data is data obtained after a method to be detected is processed based on a tampering algorithm. Similarly, the second information abstract data is data obtained after the original method is processed based on the tampering algorithm. The tamper algorithm may be, for example, a message digest algorithm (MD 5), or may be another algorithm for checking whether it is tampered with, which is not limited in this specification. The third information abstract data corresponding to each method to be detected is the second information abstract data of the original method corresponding to the method to be detected.
After determining the change method list, determining all record information of the changed method for each change method in the change method list; and determining a commit identifier corresponding to the modification method from the all recorded information. The record information may include, for example, a commit record identification (i.e., is a commit identification), a commit user identification (author information of commit), a commit time, and commit data, etc. The commit identity may be, for example, information that uniquely identifies the commit generated from each commit content and commit information, which may include, for example, a commit user identity, a commit time, and the like. For example, the contents and information may be processed by a hash function to obtain hash values.
From the history cache records, a history modification record corresponding to each modification method is determined. The manner in which the history modification record corresponding to the change method is determined based on the identification of the change method can be determined based on any existing determination manner, and the present specification is not limited thereto.
Thus, for each modification method, determining the corresponding commit identifier and history modification record; and further determining a modified code line corresponding to the method based on the commit identifier and the historical modification record. Specifically, determining a target historical modification record corresponding to each submission identifier from the historical modification records; determining, for each target history modification record, whether other history modification records can cancel each other; and under the condition that each target history modification record is not counteracted, determining the number of change lines corresponding to the commit identifier, and determining the number of change lines as the change code line. Determining that the candidate history modification record and the target history modification record can be mutually offset, deleting the commit identifiers corresponding to the candidate history modification record and the target history modification record, and thus obtaining a plurality of change commit identifiers; and determining the number of the changed lines corresponding to each changed submission identifier, and determining the number of the changed lines as the changed code line. Thus, the situation that a certain line code is modified firstly and then restored is avoided, and the modified line code can be determined more accurately.
According to another embodiment of the present disclosure, the determining the modification method list may include, for example: comparing the code to be detected with the original code by using a comparison instruction to obtain an incremental file list; and analyzing the increment file list by utilizing the analysis instruction to obtain a change method list.
For example, the contrast instruction is a Git Diff instruction, which is similar to the existing Git Diff instruction, and this description will not be repeated. Specifically, differential comparison processing is carried out on the code to be detected and the original code by using a Git Diff instruction, so that a plurality of differential information are obtained; and summarizing the difference information to obtain an incremental file list.
The parsing instruction may be, for example, a javaParse instruction, which is similar to an existing javaParse instruction, and will not be described in detail in this specification. Specifically, analyzing each piece of difference information included in the increment file list by using a Java Parse instruction to obtain readable method information corresponding to the difference information; and summarizing the readable method information to obtain a change method list. The readable method information may be, for example, a method identifier parsed for the difference information.
Fig. 3 is a flowchart illustrating a method for determining an incremental code line according to another embodiment of the present disclosure. Another process for incremental code line determination is depicted in fig. 3, but may include more or fewer operational steps based on conventional or non-inventive labor. As shown in fig. 3, the method may include:
s310, performing differential comparison on the code to be detected and an original code corresponding to the code to be detected, and determining a change method list;
s320, determining a commit identifier corresponding to each change method in the change method list;
s330, determining a modified code line based on the submitting identification and a history modification record corresponding to the modification method;
s340, for each modification method, modifying and labeling the modification code row corresponding to the modification method.
According to another embodiment of the present disclosure, when the changed line code (changed code line) is determined, if the changed line code is displayed on the user terminal only in the form of the line number, so that the user needs to look up the line based on the displayed line number, the user needs to find the corresponding line in the corresponding code, and then look up the corresponding code. This results in a user spending more time determining the altered code and a poor user experience. In order to further improve user experience, in the embodiment of the present disclosure, the modification method is labeled according to the determined modification code line.
S310-S330 may be implemented based on a similar method as S210-S230, which will not be described in detail in this specification. After the changed code rows are determined, determining row codes corresponding to each changed code row from a changing method; and marking the line of codes by changing. For example, the code line [23, 41, 52] is changed, the code of the 23 rd line, the code of the 41 st line and the code of the 52 th line in the changing method are determined to be the line codes corresponding to the changed code line, and then the change mark is carried out on the line codes. Specifically, the modification mark can be any marking mark, only the code which can remind the user to change is the increment code, and the specific modification mark form is not limited in the specification. In particular, the change labeling may be to modify the class (class) of the line code into a modified line (updatelineov), for example, the line may also be colored and labeled (e.g., highlighting of the first color).
According to another embodiment of the present disclosure, for example, for each modification method, an unmodified code line corresponding to the modification method may be labeled as unmodified. Specifically, from the altered method, an unaltered code row is determined and an unaltered label is made for each unaltered code row. The determination of the unchanged code line may be determined, for example, based on the contrary manner of determining the changed code line, or code lines other than the changed code line may be removed from all lines included in the changing method, etc., which is not limited in this specification. Specifically, the unmodified label can be any marking label, only the code which can remind the user to change is not an increment code, and the specific unmodified label form is not limited in the specification. In particular, the unchanged mark may be to modify the class (class) of the line code into a modified line (updateLineNoCov), for example, the line may also be stained (e.g. highlighting of the second color).
Fig. 4A is a flowchart illustrating a method for determining an incremental code line according to another embodiment of the present disclosure. Another incremental code line determination process is depicted in fig. 4A, but may include more or fewer operational steps based on conventional or non-inventive labor. As shown in fig. 4A, the method may include:
s410, performing differential comparison on the code to be detected and an original code corresponding to the code to be detected, and determining a change method list;
s420, determining a commit identifier corresponding to each change method in the change method list;
s430, determining a modified code line based on the submitting identification and a history modification record corresponding to the modification method;
s440, for each modification method, determining the coverage rate of the modification code row corresponding to the modification method based on the modification code row.
According to another embodiment of the present disclosure, after determining to change the code line, if the code line is displayed on the user terminal only in the form of the number of lines, so that the user refers to the code line, the user needs to calculate the coverage rate of the modified code line based on the number of lines displayed. This results in a poor user experience. In order to further improve user experience, in the embodiment of the present disclosure, the coverage rate of the modified code line is automatically determined according to the determined modified code line.
S410-S430 may be implemented based on a similar method as S210-S230, which will not be described in detail in this specification. After the change code line is determined, a percentage of the change code line that occupies the total number of lines of the change method is determined and the percentage is determined to be the change code line coverage.
Specifically, counting the number of lines according to the changing method to obtain the total number of lines; counting the number of lines of the changed code to obtain the changed line number; and dividing the changed line number by the total line number to obtain the coverage rate of the modified code line. Specifically, the counting of the number of lines may be implemented based on a counting function (count), for example, and may be implemented based on any manner in which counting may be implemented, which is not limited in this specification.
Fig. 4B is a flowchart illustrating a method for determining the coverage rate of modified code lines according to an embodiment of the present disclosure. One modified code coverage determination process is depicted in FIG. 4B, but may include more or fewer operational steps based on conventional or non-inventive labor. As shown in fig. 4B, the method may include:
s441, for each modification method, determining a modification line number of a modification code line;
s442, traversing the modification method, determining unmodified code lines and determining unmodified line numbers of the unmodified code lines;
S443, determining the coverage rate of the modified code line corresponding to the modification method based on the modified line number and the unmodified line number.
According to another embodiment of the present specification, for each modification method, a modification code row corresponding thereto is determined; the number of data included in the change code line is calculated and used as the change line number.
Traversing a modification method to determine unmodified codes except for the row codes corresponding to the modified row numbers; counting the number of lines for the unmodified codes to obtain the unmodified number of lines. Specifically, determining an unmodified code other than the line code corresponding to the number of modified lines may determine the unmodified code based on any filtering means.
After the changed line number and the unchanged line number are determined, determining a modified code line coverage formula; and further processing the changed line number and the unchanged line number by using the modified code line coverage rate formula to obtain modified code line coverage rate. Specifically, the modified code line coverage formula may be configured according to practical situations, which is not limited in this specification.
Fig. 4C is a flowchart illustrating a method for determining a modified code coverage according to another embodiment of the present disclosure. Another modified code coverage determination process is depicted in fig. 4C, but may include more or fewer operational steps based on conventional or non-inventive labor. As shown in fig. 4C, the method may include:
S4431, determining the sum of the changed line number and the unchanged line number as the total line number;
s4432, determining the quotient of the number of changed lines and the total number of lines as the coverage rate of the modified code lines.
According to another embodiment of the present disclosure, for example, the number of data included in the determined change code line is 6, and the number of change lines is 6; the number of unchanged rows is 194, the total number of rows of the change method is 200. Thus, the calculation 6 is divided by 200, yielding 0.03. Thus, the modified code line coverage is determined to be three percent. Thus, the modified code line coverage is further refined.
Fig. 5 is a schematic diagram of a method for determining a commit identifier according to an embodiment of the present disclosure. One commit identity determination process is depicted in fig. 5, but may include more or fewer operational steps based on conventional or non-inventive labor. As shown in fig. 5, the method may include:
s521, processing each modification method by using the query submission history instruction to obtain a process file;
s522, matching the candidate item identification with each record identification included in the process file in a consistent manner, and determining a target record identification corresponding to the candidate item identification;
s523, taking target record information corresponding to the target record identification as a submitting identification from the process file.
According to another embodiment of the present disclosure, the query submission history instruction may be, for example, a Git Log instruction, which is similar to the existing Git Log instruction, and will not be described in detail herein. Specifically, each modification method is processed by using a Git Log instruction, and a process file corresponding to the modification method is obtained. The process file may include, for example, a commit record identification (i.e., as a commit identification), a commit user identification (author information of the commit), a commit time, and commit data, etc., with each item of information being associated with a corresponding record identification.
The candidate item identification may be, for example, a commit record identification (commit), the candidate item identification is consistent matched with each record identification included in the process file, and a target record identification that is consistent matched with the candidate item identification is determined from the plurality of record identifications. Further, target record information associated with the target record identity is determined, and the target record information is determined to be the commit identity. The commit identifier (commit id) may be, for example, a string of ciphertext of a target number of, for example, 10, and may be, for example, information that uniquely identifies the commit generated by each commit content and commit information, which may include, for example, a commit user identifier, commit time, and the like. For example, the contents and information may be processed by a hash function to obtain hash values.
Fig. 6 is a schematic diagram of a method for determining a modified code line according to an embodiment of the present disclosure. A change code line determination process is depicted in fig. 6, but may include more or fewer operational steps based on conventional or non-inventive labor. As shown in fig. 6, the method may include:
s631, processing each submission identifier by utilizing a query modification instruction to determine a history modification record;
s632, determining a change code line based on the history modification record and the change method.
According to another embodiment of the present disclosure, the query modification instruction is a Git Blame instruction, which is similar to the existing Git Blame instruction, and will not be described in detail herein. Specifically, each submitting identifier is processed by using a Git Blame instruction to obtain a plurality of change records; each change record is used as a history modification record. Specifically, each commit identifier is input into the Git Blame instruction as an argument, and a change record of the output of the GitBlame instruction can be obtained.
After determining the history modification record, the number of lines in the modification method of the history modification record may be checked again, for example, to avoid line number change after multiple modification, so as to obtain more accurate modified code lines. Specifically, the change code content corresponding to the history modification record is determined, the current line number of the change code content in the current change method is determined, and then the current line number is determined to be the change code line.
Fig. 7A is a schematic structural diagram of an incremental code line determining apparatus according to an embodiment of the present disclosure. As shown in fig. 7A, including,
the comparison unit 710 is configured to differentially compare the code to be detected and an original code corresponding to the code to be detected, and determine a modification method list;
a first determining unit 720, configured to determine, for each modification method in the modification method list, a commit identifier corresponding to the modification method; and
and a second determining unit 730, configured to determine a modified code line based on the commit identifier and the history modification record corresponding to the modification method.
Since the principle of the device for solving the problem is similar to that of the method, the implementation of the device can be referred to the implementation of the method, and the repetition is omitted.
Fig. 7B is a schematic structural diagram of an incremental code line determining apparatus according to another embodiment of the present disclosure. As shown in fig. 7B, including,
the comparison unit 710 is configured to differentially compare the code to be detected and an original code corresponding to the code to be detected, and determine a modification method list;
a first determining unit 720, configured to determine, for each modification method in the modification method list, a commit identifier corresponding to the modification method;
A second determining unit 730, configured to determine a modified code line based on the commit identifier and a history modification record corresponding to the modification method; and
the labeling unit 7140 is configured to, for each modification method, label the modification code row corresponding to the modification method.
Since the principle of the device for solving the problem is similar to that of the method, the implementation of the device can be referred to the implementation of the method, and the repetition is omitted.
Fig. 7C is a schematic structural diagram of an incremental code line determining apparatus according to another embodiment of the present disclosure. As shown in fig. 7C, including,
the comparison unit 710 is configured to differentially compare the code to be detected and an original code corresponding to the code to be detected, and determine a modification method list;
a first determining unit 720, configured to determine, for each modification method in the modification method list, a commit identifier corresponding to the modification method;
a second determining unit 730, configured to determine a modified code line based on the commit identifier and a history modification record corresponding to the modification method; and
a third determining unit 7240 for determining, for each modification method, a modified code line coverage corresponding to the modification method based on the modified code line.
Since the principle of the device for solving the problem is similar to that of the method, the implementation of the device can be referred to the implementation of the method, and the repetition is omitted.
Fig. 8 is a schematic structural diagram of a computer device according to an embodiment of the present disclosure, where an apparatus in the present disclosure may be the computer device in the present embodiment, and perform the method of the present disclosure. The computer device 802 may include one or more processing devices 804, such as one or more Central Processing Units (CPUs), each of which may implement one or more hardware threads. The computer device 802 may also include any storage resources 806 for storing any kind of information, such as code, settings, data, etc. For example, and without limitation, storage resources 806 may include any one or more of the following combinations: any type of RAM, any type of ROM, flash memory devices, hard disks, optical disks, etc. More generally, any storage resource may store information using any technology. Further, any storage resource may provide volatile or non-volatile retention of information. Further, any storage resources may represent fixed or removable components of computer device 702. In one case, the computer device 802 may perform any of the operations of the associated instructions when the processing device 804 executes the associated instructions stored in any storage resource or combination of storage resources. The computer device 802 also includes one or more drive mechanisms 808, such as a hard disk drive mechanism, an optical disk drive mechanism, and the like, for interacting with any storage resources.
The computer device 802 may also include an input/output module 810 (I/O) for receiving various inputs (via an input device 812) and for providing various outputs (via an output device 814). One particular output mechanism may include a presentation device 816 and an associated Graphical User Interface (GUI) 818. In other embodiments, input/output module 810 (I/O), input device 812, and output device 814 may not be included, but merely as a computer device in a network. The computer device 802 may also include one or more network interfaces 820 for exchanging data with other devices via one or more communication links 822. One or more communications buses 824 couple the above-described components together.
The communication link 822 may be implemented in any manner, such as, for example, through a local area network, a wide area network (e.g., the internet), a point-to-point connection, etc., or any combination thereof. Communication link 822 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc., governed by any protocol or combination of protocols.
The embodiments of the present specification also provide a computer readable storage medium storing a computer program which, when executed by a processor, implements the above method.
The present description also provides a computer program product comprising a computer program which, when executed by a processor, implements the above method.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present description is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing detailed description of the embodiments has been presented for purposes of illustration and description, and it should be understood that the foregoing is by way of example only, and is not intended to limit the scope of the invention.
Claims (14)
1. A method for determining an incremental code line, comprising:
performing differential comparison on a code to be detected and an original code corresponding to the code to be detected, and determining a change method list;
determining a commit identifier corresponding to each modification method in the modification method list; and
and determining a change code row based on the submission identification and a history modification record corresponding to the change method.
2. The method of claim 1, further comprising, after determining a change code line based on the commit identification and a historical modification record corresponding to the change method:
and for each modification method, modifying and labeling the modification code row corresponding to the modification method.
3. The method of claim 1, further comprising, after determining a change code line based on the commit identification and a historical modification record corresponding to the change method:
for each modification method, determining a modification code row coverage corresponding to the modification method based on the modification code row.
4. The method of claim 1, wherein differentially comparing the code to be detected with the original code corresponding to the code to be detected, and determining the list of modification methods comprises:
Comparing the code to be detected with the original code by using a comparison instruction to obtain an increment file list; and
and analyzing the increment file list by utilizing an analysis instruction to obtain the change method list.
5. The method of claim 1, wherein the determining, for each change method in the list of change methods, a commit identifier corresponding to the change method comprises:
processing each modification method by utilizing a query submission history instruction to obtain a process file; and
consistency matching is carried out on candidate item identifiers and each record identifier included in the process file, and target record identifiers corresponding to the candidate item identifiers are determined; and
and taking target record information corresponding to the target record identifier as the submitting identifier from the process file.
6. The method of claim 1, wherein the determining a change code line based on the commit identification and a historical modification record corresponding to the change method comprises:
processing the submitting identifications by utilizing a query modification instruction to determine the history modification record; and
The change code line is determined based on the history modification record and the change method.
7. The method of claim 3, wherein said determining, for each of said change methods, a change code line coverage corresponding to said change method based on said change code line comprises:
determining a change line number of the change code line according to each change method;
traversing the altering method, determining an unaltered code row and determining an unaltered row number with the unaltered code row; and
and determining the coverage rate of the modified code row corresponding to the modification method based on the modified row number and the unmodified row number.
8. The method of claim 7, wherein the determining the modified code line coverage corresponding to the modified method based on the number of modified lines and the number of unmodified lines comprises:
determining the sum of the changed line number and the unchanged line number as a total line number; and
and determining the quotient of the changed line number and the total line number as the coverage rate of the modified code line.
9. An incremental code line determining apparatus, comprising:
the comparison unit is used for carrying out differential comparison on the code to be detected and the original code corresponding to the code to be detected, and determining a change method list;
A first determining unit, configured to determine, for each modification method in the modification method list, a commit identifier corresponding to the modification method; and
and the second determining unit is used for determining a change code row based on the submission identification and the historical modification record corresponding to the change method.
10. The apparatus as recited in claim 9, further comprising:
and the marking unit is used for marking the change code row corresponding to each change method in a change way.
11. The apparatus as recited in claim 9, further comprising:
and a third determining unit configured to determine, for each modification method, a modification code line coverage corresponding to the modification method based on the modification code line.
12. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of the preceding claims 1-8 when executing the computer program.
13. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when executed by a processor, performs the method of any of the preceding claims 1-8.
14. A computer program product comprising computer programs/instructions which, when executed by a processor, implement the method according to any of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311694340.4A CN117687685A (en) | 2023-12-11 | 2023-12-11 | Incremental code line determining method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311694340.4A CN117687685A (en) | 2023-12-11 | 2023-12-11 | Incremental code line determining method and device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117687685A true CN117687685A (en) | 2024-03-12 |
Family
ID=90138529
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311694340.4A Pending CN117687685A (en) | 2023-12-11 | 2023-12-11 | Incremental code line determining method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117687685A (en) |
-
2023
- 2023-12-11 CN CN202311694340.4A patent/CN117687685A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9075718B2 (en) | Dynamic field extraction of log data | |
CN109241014B (en) | Data processing method and device and server | |
CN110764980A (en) | Log processing method and device | |
CN111563016A (en) | Log collection and analysis method and device, computer system and readable storage medium | |
CN111142863B (en) | Page generation method and device | |
US20150186195A1 (en) | Method of analysis application object which computer-executable, server performing the same and storage media storing the same | |
CN112433705A (en) | Script generation method and device, electronic equipment and storage medium | |
CN112070608A (en) | Information processing method, information processing apparatus, information processing medium, and electronic device | |
CN112329043A (en) | Information encryption processing method, device, computer equipment and medium | |
CN112540808B (en) | Recording method of program behavior hierarchy call relationship and related equipment | |
US9507814B2 (en) | Bit level comparator systems and methods | |
CN110503504B (en) | Information identification method, device and equipment of network product | |
CN112181485A (en) | Script execution method and device, electronic equipment and storage medium | |
CN112583805A (en) | Data processing method and device based on block chain, electronic equipment and storage medium | |
CN117687685A (en) | Incremental code line determining method and device, computer equipment and storage medium | |
CN111200654A (en) | Client request error processing method and device | |
CN116150816A (en) | File signature integrity verification method and device based on hash algorithm | |
CN111258628B (en) | Rule file comparison method and device, readable storage medium and terminal equipment | |
CN112395319A (en) | Cache sharing method, device, server and storage medium | |
CN113055760A (en) | Log processing method, device, equipment and storage medium | |
CN110647473A (en) | Anti-interference method and device for automatic regression test, computer equipment and storage medium | |
CN107609008A (en) | A kind of data importing device and method from relevant database to Kafka based on Apache Sqoop | |
CN117688564B (en) | Detection method, device and storage medium for intelligent contract event log | |
CA3129150C (en) | Interface message test method and device, computer equipment and storage medium | |
CN109032655A (en) | A kind of configuration method, server and computer readable storage medium monitoring example |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |