Code defect automatic detection and repair method based on artificial intelligence

Through the AI-based code defect identification model, identification bias in data processing business logic is identified and optimized, and combined with test cases and multiple recognition, the problem of insufficient reliability in code defect detection and repair is solved, and repair efficiency and reliability are improved.

CN120407371AActive Publication Date: 2025-08-01HANGYIN CONSUMER FINANCE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510918813.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-04
Publication Date
2025-08-01
Estimated Expiration
2045-07-04

AI Technical Summary

Technical Problem

In the process of code defect detection and repair, the existing technology ignores differentiated repair strategies, resulting in insufficient reliability of code defect identification and low repair efficiency in some business scenarios, especially in the data processing business logic, which cannot be effectively identified.

Method used

Through the code defect identification model based on artificial intelligence, the identification deviation of the model in the data processing business logic of different software codes is identified, and the identification deviation business logic is determined. Based on the overlapping data of the identification deviation situation and the code defect, the repair processing strategy is optimized, and the test cases and multiple recognitions are combined for repair.

Benefits of technology

It improves the reliability and repair efficiency of code defect detection, ensures the reliability and accuracy of repair processing, avoids the problem of too slow repair efficiency caused by unreliable detection results, and realizes reliable evaluation and optimization adjustment of repair results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407371A_ABST
    Figure CN120407371A_ABST
Patent Text Reader

Abstract

The invention provides a code defect automatic detection and repair method based on artificial intelligence, which belongs to the technical field of safety management, and specifically comprises the following steps: according to the identification deviation conditions of different identification deviation business logics and the composition data of code defects in corresponding software codes, determining the code defects in the software codes; and determining verification processing strategies and to-be-optimized targets of the software codes corresponding to the different identification deviation business logics before the code defects are repaired, and determining repair targets in the code defects based on verification results. According to the method and the device, the optimization adjustment mode of the verification processing strategy of the to-be-optimized target during next code repair processing is determined according to the operation data of the to-be-optimized target in different repair processing times and the change condition of the repair target in different repair processing times, so that the efficiency of code defect repair processing is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of test management, and particularly relates to a method for automatically detecting and repairing code defects based on artificial intelligence. Background Art

[0002] In the existing technical solutions for identifying code defects, testers often need to construct test cases to identify code defects. Since it completely relies on the testing experience of testers, it inevitably leads to the accuracy of code defect identification being difficult to meet the requirements. After the software code is put on the market, various software defects often occur, making the operation reliability of the software system difficult to meet the requirements.

[0003] To solve the above technical problems, specifically in the invention patent application CN202510250627.0 "A Software Automatic Testing Method and Device Based on Artificial Intelligence", the construction of test cases is automatically carried out based on artificial intelligence, thereby improving the comprehensiveness and accuracy of code defect identification. However, the following technical problems exist in the existing technical solutions: In the process of detecting and repairing code defects, the existing technical solutions ignore generating differentiated repair processing strategies according to the detection results. Specifically, in some business scenarios, due to the deviation of the training data of the artificial intelligence model, the reliability of code defect identification in some data processing business logics is difficult to meet the requirements. As a result, code defects in the above data processing business logics, such as null pointer exceptions, pointer exceptions, and branch logic defects, may not be effectively identified, and the time-consuming for automatic code repair processing is too long and the code defect problem cannot be effectively solved. Therefore, how to pre-process the identification deviation business logic in the code to improve the reliability of code defect detection and repair processing has become an urgent technical problem to be solved.

[0004] To solve the above technical problems, the present application provides a method for automatically detecting and repairing code defects based on artificial intelligence. Summary of the Invention

