[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN109491923B - Method, device, medium and electronic equipment for determining newly added abnormal code - Google Patents

Method, device, medium and electronic equipment for determining newly added abnormal code Download PDF

Info

Publication number
CN109491923B
CN109491923B CN201811534275.8A CN201811534275A CN109491923B CN 109491923 B CN109491923 B CN 109491923B CN 201811534275 A CN201811534275 A CN 201811534275A CN 109491923 B CN109491923 B CN 109491923B
Authority
CN
China
Prior art keywords
code
file
check result
line number
determining
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.)
Active
Application number
CN201811534275.8A
Other languages
Chinese (zh)
Other versions
CN109491923A (en
Inventor
宋洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Neusoft Corp
Original Assignee
Neusoft Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Neusoft Corp filed Critical Neusoft Corp
Priority to CN201811534275.8A priority Critical patent/CN109491923B/en
Publication of CN109491923A publication Critical patent/CN109491923A/en
Application granted granted Critical
Publication of CN109491923B publication Critical patent/CN109491923B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3604Analysis of software for verifying properties of programs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The disclosure relates to a method, a device, a medium and an electronic device for determining a newly added abnormal code. The method comprises the following steps: acquiring a first check result generated by code check on a source code of a current version and a second check result generated by code check on a source code of a previous version of the current version, wherein the check result generated after the code check comprises a file name and a line number of a code file where an abnormal code is located; determining the code change condition between code files with the same file name in the first check result and the second check result according to the first check result and the second check result; and determining the newly added abnormal code of the source code of the current version relative to the source code of the previous version according to the code change condition. In this way, the accuracy of determining the newly added exception code can be improved.

Description

Method, device, medium and electronic equipment for determining newly added abnormal code
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a medium, and an electronic device for determining a newly added exception code.
Background
When the static check of the code is performed, a check result for the code is generated. In general, the output inspection result includes a file name, a line number, question description information, and the like. The file name is the file name of the file where the abnormal code is located, which is determined by the code check, and accordingly, the line number is the line number where the abnormal code is located, that is, the line number corresponding to the line where the abnormal code is located, and the problem description information is the problem description for the abnormal code. In practical application, because the code version is updated, an inspection result is generated for each version of the code, and technicians can solve problems occurring in the inspection results corresponding to the codes of the versions.
When problems are actually solved, abnormal codes which have appeared in the inspection result of the code of the previous version belong to known problems, and when the inspection result of the code of the next version is concerned, only the change of which codes in the code of the next version causes the inspection result of the next version to have new problems compared with the code of the previous version is needed to be determined, and the new problems are concerned to be solved, namely the new abnormal codes are concerned to be newly increased. Therefore, the two versions of the code are often compared differentially according to the checking result, i.e. it is determined which new abnormal codes are added to the code of the latter version compared with the code of the former version. In the prior art, the file name and the line number in the two previous and next version code checking results are generally subjected to simple text comparison to determine the difference result between the two. However, if the content of the abnormal code in a certain line of the two previous and next version codes is not changed, and a new line of code is added (or deleted) before the abnormal code in the latter version code, so that the line number of the abnormal code is changed, when determining the newly added abnormal code according to the method in the prior art, the file name and the line number of the file where the abnormal code in the line is located are determined according to the file name and the line number of the file where the abnormal code in the line is located, and because the line number of the abnormal code in the line is changed, the abnormal code in the line is determined as the newly added abnormal code, and the abnormal code in the line does not cause a new problem, which may cause an error in determining the newly added abnormal code, and reduce the work efficiency of technicians.
Disclosure of Invention
The invention aims to provide a method, a device, a medium and an electronic device for determining a newly added abnormal code, so as to accurately determine the newly added abnormal code.
In order to achieve the above object, according to a first aspect of the present disclosure, there is provided a method for determining a newly added exception code, the method including:
acquiring a first check result generated by code check on a source code of a current version and a second check result generated by code check on a source code of a previous version of the current version, wherein the check result generated after the code check comprises a file name and a line number of a code file where an abnormal code is located;
determining the code change condition between code files with the same file name in the first check result and the second check result according to the first check result and the second check result;
and determining the newly added abnormal code of the source code of the current version relative to the source code of the previous version according to the code change condition.
Optionally, the determining, according to the first check result and the second check result, a code change condition between code files with the same file name in the first check result and the second check result includes:
determining a target file name, wherein the target file name is a file name appearing in both the first inspection result and the second inspection result;
and sequentially taking the determined target file names as the current target file names, and executing the following operations:
determining new codes, changed codes and unchanged codes of a first code file relative to a second code file, wherein the first code file is a code file corresponding to the name of the current target file in the source codes of the current version, and the second code file is a code file corresponding to the name of the current target file in the source codes of the previous version;
if the new code exists, recording the line number of the new code in the first code file;
if the changed code exists, recording the line number of the changed code in the first code file;
and if the unchanged code exists, recording the line number of the unchanged code in the first code file and the line number in the second code file.
Optionally, the determining, according to the code change condition, a newly added exception code of the source code of the current version relative to the source code of the previous version includes:
if the line number information corresponding to the name of the current target file in the first check result comprises the line number of the newly added code in the first code file, determining the newly added code as the newly added abnormal code;
if the line number information corresponding to the name of the current target file in the first check result comprises the line number of the changed code in the first code file, determining that the changed code is the newly-added abnormal code;
and if the line number information corresponding to the current target file name in the first check result comprises the line number of the unmodified code in the first code file, and the line number information corresponding to the current target file name in the second check result does not comprise the line number of the unmodified code in the second code file, determining that the unmodified code is the newly added abnormal code.
Optionally, the method further comprises:
determining a new file name of the first check result relative to the second check result according to the first check result and the second check result;
and determining a code, of the code file corresponding to the name of the newly added file in the source code of the current version, of which the line number appears in the first check result as the newly added abnormal code.
According to a second aspect of the present disclosure, there is provided an apparatus for determining a newly added exception code, the apparatus including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a first check result generated by code check on a source code of a current version and a second check result generated by code check on a source code of a previous version of the current version, and the check results generated after the code check comprise the file name and the line number of a code file where an abnormal code is located;
a first determining module, configured to determine, according to the first check result and the second check result, a code change condition between code files with the same file name in the first check result and the second check result;
and the second determining module is used for determining the newly-added abnormal code of the source code of the current version relative to the source code of the previous version according to the code change condition.
Optionally, the first determining module is configured to determine a target file name, where the target file name is a file name appearing in both the first inspection result and the second inspection result; sequentially taking the determined target file name as a current target file name, and determining a new code, a changed code and an unchanged code of a first code file relative to a second code file, wherein the first code file is a code file corresponding to the current target file name in a source code of the current version, and the second code file is a code file corresponding to the current target file name in a source code of the previous version; if the new code exists, recording the line number of the new code in the first code file; if the changed code exists, recording the line number of the changed code in the first code file; and if the unchanged code exists, recording the line number of the unchanged code in the first code file and the line number in the second code file.
Optionally, the second determining module is configured to determine that the new code is the new exception code if the line number information corresponding to the current target file name in the first check result includes the line number of the new code in the first code file; if the line number information corresponding to the name of the current target file in the first check result comprises the line number of the changed code in the first code file, determining that the changed code is the newly-added abnormal code; and if the line number information corresponding to the current target file name in the first check result comprises the line number of the unmodified code in the first code file, and the line number information corresponding to the current target file name in the second check result does not comprise the line number of the unmodified code in the second code file, determining that the unmodified code is the newly added abnormal code.
Optionally, the apparatus further comprises:
a third determining module, configured to determine, according to the first inspection result and the second inspection result, a name of a new file of the first inspection result relative to the second inspection result;
and the fourth determining module is used for determining a code, of which the line number appears in the first check result, in the code file corresponding to the new file name in the source code of the current version as the new abnormal code.
According to a third aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to the first aspect of the present disclosure.
According to a fourth aspect of the present disclosure, there is provided an electronic device comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method of the first aspect of the disclosure.
According to the technical scheme, after a first check result generated by code check on the source code of the current version and a second check result generated by code check on the source code of the previous version of the current version are obtained, the code change condition between the code files with the same file name in the first check result and the second check result is determined according to the first check result and the second check result, and therefore the newly-added abnormal code of the source code of the current version relative to the source code of the previous version can be determined according to the code change condition. Therefore, the same code file name can be determined through the first check result and the second check result, then the code change condition between the code files with the same file name is determined, the relationship between the codes in the code files of the two previous versions can be obtained, and the newly-added abnormal code of the source code of the current version relative to the source code of the previous version can be accurately determined. Therefore, the accuracy of determining the newly added exception code can be improved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow diagram of a method of determining newly added exception code provided in accordance with one embodiment of the present disclosure;
fig. 2 is an exemplary schematic diagram of the content of a code file with the same file name in two version source codes in the method for determining a new exception code provided by the present disclosure;
FIG. 3 is a flowchart of an exemplary implementation of a step of determining a newly added exception code of a current version of a source code relative to a previous version of the source code according to a code change condition in a method for determining a newly added exception code provided by the present disclosure;
FIG. 4 is a block diagram of a newly added exception code determination apparatus provided in accordance with one embodiment of the present disclosure;
FIG. 5 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
Fig. 1 is a flowchart of a method for determining a newly added exception code according to an embodiment of the present disclosure. As shown in fig. 1, the method may include the following steps.
In step 11, a first check result generated by code checking the source code of the current version and a second check result generated by code checking the source code of the previous version of the current version are obtained.
The check result generated by performing code check on the source code may be a code static check result generated by performing static check on the source code, compilation information generated when the source code is compiled, or the like. The check result may include a file name and a line number of a code file in which the exception code is located. In addition, the examination result may further include question description information for indicating a question description for the abnormal code.
After the corresponding code inspection tool performs code inspection on the source code of the current version, a first inspection result is generated, and while the first inspection result is obtained, a second inspection result generated by performing code inspection on the source code of the previous version of the current version can be obtained, so that in the subsequent steps, a new abnormal code of the source code of the current version relative to the source code of the previous version is determined according to the first inspection result and the second inspection result.
In step 12, code change between code files with the same file name in the first and second check results is determined according to the first and second check results.
Determining the code change condition between the code files with the same file name in the first check result and the second check result can be beneficial to accurately determining the newly added abnormal code of the source code of the current version relative to the source code of the previous version. Code changes between code files having the same file name may include any one or more of the following: the line number of the newly added code in the current version code file, the line number of the changed code in the current version code file, and the line number of the unchanged code in the current version code file and the previous version code file respectively. And if no new code is added, no relevant information is recorded in the code change information, and the other similar reasons are carried out. The newly added codes are one or more lines of codes newly added to the current version code file relative to the previous version code file, the changed codes are one or more lines of codes of which the content of the current version code file is changed relative to the content of the previous version code file, and the unchanged codes are one or more lines of codes of which the content of the current version code file is not changed relative to the content of the previous version code file. If a plurality of code files with the same file name exist in the first check result and the second check result, corresponding code change information is recorded in each pair of code files with the same file name.
For example, if the first check result is { a, 3; a, 4; b, 10; b, 12; c, 15, and the second check result is { A, 3; a, 4, wherein the information contained in the inspection result is represented by the content in the { }', and the symbol is used; "distinguish each of the inspection resultsAnd groups, which sequentially contain file names and line numbers (which may also include problem description information, not shown in this disclosure) in each group of the inspection results. For the above example, it can be known that the same file name is file name a, and thus the code file with the same file name is code file a (the code file corresponding to file name a is code file a, for the sake of simplicity and convenience of description in this disclosure, the code file is represented by the same letter a, and the two are distinguished by descriptive characters "file name" and "code file"), then the code file a of the current version (denoted as code file a) can be determined1) With the code file A of the previous version (denoted as code file A)0) Code change condition in between. For the above example, then the code change case may include one or more of the following: code file A1Against code file A0New code and new code in code file A1Line number, code file A in1Against code file A0Changed code and changed code in code file A1Line number, code file A in1Against code file A0The unmodified code and the unmodified code are respectively in a code file A1And code file A0The row number in (1). Illustratively, code change conditions may be determined using third party software (e.g., diff tools).
In step 13, according to the code change situation, the newly added abnormal code of the source code of the current version relative to the source code of the previous version is determined.
According to the code change condition, for the code files with the same file name in the first check result and the second check result, which abnormal codes in the code files do not appear in the source code of the previous version can be determined, so that the newly added abnormal codes can be determined.
According to the scheme, after the first check result generated by code check on the source code of the current version and the second check result generated by code check on the source code of the previous version of the current version are obtained, the code change condition between the code files with the same file name in the first check result and the second check result is determined according to the first check result and the second check result, so that the new abnormal code of the source code of the current version relative to the source code of the previous version can be determined according to the code change condition. Therefore, the same code file name can be determined through the first check result and the second check result, then the code change condition between the code files with the same file name is determined, the relationship between the codes in the code files of the two previous versions can be obtained, and the newly-added abnormal code of the source code of the current version relative to the source code of the previous version can be accurately determined. Therefore, the accuracy of determining the newly added exception code can be improved.
In order to make those skilled in the art understand the technical solutions provided by the embodiments of the present invention, the following detailed descriptions are provided for the corresponding steps in the above.
First, a description will be given of a case where, in step 12, a code change between code files having the same file name in the first and second check results is determined from the first and second check results. In one possible embodiment, step 12 may include the steps of:
determining a target file name;
and sequentially taking the determined target file names as the current target file names, and executing target operation.
First, a target file name is determined, which is a file name appearing in both the first check result and the second check result. For example, if the first check result is { a, 3; a, 4; b, 10; b, 12; c, 15, and the second check result is { A, 3; a, 4; b, 9}, then the target filename is filename a and filename B.
And then, sequentially taking the determined target file names as current target file names, and executing target operation to sequentially determine the code change condition among the code files corresponding to each current target file name. For example, if the target file name includes a file name a and a file name B, the file name a and the file name B may be sequentially used as the current target file name, so as to sequentially determine a code change situation between the current version and the previous version of the code file a and a code change situation between the current version and the previous version of the code file B. It should be noted that, the present disclosure is not limited to the target file names as the order of the current target file names.
Wherein the target operation may include:
determining new code, changed code, and unchanged code of the first code file relative to the second code file;
if the newly added code exists, recording the line number of the newly added code in the first code file;
if the changed code exists, recording the line number of the changed code in the first code file;
if the unmodified code exists, recording the line number of the unmodified code in the first code file and the line number in the second code file.
The first code file is a code file corresponding to the name of the current target file in the source code of the current version, and the second code file is a code file corresponding to the name of the current target file in the source code of the previous version. Illustratively, the new code, changed code, and unchanged code of the first code file relative to the second code file may be determined directly using third party software (e.g., diff tools). In addition, the third-party software can also obtain the line number information of the code, for example, the line number of a certain code in the first file and the line number of a certain code in the second file. If the new code exists, recording the line number of the new code in the first code file; if the changed code exists, recording the line number of the changed code in the first code file; if the unmodified code exists, recording the line number of the unmodified code in the first code file and the line number in the second code file.
For example, if the file name a appears in both the first and second checking results, and the codes of the code file a in the source codes of the current version and the previous version are as shown in fig. 2, only the line number where the code is located is shown in fig. 2, and the specific content of the code is not shown. The number represents the line number of the code, the content with single underline represents the newly added code in the current version A file, the content with double underline represents the deleted code in the current version A file, the content with small box represents the code with changed content in the current version A file, and the dotted line represents the corresponding relationship between the unchanged codes in the previous and next version A files. Therefore, the code change situation between the two versions of the code file a may include information Y1 ═ 4, 5} regarding the new code of the code file a, may further include information Y2 ═ 16, 17, 18} regarding the changed code of the code file a, and at the same time, may further include information Y3 ═ 1-1; 2-2; 3-3; 4-6; 5-7; 6-8; 7-9; 8-10; 10-11; 11-12; 12-13; 13-14; 14-15; 15-16; 16-17; 17-18; 18-19; 19-20}. Wherein, what is recorded in Y1 is the line number of the code file a in the current version relative to the previous version, what is recorded in Y2 is the line number of the code file a in the current version relative to the previous version changed code, what is recorded in Y3 is the line number of the code file a in the current version and the previous version of the current version relative to the previous version unchanged code, the number before the symbol "-" represents the line number of the unchanged code in the code file a of the current version, and the number after the symbol "-" represents the line number of the unchanged code in the code file a of the previous version.
By the method, the code change condition can be determined for the code files with the same file names in the first check result and the second check result, so that more accurate data support is provided for subsequent determination of the newly added abnormal code, and the accuracy of determining the newly added abnormal code is improved.
The following description is given to determine that the source code of the current version is a new exception code of the source code of the previous version according to the code change condition in step 13. In one possible embodiment, as shown in fig. 3, step 13 may include the following steps:
in step 31, if the line number information corresponding to the name of the current target file in the first check result includes the line number of the new code in the first code file, determining that the new code is a new abnormal code;
in step 32, if the line number information corresponding to the name of the current target file in the first check result includes the line number of the modified code in the first code file, determining that the modified code is a newly-added abnormal code;
in step 33, if the line number information corresponding to the current target file name in the first check result includes the line number of the unmodified code in the first code file, and the line number information corresponding to the current target file name in the second check result does not include the line number of the unmodified code in the second code file, it is determined that the unmodified code is the new exception code.
Exemplarily, if the first check result is C1 ═ { a, 2; a, 4; a, 7; a, 13; a, 16; a, 19; b, 25; b, 30}, and the second check result is C2 ═ a, 2; a, 5; a, 15; a, 18 }. The same file name is known as file name a, assuming that two versions of code file a are as shown in fig. 2.
Then, as can be seen from the code change situation, the line number of the new code in the current version code file a is 4, 5, and the line number information about the file name a in the first check result includes 2, 4, 7, 13, 16 and 19, it can be determined that the 4 th line code in the current version code file a is the new exception code, and the 5 th line code is the new code but does not cause an exception.
And the line numbers of the changed codes in the current version code file A are 16, 17 and 18, and the line number information about the file name A in the first check result contains 2, 4, 7, 13, 16 and 19, then it can be determined that the 16 th line code in the current version code file A is the new exception code, and the 17 th and 18 th line codes have a change in content compared with the previous version, but the change does not cause a new code exception.
And the line numbers of the unmodified codes in the code file a of the current version and the previous version are recorded as Y3 ═ 1-1; 2-2; 3-3; 4-6; 5-7; 6-8; 7-9; 8-10; 10-11; 11-12; 12-13; 13-14; 14-15; 15-16; 16-17; 17-18; 18-19; 19-20, and 2, 4, 7, 13, 16, and 19 are included in the line number information on the file name a in the first check result, and 2, 5, 15, and 18 are included in the line number information on the file name a in the second check result. The first check result includes line number 2, which is known from Y3 to correspond to line number 2 in the previous version code file, and the second check result includes line number 2, which is known to belong to the exception code in the previous version code file, so that the 2 nd line code in the current version code file a does not belong to the newly added exception code; the first checking result includes line number 7, which is known from Y3 to correspond to line number 5 in the previous version code file, and the second checking result includes line number 5, which is known to belong to the exception code in the previous version code file, so that the 7 th line code in the current version code file a does not belong to the newly added exception code; the first checking result includes line number 13, which is known from Y3 to correspond to line number 12 in the previous version code file, and the second checking result does not include line number 12, which is known to not belong to the exception code in the previous version code file, so that line number 13 in the current version code file a belongs to the newly added exception code; the first check result includes a line number 19, which is known to correspond to the line number 18 in the previous version code file from Y3, and the second check result includes a line number 18, which is known to belong to an exception code in the previous version code file, so that the 13 th line code in the current version code file a does not belong to the newly added exception code.
Thus, for the above example, the resulting new exception code for the current version of source code relative to the previous version of source code is the 4 th, 13 th, and 16 th line code in the current version of code file a. It should be noted that the new exception code obtained here is for the code file with the same file name in the first check result and the second check result.
By the scheme, the determined exception code can be ensured to be the newly added exception code, and the accuracy of determining the newly added exception code is improved.
In a possible implementation manner, the method for determining a newly added exception code provided by the present disclosure may further include the following steps:
determining the name of the newly added file of the first check result relative to the second check result according to the first check result and the second check result;
and determining codes, of the code files corresponding to the names of the newly added files in the source codes of the current version, of which the line numbers appear in the first check result as newly added abnormal codes.
Exemplarily, if the first check result is C1 ═ { a, 2; a, 4; a, 7; a, 13; a, 16; a, 19; b, 25; b, 30}, and the second check result is C2 ═ a, 2; a, 5; a, 15; a, 18 }. It may be determined that the new file name of the first check result relative to the second check result is the file name B.
The new file name may reflect that the source code of the current version has an abnormal code in other code files, which is different from the abnormal code of the source code of the previous version, except the code file in which the abnormal code of the previous version is located. Therefore, the code of the code file corresponding to the new file name in the source code of the current version, the line number of which appears in the first check result, can be directly determined as the new exception code. Exemplarily, if the first check result is C1 ═ { a, 2; a, 4; a, 7; a, 13; a, 16; a, 19; b, 25; b, 30}, and the second check result is C2 ═ a, 2; a, 5; a, 15; a, 18}, then the newly added exception code may be determined to be the 25 th line and 30 th line code in the code file B of the current version.
Through the scheme, the new file name of the first check result relative to the second check result can be determined, and the new abnormal code is determined according to the new file name.
By combining the above-mentioned manner of determining the newly added exception code for the code files with the same file name and the manner of determining the newly added exception code for the newly added file name, all the newly added exception codes of the source code of the current version relative to the source code of the previous version can be obtained, and the accuracy can be ensured.
Fig. 4 is a block diagram of a newly added exception code determination apparatus provided according to an embodiment of the present disclosure. As shown in fig. 4, the apparatus 40 may include:
an obtaining module 41, configured to obtain a first check result generated by performing code check on a source code of a current version and a second check result generated by performing code check on a source code of a previous version of the current version, where the check result generated after the code check includes a file name and a line number of a code file where an abnormal code is located;
a first determining module 42, configured to determine, according to the first check result and the second check result, a code change condition between code files with the same file name in the first check result and the second check result;
a second determining module 43, configured to determine, according to the code change condition, a newly added exception code of the current version of the source code relative to the previous version of the source code.
Optionally, the first determining module 42 is configured to determine a target file name, where the target file name is a file name appearing in both the first inspection result and the second inspection result; sequentially taking the determined target file name as a current target file name, and determining a new code, a changed code and an unchanged code of a first code file relative to a second code file, wherein the first code file is a code file corresponding to the current target file name in a source code of the current version, and the second code file is a code file corresponding to the current target file name in a source code of the previous version; if the new code exists, recording the line number of the new code in the first code file; if the changed code exists, recording the line number of the changed code in the first code file; and if the unchanged code exists, recording the line number of the unchanged code in the first code file and the line number in the second code file.
Optionally, the second determining module 43 is configured to determine that the new code is the new exception code if the line number information corresponding to the name of the current target file in the first check result includes the line number of the new code in the first code file; if the line number information corresponding to the name of the current target file in the first check result comprises the line number of the changed code in the first code file, determining that the changed code is the newly-added abnormal code; and if the line number information corresponding to the current target file name in the first check result comprises the line number of the unmodified code in the first code file, and the line number information corresponding to the current target file name in the second check result does not comprise the line number of the unmodified code in the second code file, determining that the unmodified code is the newly added abnormal code.
Optionally, the apparatus 40 further comprises:
a third determining module, configured to determine, according to the first inspection result and the second inspection result, a name of a new file of the first inspection result relative to the second inspection result;
and the fourth determining module is used for determining a code, of which the line number appears in the first check result, in the code file corresponding to the new file name in the source code of the current version as the new abnormal code.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
FIG. 5 is a block diagram illustrating an electronic device in accordance with an example embodiment. For example, the electronic device 1900 may be provided as a server. Referring to fig. 5, an electronic device 1900 includes a processor 1922, which may be one or more in number, and a memory 1932 for storing computer programs executable by the processor 1922. The computer program stored in memory 1932 may include one or more modules that each correspond to a set of instructions. Further, the processor 1922 may be configured to execute the computer program to perform the method of determining the newly added exception code described above.
Additionally, electronic device 1900 may also include a power component 1926 and a communication component 1950, the power component 1926 may be configured to perform power management of the electronic device 1900, and the communication component 1950 may be configured to enable communication, e.g., wired or wireless communication, of the electronic device 1900. In addition, the electronic device 1900 may also include input/output (I/O) interfaces 1958. The electronic device 1900 may operate based on an operating system, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, etc., stored in memory 1932.
In another exemplary embodiment, a computer readable storage medium including program instructions, which when executed by a processor, implement the steps of the method for determining a newly added exception code described above is also provided. For example, the computer readable storage medium may be the memory 1932 comprising program instructions executable by the processor 1922 of the electronic device 1900 to perform the method for determining new exception code described above.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. In order to avoid unnecessary repetition, various possible combinations will not be separately described in this disclosure.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.