[0005] To achieve the object of the present invention, the present invention adopts the following technical solutions: Specifically, the present application provides a method for automatically detecting and repairing code defects based on artificial intelligence, which specifically includes: S1 Using the historical identification data of the code defect identification model based on artificial intelligence, determine the identification deviation situation of the identification model in the data processing business logics of different software codes, and determine the identification deviation business logic in the data processing business logic based on the identification deviation situation; S2 performs detection and processing of code defects in software code based on the recognition model to obtain code defects. When it is determined that the recognition reliability of the code defects of the recognition model meets the requirements according to the coincidence data between the code defects and different recognition deviation business logics, the next step is entered; S3 determines the verification processing strategy and the target to be optimized for the software code corresponding to different recognition deviation business logics before the code defects are repaired according to the recognition deviation situations of different recognition deviation business logics and the composition data of the code defects in the corresponding software code; S4 determines the repair target in the code defects based on the verification results, and determines the optimization adjustment method of the verification processing strategy for the target to be optimized in the next code repair process based on the running data of the target to be optimized in different repair processing times and the change situation of the repair target in different repair processing times.

[0006] The beneficial effects of the present invention are as follows: According to the coincidence data between the code defects and different recognition deviation business logics, it is determined whether the recognition reliability of the code defects of the recognition model meets the requirements, thus fully considering the difference in the reliability of the recognition processing results of the code defects caused by the difference in the coincidence degree with the recognition deviation business logics, thereby avoiding the technical problem of slow repair processing efficiency caused by unreliable detection results of the code defects in the original direct repair processing of software code, and also laying a foundation for further determining the differential verification processing strategy and ensuring the reliability of the repair processing.

[0007] Based on the running data of the target to be optimized in different repair processing times and the change situation of the repair target in different repair processing times, the optimization adjustment method of the verification processing strategy for the target to be optimized in the next code repair process is determined. Not only is an accurate assessment of the probability of whether there are software defects in the target to be optimized achieved based on the change situation of the running results of the target to be optimized, but also an accurate assessment of the reliability of the repair results is achieved based on the change situation of the repair target. Furthermore, the optimization adjustment method of the verification processing strategy for the target to be optimized in the next code repair process is determined from two perspectives: the probability of having defects and the reliability of the repair processing, improving the efficiency and reliability of the repair processing.

[0008] A further technical solution lies in that the recognition deviation situation in the data processing business logic includes the number of recognition deviations of the code defects in the data processing business logic.

[0009] A further technical solution lies in that the data processing business logic is divided according to the function types of the data processing called.

[0010] A further technical solution is that the function types include mathematical operation functions, conditional branch control functions, text processing functions, date and time functions, and aggregation and statistical functions.

[0011] A further technical solution is that the method for determining the recognition deviation business logic in the data processing business logic is as follows: Based on the recognition deviation situation of the recognition model in the data processing business logics of different software codes, determine the number of recognition deviations of the data processing business logic; Based on the number of recognition deviations, determine whether the data processing business logic is a recognition deviation business logic.

[0012] A further technical solution is that the method for determining the verification processing strategy before the next step of fixing code defects for the target to be optimized is as follows: Based on the running data of different targets to be optimized in different numbers of repair processes, determine the targets to be optimized with inconsistent running results or inconsistent with the target running results in different numbers of repair processes, and use them as the target with running result deviation; According to the change situation of the repair targets in different numbers of repair processes, determine the number of newly added repair targets after the previous repair process in different numbers of repair processes, and use it as the number of newly added targets; Based on the number of newly added targets and the number of targets with running result deviation in different numbers of repair processes, determine the verification processing strategy before the next step of fixing code defects for the target to be optimized.

[0013] Other features and advantages will be described in the subsequent description. The objectives and other advantages of the present invention are achieved and obtained by the structures specifically pointed out in the description and the drawings.

[0014] To make the above objectives, features, and advantages of the present invention more obvious and understandable, the following specific preferred embodiments are given, and in conjunction with the accompanying drawings, the detailed description is as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] By referring to the accompanying drawings and describing its exemplary embodiments in detail, the above and other features and advantages of the present invention will become more obvious.

[0016] Figure 1 is a flowchart of a method for automatically detecting and fixing code defects based on artificial intelligence; Figure 2 is a flowchart of a method for determining the recognition deviation business logic in the data processing business logic; Figure 3 is a flowchart for determining that the recognition processing reliability of the recognition model meets the requirements; Figure 4 It is a flowchart of a method for determining a verification processing strategy before repairing code defects in the next step for the target to be optimized. Specific implementation mode

[0017] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on the embodiments of this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this specification.

[0018] In this application, by performing the identification process of the identification deviation business logic in the identification model, and then based on the operation results of the identification model during the automatic repair process of the software code, the verification processing strategy for the identification deviation business logic in the next repair process is determined, so as to timely use test cases for verification and adjustment processing, thereby improving the efficiency of the repair processing.

[0019] The target to be optimized is the target software code with inconsistent positions of code defects in different numbers of identification processes.

[0020] The targets to be optimized with inconsistent operation results in different repair processes or inconsistent with the target operation results are used as the operation result deviation targets. According to the changes in the repair targets in different repair processes, the number of newly added repair targets after the previous repair process in different repair processes is determined and used as the newly added target number. When there are newly added repair targets in all different repair processes, in order to improve the reliability of the repair process, all targets to be optimized and the target software code that has not been verified by test cases before repairing code defects in the target software code are verified by test cases; When there are no newly added repair targets in all different repair processes, the operation result deviation targets are verified by test cases, and other targets to be optimized still use the method of multiple identification processes to verify the target software code before repairing code defects.

[0021] In one of the embodiments: For the recognition model in the data processing business logic corresponding to the text processing function, it has a relatively large number of recognition times in history. When the proportion of the number of recognition deviations in the text processing function in the total number of historical recognition processes is above 0.6, the text processing function is regarded as the recognition deviation business logic at this time. When using the recognition model to identify and process code defects in the software code for the risk control model, if a relatively large number of all code defects fall into the text processing function, in a possible embodiment, if 1 / 4 of the number of code defects fall into the text processing function, it can be determined at this time that there is a risk of recognition deviation, that is, the recognition reliability does not meet the requirements. When the recognition reliability does not meet the requirements, at this time, due to the relatively large number of code defects in the text processing function and its relatively large number of recognition deviations, on this basis, if the number of code defects in the software code block including the text processing function is relatively small, through multiple recognitions, that is, using the recognition model to perform multiple code defect recognitions on the software code block including the text processing function. When the code defects in different recognition processes are all inconsistent, the software code block is determined as the target to be optimized. The software code block is divided according to independent sub-functions, and each sub-function is divided into the software code block.

[0022] Repair the code defects that do not belong to the target to be optimized. Specifically, manual repair or automatic repair using the recognition model can be used. When the number of repair processes is more than 5 times, there are code defects in different repair processes, and there are new repair targets compared with the previous repair process. Then, directly use the test data to repair the code defects of the target to be optimized.

[0023] As Figure 1 shown, this application provides an automatic code defect detection and repair method based on artificial intelligence, specifically including: S1 Use the historical recognition data of the code defect recognition model based on artificial intelligence to determine the recognition deviation situation of the recognition model in the data processing business logic of different software codes, and determine the recognition deviation business logic in the data processing business logic based on the recognition deviation situation; Furthermore, the recognition deviation situation in the data processing business logic includes the number of recognition deviations of the code defects in the data processing business logic.

[0024] It should be noted that for the code defect recognition model based on artificial intelligence, common code defects, software codes with code defects, and repair methods can be input into the model of the neural network based on the RNN algorithm for training. Thus, based on the input volume of the software code, the neural network model can automatically locate the positions with code defects and output repair suggestions.

[0025] In addition, it should be noted that the data processing service logic is divided according to the type of data processing function called.

[0026] It can be understood that the function types include mathematical operation functions, conditional branch control functions, text processing functions, date and time functions, and aggregation and statistical functions.

[0027] Specifically, as Figure 2 shown, the method for determining the recognition deviation service logic in the data processing service logic is as follows: Based on the recognition deviation situation of the recognition model in the data processing service logic of different software codes, determine the number of recognition deviations of the data processing service logic; Based on the number of recognition deviations, determine whether the data processing service logic is a recognition deviation service logic.