Claims (6)

1. A method for determining new exception code, the method comprising:
acquiring a first check result generated by code check on a source code of a current version and a second check result generated by code check on a source code of a previous version of the current version, wherein the check result generated after the code check comprises a file name and a line number of a code file where an abnormal code is located;
determining the code change condition between code files with the same file name in the first check result and the second check result according to the first check result and the second check result;
determining the newly added abnormal code of the source code of the current version relative to the source code of the previous version according to the code change condition;
the determining, according to the first check result and the second check result, a code change condition between code files with the same file name in the first check result and the second check result includes:
determining a target file name, wherein the target file name is a file name appearing in both the first inspection result and the second inspection result;
and sequentially taking the determined target file names as the current target file names, and executing the following operations:
determining new codes, changed codes and unchanged codes of a first code file relative to a second code file, wherein the first code file is a code file corresponding to the name of the current target file in the source codes of the current version, and the second code file is a code file corresponding to the name of the current target file in the source codes of the previous version;
if the new code exists, recording the line number of the new code in the first code file;
if the changed code exists, recording the line number of the changed code in the first code file;
if the unmodified code exists, recording the line number of the unmodified code in the first code file and the line number in the second code file;
the determining, according to the code change condition, a newly added exception code of the current version of the source code relative to the previous version of the source code includes:
if the line number information corresponding to the name of the current target file in the first check result comprises the line number of the newly added code in the first code file, determining the newly added code as the newly added abnormal code;
if the line number information corresponding to the name of the current target file in the first check result comprises the line number of the changed code in the first code file, determining that the changed code is the newly-added abnormal code;
and if the line number information corresponding to the current target file name in the first check result comprises the line number of the unmodified code in the first code file, and the line number information corresponding to the current target file name in the second check result does not comprise the line number of the unmodified code in the second code file, determining that the unmodified code is the newly added abnormal code.
2. The method of claim 1, further comprising:
determining a new file name of the first check result relative to the second check result according to the first check result and the second check result;
and determining a code, of the code file corresponding to the name of the newly added file in the source code of the current version, of which the line number appears in the first check result as the newly added abnormal code.
3. An apparatus for determining a newly added exception code, the apparatus comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a first check result generated by code check on a source code of a current version and a second check result generated by code check on a source code of a previous version of the current version, and the check results generated after the code check comprise the file name and the line number of a code file where an abnormal code is located;
a first determining module, configured to determine, according to the first check result and the second check result, a code change condition between code files with the same file name in the first check result and the second check result;
the second determining module is used for determining the newly-added abnormal code of the source code of the current version relative to the source code of the previous version according to the code change condition;
the first determining module is configured to determine a target file name, where the target file name is a file name appearing in both the first inspection result and the second inspection result; sequentially taking the determined target file name as a current target file name, and determining a new code, a changed code and an unchanged code of a first code file relative to a second code file, wherein the first code file is a code file corresponding to the current target file name in a source code of the current version, and the second code file is a code file corresponding to the current target file name in a source code of the previous version; if the new code exists, recording the line number of the new code in the first code file; if the changed code exists, recording the line number of the changed code in the first code file; if the unmodified code exists, recording the line number of the unmodified code in the first code file and the line number in the second code file;
the second determining module is configured to determine that the newly added code is the newly added abnormal code if the line number information corresponding to the current target file name in the first check result includes the line number of the newly added code in the first code file; if the line number information corresponding to the name of the current target file in the first check result comprises the line number of the changed code in the first code file, determining that the changed code is the newly-added abnormal code; and if the line number information corresponding to the current target file name in the first check result comprises the line number of the unmodified code in the first code file, and the line number information corresponding to the current target file name in the second check result does not comprise the line number of the unmodified code in the second code file, determining that the unmodified code is the newly added abnormal code.
4. The apparatus of claim 3, further comprising:
a third determining module, configured to determine, according to the first inspection result and the second inspection result, a name of a new file of the first inspection result relative to the second inspection result;
and the fourth determining module is used for determining a code, of which the line number appears in the first check result, in the code file corresponding to the new file name in the source code of the current version as the new abnormal code.
5. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method as claimed in claim 1 or 2.
6. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of claim 1 or 2.
CN201811534275.8A 2018-12-14 2018-12-14 Method, device, medium and electronic equipment for determining newly added abnormal code Active CN109491923B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811534275.8A CN109491923B (en) 2018-12-14 2018-12-14 Method, device, medium and electronic equipment for determining newly added abnormal code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811534275.8A CN109491923B (en) 2018-12-14 2018-12-14 Method, device, medium and electronic equipment for determining newly added abnormal code