[0028] It should be noted that the number of recognition deviations is the number of times when the recognized code defects are inconsistent with the actual code defects.

[0029] It can be understood that when the number of recognition deviations is greater than the preset deviation number threshold or the proportion of the number of recognition deviations in the historical recognition times in the data processing service logic does not meet the requirements, that is, greater than 0.6, then it is determined that the data processing service logic is a recognition deviation service logic.

[0030] Optionally, the method for determining the recognition deviation service logic in the data processing service logic is as follows: Based on the recognition deviation situation of the recognition model in the data processing service logic of different software codes, determine the number of recognition deviations of the data processing service logic; Based on the number of recognition deviations, determine the software codes with recognition deviations and use them as recognition deviation codes; Determine whether the data processing service logic is a recognition deviation service logic according to the number of software codes with recognition deviations.

[0031] It can be understood that when the number of software codes with recognition deviations is greater than the preset deviation code number threshold, it is determined that the data processing service logic is a recognition deviation service logic.

[0032] S2 Based on the recognition model, detect and process the code defects of the software code to obtain code defects. When it is determined that the recognition reliability of the code defects of the recognition model meets the requirements according to the overlapping data between the code defects and different recognition deviation service logics, proceed to the next step; Specifically, as Figure 3 shown, determining that the recognition processing reliability of the recognition model meets the requirements specifically includes: Determine the distribution data of code defects in different recognition deviation business logics based on the overlapping data between the code defects and different recognition deviation business logics; Based on the distribution data, determine the code defects in the recognition deviation business logic and use them as overlapping code defects; Determine whether the recognition processing reliability of the recognition model meets the requirements through the distribution data of the overlapping code defects among the code defects of the software code.

[0033] It can be understood that when the proportion of the number of the overlapping code defects in the code defects of the software code does not meet the requirements, that is, when it is greater than 0.2, a large number of code defects are distributed in the recognition deviation business logic, and it is determined that the recognition processing reliability of the recognition model does not meet the requirements.

[0034] It should be noted that when the recognition processing reliability of the recognition model does not meet the requirements, the software code corresponding to different recognition deviation business logics is constructed with test cases. And when it is determined that there is no abnormality in the software code corresponding to the recognition deviation business logic by using the test cases, then the code defects of the software code are repaired by using the recognition model, that is, the code defects of the software code except for the recognition deviation business logic are repaired.

[0035] It can be understood that determining that the recognition processing reliability of the recognition model meets the requirements specifically includes: S21 Determine the distribution data of code defects in different recognition deviation business logics based on the overlapping data between the code defects and different recognition deviation business logics. Based on the distribution data, determine the code defects in the recognition deviation business logic and use them as overlapping code defects, and determine the number of overlapping code defects in the software code corresponding to different recognition deviation business logics; Optionally, in the above steps, if the number of code defects is small, that is, less than the preset threshold, at this time, it can be directly determined that the recognition processing reliability of the recognition model meets the requirements.

[0036] In addition, in the above steps, if the number of code defects is not less than the preset threshold, it is also necessary to further determine whether the number of overlapping code defects meets the requirements. When the number of overlapping code defects is greater than the preset defect number threshold or the proportion of the composition number of the overlapping code defects in the code defects is greater than the preset overlapping defect proportion threshold, at this time, it can be directly determined that the recognition processing reliability of the recognition model does not meet the requirements.

[0037] It should be further noted that when the number of overlapping code defects meets the requirements, it is necessary to further determine the recognition deviation business logic where the number of overlapping code defects in the corresponding software code does not meet the requirements. It can be understood that when there is a recognition deviation business logic where the number of overlapping code defects in the corresponding software code is greater than the preset defect quantity threshold, it can be directly determined that the recognition processing reliability of the recognition model does not meet the requirements. In other cases, it proceeds to the next step.

[0038] S22 uses the software code corresponding to the recognition deviation business logic with overlapping code defects as the overlapping deviation software code, and determines the recognition deviation quantity ratio based on the proportion of the overlapping deviation software code in the quantity of the software code corresponding to the recognition deviation business logic. It can be understood that when the quantity of the overlapping deviation software code does not meet the requirements, that is, when the quantity of the software code corresponding to the recognition deviation business logic with overlapping code defects is relatively large, that is, greater than the preset threshold, at this time, it can be directly determined that the recognition processing reliability of the recognition model does not meet the requirements.

[0039] It can also be understood that when the quantity of the software code corresponding to the recognition deviation business logic with overlapping code defects is not large, at this time, it is necessary to determine the proportion of the overlapping deviation software code in the quantity of the software code corresponding to the recognition deviation business logic to determine the recognition deviation quantity ratio. If the recognition deviation quantity ratio is greater than the preset deviation quantity ratio threshold at this time, then it can also be determined that the recognition processing reliability of the recognition model does not meet the requirements at this time.

[0040] S23 determines whether the recognition processing reliability of the recognition model meets the requirements based on the distribution data of the overlapping code defects in the code defects of the software code, the quantity of the overlapping code defects in the software code corresponding to different recognition deviation business logics, and the recognition deviation quantity ratio.

[0041] It can be understood that in a possible embodiment, the defect ratio is determined based on the average value of the quantity ratio of the overlapping code defects in the code defects of the software code and the recognition deviation quantity ratio, and the recognition processing deviation value is determined based on the product of the defect ratio and the average value of the quantity of the overlapping code defects in the software code corresponding to different recognition deviation business logics.

[0042] When the recognition processing deviation value is greater than the preset recognition deviation threshold, where the preset recognition deviation threshold is determined based on the quantity of the software code corresponding to the recognition deviation business logic in the software code, and the more the quantity of the software code corresponding to the recognition deviation business logic in the software code, the smaller the preset recognition deviation threshold. At this time, it is determined that the recognition processing reliability of the recognition model does not meet the requirements.

[0043] S3 determines the verification processing strategy and the optimization target to be optimized for the software code corresponding to different recognition deviation business logics before the repair of code defects according to the recognition deviation situation of different recognition deviation business logics and the composition data of code defects in the corresponding software code; Further, the method for determining the verification processing strategy for the software code corresponding to the recognition deviation business logic before the repair of code defects is as follows: Based on the recognition deviation situation of the recognition deviation business logic, determine the proportion of the number of recognition deviations of the recognition deviation business logic in the historical recognition times in the data processing business logic, and use it as the deviation recognition proportion; Take the software code corresponding to the recognition deviation business logic as the target software code, and determine the number of code defects in the target software code based on the composition data of the code defects of the target software code; Based on the deviation recognition proportion and the number of code defects, determine the verification processing strategy for the software code corresponding to the recognition deviation business logic before the repair of code defects.

[0044] It can be understood that when the deviation recognition proportion is greater than the preset proportion threshold, in a possible embodiment, the preset proportion threshold is determined according to the number of recognition deviation business logics. The more the number of recognition deviation business logics, the greater the deviation recognition proportion. In a possible embodiment, it is set to 0.7. Then, regardless of the number of code defects, it is necessary to verify the target software code before the repair of code defects by constructing test cases.

[0045] In addition, it should be noted that when the deviation recognition proportion is not greater than the preset proportion threshold, only when the proportion of the number of code defects in the target software code in the number of software codes is greater than the preset defect number proportion threshold, in a possible embodiment, when it is above 0.05, it is necessary to verify the target software code before the repair of code defects by constructing test cases. When the proportion of the number of code defects in the target software code in the number of software codes is not greater than the preset defect number proportion threshold, only multiple recognition processing methods are required to verify the target software code before the repair of code defects.

[0046] It can be understood that the multiple recognition processing method is to obtain the recognition result by using the recognition processing of the preset recognition times fixed by the recognition model, where the recognition result includes the positions and quantities of code defects in different recognition processing times.

[0047] Further, the optimization target to be optimized is the target software code with inconsistent positions of code defects in different recognition processing times.