Publications (2)

Publication Number Publication Date
CN109491923A CN109491923A (en) 2019-03-19
CN109491923B true CN109491923B (en) 2021-11-12

Family

ID=65710290

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811534275.8A Active CN109491923B (en) 2018-12-14 2018-12-14 Method, device, medium and electronic equipment for determining newly added abnormal code

Country Status (1)

Country Link
CN (1) CN109491923B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110532174B (en) * 2019-07-24 2024-05-31 平安科技(深圳)有限公司 Method, device, computer equipment and storage medium for calculating increment code coverage rate
CN112000577B (en) * 2020-08-25 2023-12-26 得到(天津)文化传播有限公司 Code checking method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101937392A (en) * 2010-08-27 2011-01-05 华南理工大学 A Dynamic Defect Detection Method for Embedded Software
CN103577319A (en) * 2012-08-07 2014-02-12 腾讯科技(深圳)有限公司 Source code file detection method, source code file detection device and file release system
CN103942143A (en) * 2014-04-09 2014-07-23 烽火通信科技股份有限公司 PC-Lint code inspection result screening method based on version repository comparison
CN105335277A (en) * 2014-06-27 2016-02-17 可牛网络技术(北京)有限公司 Fault information processing method and device as well as terminal
CN106445476A (en) * 2015-08-11 2017-02-22 腾讯科技(深圳)有限公司 Code change information determination method and device and electronic equipment
CN108304327A (en) * 2018-02-02 2018-07-20 平安证券股份有限公司 Static code scanning result treating method and apparatus

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2003549B1 (en) * 2002-07-03 2016-04-27 National Instruments Corporation Wireless deployment/distributed execution of graphical programs to smart sensors
CN102929733B (en) * 2012-10-18 2015-02-11 北京奇虎科技有限公司 Method and device for processing error files and client-side equipment
US9135140B2 (en) * 2012-11-30 2015-09-15 Lenovo Enterprise Solutions (Singapore) Pte. Ltd. Identifying software responsible for a change in system stability
EP3144816A1 (en) * 2015-09-15 2017-03-22 Tata Consultancy Services Limited Static analysis based efficient elimination of false positives
US9785537B2 (en) * 2015-10-15 2017-10-10 International Business Machines Corporation Runtime exception and bug identification within an integrated development environment
CN105824756B (en) * 2016-03-17 2019-01-04 南京大学 A kind of out-of-date demand automatic testing method and system based on code dependence
CN106294134B (en) * 2016-07-29 2018-02-23 腾讯科技(深圳)有限公司 The collapse localization method and device of code
CN106250319B (en) * 2016-08-15 2018-02-27 腾讯科技(深圳)有限公司 Static code scanning result treating method and apparatus

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101937392A (en) * 2010-08-27 2011-01-05 华南理工大学 A Dynamic Defect Detection Method for Embedded Software
CN103577319A (en) * 2012-08-07 2014-02-12 腾讯科技(深圳)有限公司 Source code file detection method, source code file detection device and file release system
CN103942143A (en) * 2014-04-09 2014-07-23 烽火通信科技股份有限公司 PC-Lint code inspection result screening method based on version repository comparison
CN105335277A (en) * 2014-06-27 2016-02-17 可牛网络技术(北京)有限公司 Fault information processing method and device as well as terminal
CN106445476A (en) * 2015-08-11 2017-02-22 腾讯科技(深圳)有限公司 Code change information determination method and device and electronic equipment
CN108304327A (en) * 2018-02-02 2018-07-20 平安证券股份有限公司 Static code scanning result treating method and apparatus