[0048] S4 determines the repair objectives in the code defects based on the verification results, and determines the optimization adjustment method of the verification processing strategy for the target to be optimized in the next code repair process according to the running data of the target to be optimized in different repair processing times and the change situation of the repair objectives in different repair processing times.

[0049] Furthermore, when the verification process before the repair of the target software code is implemented by using test cases, when there are problems, the code defects are directly repaired manually.

[0050] It should be noted that the repair objectives are the code defects except the software code corresponding to the recognition deviation business logic and the software code corresponding to the recognition deviation business logic that does not belong to the target to be optimized.

[0051] Specifically, as Figure 4 shown, the method for determining the verification processing strategy before the next code defect repair of the target to be optimized is: Based on the running data of different targets to be optimized in different repair processing times, determine the targets to be optimized with inconsistent running results in different repair processing times or with inconsistent running results with the target running result, and use them as the running result deviation targets; According to the change situation of the repair objectives in different repair processing times, determine the number of newly added repair objectives after the last repair processing in different repair processing times, and use it as the newly added target number; Based on the number of newly added targets and the number of running result deviation targets in different repair processing times, determine the verification processing strategy before the next code defect repair of the target to be optimized.

[0052] It should be noted that the newly added repair objectives are the repair objectives that did not belong to the repair objectives during the last repair processing but belong to the repair objectives in the current repair processing times; Specifically, the repair objectives in different repair processing times are the repair objectives with inconsistent running processing results and target processing results after the last repair processing. It can be understood that the target running result is the program running result expected to be output by the software code corresponding to the repair objective, and can be specifically determined by manual input or the automatic recognition result of the model according to the code logic flowchart.

[0053] Furthermore, based on the number of newly added targets and the number of running result deviation targets in different repair processing times, determine the verification processing strategy before the next code defect repair of the target to be optimized, specifically including: When the number of repair processes is not greater than the preset repair process threshold, the optimization adjustment of the verification processing strategy before the next repair of the code defect of the target to be optimized is not performed temporarily, and the verification processing is not required; When the number of repair processes is greater than the preset repair process threshold, when there are new repair targets in different repair processes, in order to improve the reliability of the repair process at this time, all targets to be optimized and the target software code that has not been verified by test cases before the repair of the code defect of the target software code are verified by test cases; When there are no new repair targets in different repair processes, obtain the number of new targets in different repair processes. When the number of repair processes with the number of new targets greater than the preset target number threshold is greater than the preset process threshold, all targets to be optimized and the target software code that has not been verified by test cases before the repair of the code defect of the target software code are verified by test cases; When the number of repair processes with the number of new targets greater than the preset target number threshold is not greater than the preset process threshold, if the number of deviation targets of the running result does not meet the requirements, that is, is greater than the preset number threshold, at this time, all targets to be optimized and the target software code that has not been verified by test cases before the repair of the code defect of the target software code are verified by test cases; If the number of deviation targets of the running result meets the requirements, at this time, the deviation targets of the running result are verified by test cases, and the other targets to be optimized still adopt the multiple recognition processing method to verify the target software code before the repair of the code defect. If the recognition results are still inconsistent, they are verified by test cases.

[0054] Optionally, the method for determining the verification processing strategy before the next repair of the code defect of the target to be optimized is: S41 According to the change situation of the repair targets in different repair processes, determine the number of new repair targets after the previous repair process for different repair processes, and use it as the number of new targets. According to the number of times that different repair targets belong to new repair targets, determine the frequently changed repair targets in the software code; It should be noted that in the above steps, it is necessary to determine that if the number of repair processes is not greater than the preset repair process threshold, the optimization adjustment of the verification processing strategy before the next repair of the code defect of the target to be optimized is not performed temporarily, and the verification processing is not required; In addition, if the number of repair processes is greater than the preset repair process number threshold, when there are newly added repair targets in different numbers of repair processes, in order to improve the reliability of the repair process at this time, all the targets to be optimized and the target software code that has not been verified by test cases before the code defects of the target software code are repaired are verified by test cases; In addition, it can be understood that if there are no newly added repair targets in different numbers of repair processes, the number of newly added targets in different numbers of repair processes is obtained. When the number of repair processes with the number of newly added targets greater than the preset target number threshold is greater than the preset process number threshold, all the targets to be optimized and the target software code that has not been verified by test cases before the code defects of the target software code are repaired are verified by test cases; If the number of repair processes with the number of newly added targets greater than the preset target number threshold is not greater than the preset process number threshold, it is also necessary to determine whether the number of frequently changed repair targets in the software code meets the requirements. Specifically, when there are more than 3 frequently changed repair targets, all the targets to be optimized and the target software code that has not been verified by test cases before the code defects of the target software code are repaired are directly verified by test cases, and in other cases, it goes to the next step.

[0055] It should be noted that the frequently changed repair target is a repair target whose number of times belonging to the newly added repair target is more than 2 times.

[0056] S42 uses the running data of different targets to be optimized in different numbers of repair processes to determine that the running results in different numbers of repair processes are inconsistent or there are targets to be optimized that are inconsistent with the target running result, and uses them as running result deviation targets. According to whether the running results of the running result deviation targets in the nearest preset number of repair times are all consistent with the target processing results, the running result deviation targets are divided into suspected defect targets and normal targets; It can be understood that the suspected defect target is a running result deviation target whose running result in the nearest preset number of repair times is not all consistent with the target processing result. Specifically, it is determined according to whether the running results of the nearest 5 times are all consistent with the target processing result.

[0057] In addition, it should be noted that in the above steps, if the number of suspected defect targets does not meet the requirements, that is, when the number of suspected defect targets is greater than the threshold of the number of suspected defect targets, it indicates that the number of suspected defect targets is relatively large at this time. Therefore, on this basis, all the targets to be optimized and the target software code that has not been verified by test cases before repairing the code defects of the target software code are verified by test cases.

[0058] It can also be understood that if the number of running result deviation targets does not meet the requirements, that is, when it is greater than the preset quantity threshold, at this time, all the targets to be optimized and the target software code that has not been verified by test cases before repairing the code defects of the target software code are verified by test cases, and in other cases, the next step is entered.

[0059] S43 Determine the verification processing strategy of the target to be optimized before the next code defect repair based on the number of frequently changed repair targets in the software code, the number of suspected defect targets and normal targets in the running result deviation targets.

[0060] In a possible embodiment, the optimization requirement value is determined according to the ratio of the sum of the number of frequently changed repair targets and the number of running result deviation targets to the number of normal targets in the running result deviation targets.

[0061] It can be understood that when the optimization requirement value is greater than the preset optimization requirement threshold, all the targets to be optimized and the target software code that has not been verified by test cases before repairing the code defects of the target software code are verified by test cases. In other cases, the running result deviation targets and the frequently changed repair targets are verified by test cases, and the other targets to be optimized still adopt the multiple recognition processing method to verify the target software code before repairing the code defects.

[0062] Each embodiment in this specification is described in a progressive manner. The same or similar parts among the embodiments can be referred to each other, and the key points of each embodiment are the differences from other embodiments. In particular, for the embodiments of the device, equipment, and non-volatile computer storage medium, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments.

[0063] The above describes specific embodiments of this specification. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0064] The above are only one or more embodiments of this specification and are not intended to limit this specification. For those skilled in the art, various changes and modifications can be made to one or more embodiments of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of this specification shall be included within the protection scope of this specification.

Claims

1. An automatic code defect detection and repair method based on artificial intelligence, characterized in that, Specifically, it includes: Based on the historical recognition data of the recognition model for code defects based on artificial intelligence, determine the recognition deviation situation of the recognition model in the data processing business logics of different software codes, and determine the recognition deviation business logic in the data processing business logic based on the recognition deviation situation; Perform detection and processing of code defects in software codes based on the recognition model to obtain code defects. When the recognition reliability of the code defects of the recognition model meets the requirements according to the coincidence data between the code defects and different recognition deviation business logics, proceed to the next step; According to the recognition deviation situations of different recognition deviation business logics and the composition data of the code defects in the corresponding software codes, determine the verification processing strategies and the targets to be optimized for the software codes corresponding to different recognition deviation business logics before the code defects are repaired; Determine the repair targets in the code defects based on the verification results, and determine the optimization adjustment method of the verification processing strategy for the targets to be optimized in the next code repair process based on the running data of the targets to be optimized in different repair processing times and the change situations of the repair targets in different repair processing times.

2. The automatic code defect detection and repair method based on artificial intelligence according to claim 1, characterized in that, The recognition deviation situation in the data processing business logic includes the recognition deviation times of the code defects in the data processing business logic.

3. The automatic code defect detection and repair method based on artificial intelligence according to claim 1, characterized in that The data processing business logic is divided according to the types of data processing functions called.

4. The automatic code defect detection and repair method based on artificial intelligence according to claim 1, characterized in that, The method for determining the recognition deviation business logic in the data processing business logic is: Based on the recognition deviation situation of the recognition model in the data processing business logics of different software codes, determine the recognition deviation times of the data processing business logic; Based on the recognition deviation times, determine whether the data processing business logic is a recognition deviation business logic.

5. The method for automatically detecting and repairing code defects based on artificial intelligence according to claim 4, wherein, The recognition deviation times are the number of times when the recognized code defects are inconsistent with the real code defects.

6. The method for automatically detecting and repairing code defects based on artificial intelligence according to claim 1, characterized in that, Determining that the recognition processing reliability of the recognition model meets the requirements specifically includes: Based on the coincidence data between the code defects and different recognition deviation business logics, determine the distribution data of the code defects in different recognition deviation business logics; Based on the distribution data, determine the code defects in the recognition deviation business logic and use them as the coincident code defects; Determine whether the recognition processing reliability of the recognition model meets the requirements through the distribution data of the coincident code defects in the code defects of the software code.

7. The automatic code defect detection and repair method based on artificial intelligence according to claim 6, characterized in that, When the proportion of the number of the coincident code defects in the code defects of the software code does not meet the requirements, determine that the recognition processing reliability of the recognition model does not meet the requirements.

8. The automatic code defect detection and repair method based on artificial intelligence according to claim 1, characterized in that The method for determining the verification processing strategy for the targets to be optimized before the next code defect repair is: Based on the running data of different targets to be optimized in different repair processing times, determine the targets to be optimized with inconsistent running results or inconsistent with the target running results in different repair processing times and use them as the target running result deviation targets; Determine the number of newly added repair targets for different repair processing times after the last repair processing according to the changes in the repair targets in different repair processing times, and use it as the number of newly added targets. Based on the number of newly added targets for different repair processing times and the number of operation result deviation targets, determine the verification processing strategy of the target to be optimized before the next repair of code defects.

9. The method for automatically detecting and repairing code defects based on artificial intelligence according to claim 8, characterized in that, The newly added repair target is a repair target that did not belong to the repair target during the last repair processing but belongs to the repair target in the current repair processing times.

10. The method for automatically detecting and repairing code defects based on artificial intelligence according to claim 8, characterized in that, Based on the number of newly added targets for different repair processing times and the number of operation result deviation targets, determine the verification processing strategy of the target to be optimized before the next repair of code defects, specifically including: When there are newly added repair targets in different repair processing times, verify all targets to be optimized and target software codes that have not been verified by test cases before the repair of code defects in the target software code through test cases.

Citation Information

Patent Citations

  • Advanced vulnerability mining and automatic testing method and testing system based on large language model

    CN118171288A

  • Code defect prediction method, readable storage medium and computer program product

    CN119396689A

  • Software efficient testing method and system based on artificial intelligence

    CN119396719A

  • Code automatic repairing method and device and electronic equipment

    CN119597293A

  • Transitive source code violation matching and attribution

    US20160162289A1