Also Published As

Publication number Publication date
CN109491923A (en) 2019-03-19

Similar Documents

Publication Publication Date Title
US8434062B2 (en) Enhancing source code debugging and readability using visual symbols
US20160283357A1 (en) Call stack relationship acquiring method and apparatus
CN106250319B (en) Static code scanning result treating method and apparatus
CN112817935A (en) Data processing method, device and equipment based on field type and storage medium
CN110990276A (en) Automatic testing method and device for interface field and storage medium
CN109491923B (en) Method, device, medium and electronic equipment for determining newly added abnormal code
CN112559337A (en) Code coverage rate testing method and device, electronic equipment and storage medium
CN111708542B (en) Test case generation method, system, equipment and storage medium
CN118503214A (en) Engineering file processing method and device and electronic equipment
CN111046393B (en) Vulnerability information uploading method and device, terminal equipment and storage medium
CN104536897A (en) Automatic testing method and system based on keyword
CN113703753A (en) Method and device for product development and product development system
CN112433943A (en) Method, device, equipment and medium for detecting environment variable based on abstract syntax tree
CN117454038A (en) Page detection method and device
CN111045922B (en) Test case generation method and system
CN115587046A (en) Code exception processing method and device, storage medium and computer equipment
CN113159971B (en) Information extraction method, device, electronic device and readable storage medium
CN114840485B (en) Log matching method, device, equipment, storage medium and product
CN115080596B (en) Data processing method, device, computer equipment and storage medium
CN112905169B (en) Method and device for automatically positioning naming space reference problem
CN119415436A (en) A WCET acquisition method and device based on dynamic measurement
CN111126015B (en) Report form compiling method and equipment
CN112019644B (en) Method, system, medium and equipment for determining attribution information of IP address
CN115470214A (en) DBC file generation method and device and electronic equipment
CN118250349A (en) Protocol text difference recognition method, device, equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant