Code quality determination method and device, equipment, medium and program product
By combining the workload of the current task and the defect distribution of historical tasks, the expected code quality of the current task is determined, and the problem that zero-defect tasks may have defects in actual applications is solved, and the accuracy of code quality judgment and development efficiency are improved.
Patent Information
- Application Number
- CN202411611513.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, programs with zero defect tasks may have defects in actual applications, resulting in insufficient reliability of the code quality process, poor program availability and user experience.
By determining that the number of defects in the current task is zero and the workload, combining the task defect distribution in the history, the expected code quality of the current task is determined based on the defect distribution and the workload of the current task.
It improves the accuracy of code quality judgment, enhances the predictive ability of code quality, reduces the risks caused by code defects, optimizes resource allocation, and improves development efficiency.
Smart Images

Figure CN119473854A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the financial field or other fields, and in particular to a code quality determination method, device, equipment, medium and program product. Background Art
[0002] In the process of code development, in order to ensure the availability and stability of the programs (such as websites, scripts, applications, services, etc.) obtained by the code development task, the program code needs to be constantly checked. Among them, the process of checking the code after the program code is completed is the code quality process, which includes code review, internal testing, functional testing and other links. Through the code quality process, various defects in the program code can be easily checked. When no defects are found in the program code through the code quality process, the code development task corresponding to the program can be considered a zero-defect task.
[0003] Related technologies, programs for zero-defect tasks can usually be released to target customers for application, but new defects are usually still discovered during the actual application phase, resulting in insufficient reliability of the code quality process, insufficient availability of programs corresponding to code development tasks, and poor customer experience. Summary of the invention
[0004] The embodiments of the present application provide a code quality determination method, apparatus, device, medium and program product to solve the problem in the related art that the program corresponding to the zero-defect task may have defects, resulting in insufficient usability and poor user experience, so as to achieve the effect of improving the accuracy of code quality judgment.
[0005] In a first aspect, an embodiment of the present application provides a method for determining code quality, comprising the following steps:
[0006] Determine that the number of defects in the quality determination process for the current task is zero and determine the workload of the current task;
[0007] Determine the defect distribution of the tasks in the historical records, wherein the defect distribution includes the relationship between the workload and the number of defects of the tasks in the historical records, and the number of defects includes the first number of defects in the quality determination process and the second number of defects in the application stage;
[0008] Determine the expected code quality for the current task based on the defect distribution and the workload of the current task.
[0009] In one possible implementation, determining the defect distribution of tasks in historical records includes: determining the first defect number of tasks in the historical records during the quality determination process and the second defect number in the application stage; determining tasks where the first defect number and the second defect number are both zero as first-category zero-defect tasks; determining tasks where the first defect number is zero and the second defect number is non-zero as second-category zero-defect tasks; based on the workload of each type of zero-defect task, determining a probability density function corresponding to a corresponding type of zero-defect task, the probability density function being used to represent the probability distribution of the workload of a corresponding type of zero-defect task, the probability density function including a first probability density function corresponding to the first type of zero-defect task and a second probability density function corresponding to the second type of zero-defect task; determining the defect distribution based on the first probability density function and the second probability density function.
[0010] In one possible implementation, the defect distribution includes a boundary threshold of the workload corresponding to the first type of zero-defect tasks and the second type of zero-defect tasks; based on the first probability density function and the second probability density function, the defect distribution is determined, including: based on the first probability density function and the second probability density function, the boundary threshold is determined; based on the defect distribution and the workload of the current task, the expected code quality of the current task is determined, including: if the workload of the current task is less than the boundary threshold, the expected code quality of the current task is determined to contain no defects; or, if the workload of the current task is greater than the boundary threshold, the expected code quality of the current task is determined to contain defects.
[0011] In one possible implementation, based on the workload of each type of zero-defect task, a probability density function corresponding to the corresponding type of zero-defect task is determined, including: taking the workload of each first-type zero-defect task as a first-type sample, and taking the workload of each second-type zero-defect task as a second-type sample; based on the number of occurrences of each workload in each type of sample, determining the probability of occurrence of the workload in the corresponding type of sample; based on the probability of occurrence of each workload in each type of sample, determining the corresponding probability density function.
[0012] In one possible implementation, based on the number of occurrences of each workload in each type of sample, the probability of occurrence of the workload in the corresponding type of sample is determined, including: for each type of sample, based on the workload of each sample in the same type of sample, the same type of sample is divided into at least two sample intervals with the goal of maximizing the number of divided sample intervals and the number of samples in each sample interval being greater than a set number threshold; the middle value of the workload in each sample interval is determined as the representative workload of the sample interval; the ratio of the number of samples in the sample interval to the total number of samples of the same type of sample is used as the probability of occurrence of the representative workload in the corresponding sample type.
[0013] In one possible implementation, based on the probability of occurrence of each workload in each type of sample, a corresponding probability density function is determined, including: for each type of sample, performing function fitting on the probability of occurrence of each workload in the sample to obtain a fitting function for the corresponding sample; determining an integral value of the fitting function; based on the integral value, correcting the fitting function, and using the corrected fitting function as the probability density function of the sample.
[0014] In a possible implementation, determining a boundary threshold based on a first probability density function and a second probability density function includes: determining at least one intersection point of the first probability density function and the second probability density function; and determining an intersection point from the at least one intersection point as the boundary threshold.
[0015] In a second aspect, an embodiment of the present application provides a code quality determination device, including:
[0016] A determination module is used to determine that the number of defects of the current task in the quality determination process is zero and to determine the workload of the current task;
[0017] An analysis module, used to determine the defect distribution of the tasks in the historical records, wherein the defect distribution includes the relationship between the workload and the number of defects of the tasks in the historical records, and the number of defects includes the first number of defects in the quality determination process and the second number of defects in the application stage;
[0018] The processing module is used to determine the expected code quality of the current task based on the defect distribution and the workload of the current task.
[0019] In one possible implementation, the analysis module is specifically used to determine the first defect number of tasks in the historical records during the quality determination process and the second defect number in the application stage; determine tasks where the first defect number and the second defect number are both zero as first-category zero-defect tasks; determine tasks where the first defect number is zero and the second defect number is non-zero as second-category zero-defect tasks; based on the workload of each type of zero-defect task, determine the probability density function corresponding to the corresponding type of zero-defect task, the probability density function is used to represent the probability distribution of the workload of the corresponding type of zero-defect task, the probability density function includes a first probability density function corresponding to the first type of zero-defect task and a second probability density function corresponding to the second type of zero-defect task; based on the first probability density function and the second probability density function, determine the defect distribution.
[0020] In one possible implementation, the analysis module is specifically used to, if the defect distribution includes a boundary threshold of the workload corresponding to the first type of zero-defect task and the second type of zero-defect task; based on the first probability density function and the second probability density function, determine the boundary threshold; the processing module is specifically used to, if the workload of the current task is less than the boundary threshold, determine the expected code quality of the current task as containing no defects; or, if the workload of the current task is greater than the boundary threshold, determine the expected code quality of the current task as containing defects.
[0021] In one possible implementation, the analysis module is specifically used to take the workload of each first-category zero-defect task as a first-category sample, and take the workload of each second-category zero-defect task as a second-category sample; based on the number of occurrences of each workload in each category of samples, determine the probability of occurrence of the workload in the corresponding category of samples; based on the probability of occurrence of each workload in each category of samples, determine the corresponding probability density function.
[0022] In one possible implementation, the analysis module is specifically used to, for each type of sample, divide the same type of samples into at least two sample intervals based on the workload of each sample in the same type of samples, with the goal of maximizing the number of divided sample intervals and the number of samples in each sample interval being greater than a set number threshold; determine the middle value of the workload in each sample interval as the representative workload of the sample interval; and use the ratio of the number of samples in the sample interval to the total number of samples of the same type of samples as the probability of occurrence of the representative workload in the corresponding sample type.
[0023] In one possible implementation, the analysis module is specifically used to, for each type of sample, fit a function to the probability of occurrence of each workload in the sample to obtain a fitting function for the corresponding sample; determine the integral value of the fitting function; based on the integral value, correct the fitting function, and use the corrected fitting function as the probability density function of the sample.
[0024] In a possible implementation, the analysis module is specifically configured to determine at least one intersection point between the first probability density function and the second probability density function; and determine one intersection point from the at least one intersection point as a boundary threshold.
[0025] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;
[0026] Memory stores computer-executable instructions;
[0027] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.
[0028] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.
[0029] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.
[0030] The code quality determination method, apparatus, equipment, medium and program product provided in the embodiment of the present application, by determining that the number of defects of the current task in the quality determination process is zero, and determining the workload of the current task, and then determining the defect distribution of the tasks in the historical records, and then based on the defect distribution and the workload of the current task, determining the expected code quality of the current task. Thus, by combining the workload of the current task and the defect distribution of historical tasks, a more accurate prediction of the code quality is achieved. And it is possible to judge the quality of the current task when the defects of the current task are not found in the code quality determination process, which not only takes into account the direct quality performance of the task, but also incorporates the comparison of the workload and historical data, thereby improving the accuracy and reliability of the code quality determination. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0032] Figure 1 An application scenario diagram of the code quality determination method provided by the embodiment of the present disclosure;
[0033] Figure 2 A flowchart of a method for determining code quality provided by an embodiment of the present disclosure;
[0034] Figure 3a A flowchart of a code quality determination method provided by yet another embodiment of the present disclosure;
[0035] Figure 3b for Figure 3a A flow chart of a method for determining a probability density function provided in the illustrated embodiment;
[0036] Figure 4 A schematic diagram of the structure of a code quality determination device provided by yet another embodiment of the present disclosure;
[0037] Figure 5 A schematic structural diagram of an electronic device provided in yet another embodiment of the present disclosure.
[0038] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0039] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0040] First, the terms involved in this application are explained:
[0041] Code quality determination process: refers to the process of checking the program code after it is completed and before the program is released, which includes code review, internal testing, functional testing and other links.
[0042] In the process of code development, in order to ensure the availability and stability of the programs (such as websites, scripts, applications, services, etc.) obtained by the code development task, the program code needs to be constantly checked. Among them, the code quality determination process is crucial to the availability of the released program code.
[0043] Although the process of determining code quality includes code review, internal testing, functional testing and other links, due to insufficient test coverage (such as missing boundary conditions, exception handling or specific user scenarios), differences between the test environment and the actual environment (such as some defects that are only triggered in the production environment may not be discovered in advance), human factors (such as developers or testers may miss some defects due to lack of experience, negligence or incomplete understanding of requirements), etc., even if no defects are found in the code quality process, various defects may appear when the program is released and applied to the actual environment, causing various problems, such as program crashes, data loss, performance degradation, etc., which seriously affect the availability of the program and damage the customer's experience.
[0044] The code quality determination method provided in the present application analyzes the tasks with zero defects in the quality determination process by combining the defect distribution of historical tasks, so as to re-judge the code quality of the current task. Thus, it is possible to find out the tasks that may have code quality problems by combining the defect distribution in historical tasks, so as to review such tasks and find out possible defects, thereby improving the availability of the program and ensuring the user experience.
[0045] Specific application scenarios of the present application The application scenarios of the embodiments of the present disclosure are explained below:
[0046] Figure 1 This is an application scenario diagram of the code quality determination method provided by the embodiment of the present disclosure. Figure 1 As shown, during the code quality determination process, in the server 120, the user inputs the program code 100 that has passed the code quality determination process into the review program 110 corresponding to the code quality determination method. The review program 110 combines the historical task-related data 130 stored in the server 120 to determine the quality assessment result 140 of the program code 100, thereby completing the code quality determination process.
[0047] It should be noted that Figure 1 In the scenario shown, only one of the program code, review program, server, and historical task-related data is used as an example for illustration, but the present disclosure is not limited to this. In other words, the number of program code, review program, server, and historical task-related data can be arbitrary.
[0048] The code quality determination method, device, equipment and medium provided in this application are intended to solve the above technical problems in the prior art.
[0049] It should be noted that the method and device for determining code quality of the present application can be used in the financial field, and can also be used in any field other than the financial field. The application field of the method and device for determining code quality of the present application is not limited.
[0050] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0051] Figure 2 A flowchart of a method for determining code quality provided by an embodiment of the present disclosure. Figure 2 As shown, the following steps are included:
[0052] Step S201: determine that the number of defects of the current task in the quality determination process is zero, and determine the workload of the current task.
[0053] Specifically, the execution subject of the embodiment of the present disclosure is a computer, a processor or a server (hereinafter collectively described as a server).
[0054] This embodiment is used to describe the implementation process of the code quality determination method.
[0055] During the code development process, after the developer completes the writing of the program code corresponding to the current task, the code quality determination process will be carried out, including developer review, internal automated testing, manual testing of various functions, etc. Through the above steps, the number of defects in the program code can be determined. If the above steps are combined to confirm that no defects are found in the quality determination process of the current task, it can be determined that the number of defects in the quality determination process of the current task is zero.
[0056] At this time, the workload of the current task is also determined. The determination of the workload of the task can be determined by task complexity assessment, working time assessment, etc. Task complexity, such as analyzing task requirements, evaluating the complexity of code implementation, including algorithm difficulty, data processing volume, etc., such as presetting corresponding workload ratings or coefficients for different algorithm difficulties and different data processing levels. Working time estimation can be determined by the actual working time spent on completing the task, such as 20 man-days (that is, it takes one person 20 days to complete) or 600 hours (that is, detailed to the specific time). In actual calculations, the workload can be determined by combining task complexity and working time, or only working hours can be used as the workload of the current task.
[0057] The current task may be a program development task or a program version update task, and the corresponding code may be an update package code of a program or a program code of a large program, such as a website program code.
[0058] Step S202: Determine the defect distribution of tasks in the historical records.
[0059] The defect distribution includes the relationship between the workload of tasks in the historical records and the number of defects, and the number of defects includes the first number of defects in the quality determination process and the second number of defects in the application stage.
[0060] Specifically, the quality assessment of the current task needs to be analyzed in combination with the defect distribution of other tasks in the historical records.
[0061] First, you need to collect corresponding data from historical records for tasks that have completed the quality determination process and have been released, including the workload of these historical tasks, the number of first defects in the quality determination process (that is, the number of defects found in the quality determination process, which can also include the number of defects found in the development phase in actual applications), and the number of second defects in the application phase (that is, the number of defects found after the program is released and applied to the actual environment).
[0062] Combined with the workload and defect number of historical tasks, the relationship between the workload and defect number of tasks can be analyzed. Then, the relationship between the second defect number and workload corresponding to the historical tasks with zero first defect number can be found. The specific determination method can be statistical analysis methods, such as regression analysis, cluster analysis, etc., or a corresponding model can be established to predict the possible second defect number under different workloads.
[0063] Step S203: Determine the expected code quality of the current task based on the defect distribution and the workload of the current task.
[0064] Specifically, based on the relationship between the number of second defects and the workload obtained by analysis, combined with the workload of the current task, the number of second defects that may exist in the current task can be determined, thereby achieving an assessment of the expected code quality of the current task. If the number of second defects predicted for the current task is non-zero, it is necessary to optimize the code quality, such as increasing test coverage, optimizing code structure, etc., to discover possible defects and improve code quality. Ensure the availability and reliability of the program.
[0065] The code quality determination method provided by the embodiment of the present disclosure determines that the number of defects of the current task in the quality determination process is zero, determines the workload of the current task, and then determines the defect distribution of the tasks in the historical records, and then determines the expected code quality of the current task based on the defect distribution and the workload of the current task. Thus, by combining the workload of the current task and the defect distribution of historical tasks, a more accurate prediction of the code quality is achieved. And it is possible to judge the quality of the current task when the defects of the current task are not found in the code quality determination process, which not only takes into account the direct quality performance of the task, but also incorporates the comparison of the workload and historical data, thereby improving the accuracy and reliability of the code quality determination.
[0066] Figure 3a Schematic diagram of the code quality determination method provided for this application Figure 2 ,like Figure 3a As shown, in this embodiment Figure 2 Based on the embodiment, a method for determining code quality is described in detail, and the method includes:
[0067] Step S301: determine that the number of defects of the current task in the quality determination process is zero, and determine the workload of the current task.
[0068] Specifically, this embodiment is used to further describe a specific process of determining defect distribution and a process of determining code quality based on the defect distribution.
[0069] This step and Figure 2 The corresponding steps in the embodiments are the same and will not be repeated here.
[0070] Step S302: Determine the number of first defects in the quality determination process and the number of second defects in the application phase of the task in the historical record.
[0071] Specifically, when analyzing the defect distribution of historical tasks, it is first necessary to determine the number of defects of each task in the historical records, including the first defect number in the quality determination process and the second defect number in the application stage.
[0072] The obtained first defect number and second defect number can be stored in a database. When the historical tasks and their defect numbers are updated, the corresponding first defect number and second defect number are updated based on the updated historical tasks to facilitate calling when determining the defect distribution.
[0073] Step S303: Determine the task whose first defect number and second defect number are both zero as a first-type zero-defect task.
[0074] Specifically, according to the determined first defect number and second defect number, the first type of zero-defect tasks, ie, program tasks without code defects in the testing phase and the application phase, can be quickly screened out.
[0075] Step S304: Determine the task whose first defect number is zero and whose second defect number is non-zero as a second-category zero-defect task.
[0076] Specifically, according to the determined first defect number and second defect number, the second type of zero-defect tasks can also be quickly screened out, that is, program tasks in which no code defects are found in the testing phase (quality determination process) but code defects are found in the application phase.
[0077] Step S305: Based on the workload of each type of zero-defect task, determine the probability density function corresponding to the corresponding type of zero-defect task.
[0078] Among them, the probability density function is used to represent the probability distribution of the workload of the corresponding type of zero-defect tasks, and the probability density function includes a first probability density function corresponding to the first type of zero-defect tasks and a second probability density function corresponding to the second type of zero-defect tasks.
[0079] Specifically, different tasks have corresponding workloads, and the workload of each zero-defect task will show a certain distribution. The function used to represent the distribution characteristics of the probability of occurrence of each workload in the same type of zero-defect tasks is the probability density function corresponding to the zero-defect task.
[0080] The probability density function can be used to represent the task distribution of each type of zero-defect task. By combining the task distribution and defect number of different types of zero-defect tasks, the defect distribution of zero-defect tasks in historical tasks can be obtained.
[0081] Therefore, the corresponding probability density function can be determined by determining the workload of different types of zero-defect tasks and the distribution of different workloads.
[0082] In one embodiment, if Figure 3b As shown, it is a flow chart of the method for determining the probability density function. The probability density function can be determined in the following way:
[0083] Step S3051: The workload of each first-category zero-defect task is taken as a first-category sample, and the workload of each second-category zero-defect task is taken as a second-category sample.
[0084] Specifically, the workloads of different types of zero-defect tasks are analyzed as samples of corresponding types to determine the probability density function.
[0085] Step S3052: Based on the number of occurrences of each workload in each type of sample, determine the occurrence probability of the workload in the corresponding type of sample.
[0086] Specifically, by comparing the number of times each workload occurs with the total number of samples, the occurrence probability of each workload can be obtained.
[0087] In some embodiments, since directly calculating the occurrence probability of each workload in the same type of samples may result in a situation where the occurrence probability of many workloads is extremely low, the occurrence probabilities of different workloads may also be determined in the following manner:
[0088] Step A1: For each type of sample, based on the workload of each sample in the same type of sample, the same type of sample is divided into at least two sample intervals with the goal of maximizing the number of divided sample intervals and the number of samples in each sample interval being greater than a set number threshold.
[0089] Specifically, each type of sample is divided into multiple sample intervals, and then the workload in each interval is replaced by a representative workload, and the probability of occurrence of each workload is replaced by the probability of occurrence of each representative workload. This can increase the numerical value of the probability of occurrence of each workload, and better reflect the distribution of workloads in the same type of samples, and reduce data noise that may be caused by a large number of single workloads.
[0090] The number of samples in the sample interval can be the same or different, but all need to be greater than the set number threshold. The set number threshold can be determined based on the total number of samples. For example, if the total number of samples is 1,000, the set number threshold can be 10, thereby increasing the sample interval as much as possible while reducing data noise to better reflect the distribution of workload.
[0091] Step A2: Determine the middle value of the workload in each sample interval as the representative workload of the sample interval.
[0092] Specifically, there may be multiple tasks with workloads in each sample interval, and these workloads may be the same or different. In this case, only the middle value (or the average of the middle values) of these samples is needed as the representative workload of the sample interval.
[0093] For example, if the sample interval contains three workloads of 8, 9, and 10 (the unit is man-days), 9 can be used as its representative workload; if the sample interval contains four workloads of 200, 210, 220, and 230 (the unit is working hours), 215 (that is, the average of 210 and 220) can be used as its representative workload.
[0094] Step A3: The ratio of the number of samples in the sample interval to the total number of samples of the same type is used as the probability of occurrence of the representative workload in the corresponding sample type.
[0095] Specifically, the number of samples in the sample interval is used as the number of occurrences of the representative workload, and this value is compared with the total number of samples of the same type to obtain the probability of occurrence of the representative workload.
[0096] By repeating steps A2 to A3, the occurrence probabilities of all representative workloads in the same type of sample can be obtained, and the occurrence probabilities of the workloads in each type of sample can be used as the occurrence probabilities of the workloads in each type of sample.
[0097] Step S3053: Determine the corresponding probability density function based on the occurrence probability of each workload in each type of sample.
[0098] Specifically, according to the frequency of occurrence of each workload, a corresponding function can be fitted to reflect the probability distribution of different workloads. The obtained function can be modified (such as normalization) to obtain a probability density function.
[0099] Furthermore, combined with the occurrence probability of the workload determined in the signing step, the probability density function can be determined by the following steps:
[0100] Step B1: For each type of sample, perform function fitting on the occurrence probability of each workload in the sample to obtain the fitting function of the corresponding sample.
[0101] Specifically, according to the occurrence probability values corresponding to different workloads, the corresponding function, i.e., the fitting function, can be obtained by function fitting. The probability distribution law of different workloads can be reflected by the fitting function. The specific fitting method can be implemented by function fitting related tools, such as python tools, matlab, excel and other tools, or by configuring the corresponding function fitting algorithm, such as linear regression algorithm, support vector machine algorithm, etc.
[0102] Step B2: determine the integral value of the fitting function.
[0103] Specifically, since the workload and its occurrence probability used for function fitting are not all the workloads and their corresponding occurrence probabilities in the sample, but the representative workload selected from the sample and the occurrence probability obtained based on the corresponding sample interval data volume, the integral of the workload and its occurrence probability used for you and is likely not to be one. In this case, the fitting function needs to be corrected. Before making the correction, you first need to determine the integral value of the occurrence probability of the fitting function.
[0104] Step B3: based on the integral value, the fitting function is corrected, and the corrected fitting function is used as the probability density function of the sample.
[0105] Specifically, by comparing the integral value with the value 1, the correction coefficient corresponding to the fitting function can be obtained. By correcting the fitting function with the correction coefficient, the probability density function corresponding to each type of sample can be obtained.
[0106] For example, if the integral value of the fitting function is 0.9, 10 / 9 can be used as a correction coefficient to multiply the fitting function to obtain the corresponding probability density function.
[0107] Step S306: Determine defect distribution based on the first probability density function and the second probability density function.
[0108] Specifically, by combining the probability density functions of the two types of zero-defect tasks, the corresponding defect distribution can be determined, so as to determine the expected code quality of the current task based on the defect distribution and the current task workload.
[0109] In some embodiments, the defect distribution includes a boundary threshold of the workload corresponding to the first type of zero-defect task and the second type of zero-defect task. Therefore, the defect distribution process can be implemented by determining the boundary threshold based on the first probability density function and the second probability density function. At this time, tasks with a workload less than the boundary threshold can be considered to be more likely to meet the first type of zero-defect task, and tasks with a workload greater than the boundary threshold can be considered to be more likely to meet the second type of zero-defect task.
[0110] In some embodiments, the boundary threshold can be determined based on the intersection of different probability density functions, that is, at least one intersection of the first probability density function and the second probability density function is determined, and then an intersection is determined from the at least one intersection as the boundary threshold.
[0111] Specifically, the first probability density function and the second probability density function are both functions that reflect the workload and the corresponding probability of occurrence. If the graphs of these two functions are plotted with the workload and the probability of occurrence as the coordinate axes respectively, there will be one or more intersection points between the two graphs. These intersection points represent that the probability of occurrence of a certain workload in the first type of zero-defect task is the same as the probability of occurrence in the second type of zero-defect task. Since most of the workloads in the first type of zero-defect tasks are less than those in the second type of zero-defect tasks, it can be considered that the situation of simply setting the workload corresponding to a value less than the intersection point corresponds to the situation of the first type of zero-defect task, and vice versa.
[0112] In some embodiments, there may be a situation where the error of the determined probability density function is large, which will lead to a large error in the determined boundary threshold. The large error of the determined probability density function is due to large errors in the division of the sample interval and the calculation of the probability of occurrence. This may be caused by an unreasonable set quantity threshold when dividing the sample interval, for example, the set quantity threshold is too small. Therefore, the set quantity threshold can be optimized through the following steps:
[0113] Step C1, setting the probability error value and the deviation probability value.
[0114] The probability error value is used to indicate the maximum value of the acceptable probability error, and the deviation probability value is used to indicate the probability that the acceptable probability error exceeds the probability error value.
[0115] Specifically, it is first necessary to set the deviation-related parameters between the probability density function obtained by fitting and the actual workload distribution, that is, the probability error value and the deviation probability value. For example, the probability error value is 20%, and the deviation probability value is 20%.
[0116] Step C2: In each category of samples, the ratio of the number of samples contained in each sample interval to the total number of samples is used as the sample probability of the corresponding category of samples.
[0117] Specifically, based on the sample intervals obtained in step A1, the ratio of the number of samples in each interval to the total number of samples of the category can be determined, and the ratio is used as a sample probability of the corresponding category of samples.
[0118] Step C3: taking the maximum value of the sample probability variance of different types of samples as the variance estimate.
[0119] Specifically, based on the probability of each sample in each category of samples, the variance of the sample probability corresponding to each category of samples can be calculated, and the maximum value thereof is used as the variance estimation value.
[0120] Step C4: Calculate the product of the square of the probability error value and the deviation probability value, and determine the ratio of the product to the variance estimate.
[0121] Specifically, the product of the square of the probability error value and the deviation probability value, and then the ratio of the variance estimate value, can determine the quantity threshold that complies with the law of large numbers based on the value.
[0122] For example, if the variance estimate is 0.04, the probability error is 25%, and the probability of bias is 20%, the ratio could be 7.8.
[0123] Step C5: taking the smallest integer value greater than the ratio as the set quantity threshold.
[0124] Specifically, by re-determining the probability density function through the quantity threshold, the accuracy of the probability density function can be effectively guaranteed. For example, the minimum integer value 8 that is greater than the ratio (7.8) in the example of step C4 is determined as the quantity threshold.
[0125] Step S307: If the workload of the current task is less than the boundary threshold, determine that the expected code quality of the current task does not contain defects.
[0126] Specifically, based on the boundary threshold obtained in the previous steps, the expected code quality of the current task can be evaluated by comparing the workload of the current task. For example, if the workload of the current task is less than the boundary threshold, it can be considered that it is more likely to belong to the first type of zero-defect task, and the expected code quality is good and is unlikely to contain defects (that is, the expected code quality is no defects). At this time, there is no need to reinforce and review the current task.
[0127] Step S308: If the workload of the current task is greater than the boundary threshold, determine that the expected code quality of the current task contains defects.
[0128] Specifically, in another case, if the workload of the current task is greater than the boundary threshold, it can be considered that the current task is more likely to belong to the second type of zero-defect task, the expected code quality is poor, and there is a high probability that defects still exist (that is, the expected code quality is to contain defects). At this time, the current task needs to be reinforced and reviewed to avoid new defects in the application stage.
[0129] In some embodiments, based on the probability density function obtained in the above steps, in addition to the boundary threshold, the code quality can be determined by the integral value related to the probability density function:
[0130] Step D1: taking the minimum workload value corresponding to the first probability density function as the first minimum value, and taking the minimum workload value corresponding to the second probability density function as the second minimum value.
[0131] Specifically, in some development scenarios, the workload of the first type of zero-defect tasks is not significantly less than that of the second type of zero-defect tasks. At this time, the integral between the probability density function and the current task can be used to determine which situation the current task is more inclined to.
[0132] Step D2: taking the integral of the first probability density function from the first minimum value to the workload of the current task as the first integral value, and taking the integral of the second probability density function from the second minimum value to the workload of the current task as the second integral value.
[0133] Specifically, the integral from the first minimum value to the workload of the current task in the first probability density function can reflect the proportion of the workload of the first type of zero-defect tasks below the workload of the current task. Similarly, the integral from the second minimum value to the workload of the current task in the second probability density function can reflect the proportion of the workload of the second type of zero-defect tasks below the workload of the current task. By comparing the two, it can be determined which one has a higher proportion. According to the different proportions, the position of the current task workload in the workload distribution of different types of zero-defect tasks can be determined, and then it can be determined which type of zero-defect task the current task is more likely to belong to.
[0134] Step D3: Determine the code quality of the current task based on the first integral value and the second integral value.
[0135] Specifically, if the ratio of the first integral value to the second integral value is greater than the set threshold (for example, 2), and the first integral value is not greater than the integral threshold (for example, 90%), it can be considered that the current task is more likely to belong to the first type of zero-defect task, and at this time it can be determined that the code quality of the current task is good. Similarly, if the ratio of the first integral value to the second integral value is less than the set threshold, or the first integral value is greater than the integral threshold, it can be considered that the current task is more likely to belong to the second type of zero-defect task, that is, the code quality is insufficient and needs to be reinforced and reviewed.
[0136] The code quality determination method provided by the embodiment of the present disclosure determines that the number of defects of the current task in the quality determination process is zero and records its workload, then extracts the first number of defects in the quality determination process of each task and the second number of defects in the application stage from the historical records, and determines the first type of zero-defect tasks and the second type of zero-defect tasks, and then determines its probability density function based on the workload of each type of zero-defect task, and determines the representative workload of each interval and its probability of occurrence by dividing the workload into multiple sample intervals, and performs function fitting and normalization processing. Based on the intersection of the first probability density function and the second probability density function, the boundary threshold of the workload is determined. Then, based on the comparison between the workload of the current task and the boundary threshold, the expected code quality of the current task is determined, so that when the expected code quality is to contain defects, reinforcement review can be carried out in time. This process can accurately evaluate the code quality of the current task, reduce the risks caused by code defects, optimize resource allocation, and improve overall development efficiency.
[0137] Figure 4 A schematic diagram of the structure of the code quality determination device provided in this application, such as Figure 4 As shown, the code quality determination device 400 provided in this embodiment includes:
[0138] A determination module 410 is used to determine that the number of defects of the current task in the quality determination process is zero, and to determine the workload of the current task;
[0139] An analysis module 420 is used to determine the defect distribution of the tasks in the historical records, wherein the defect distribution includes the relationship between the workload and the number of defects of the tasks in the historical records, and the number of defects includes the first number of defects in the quality determination process and the second number of defects in the application stage;
[0140] The processing module 430 is used to determine the expected code quality of the current task based on the defect distribution and the workload of the current task.
[0141] In one possible implementation, the analysis module 420 is specifically used to determine the first defect number of tasks in the historical records during the quality determination process and the second defect number in the application stage; determine tasks where the first defect number and the second defect number are both zero as first-category zero-defect tasks; determine tasks where the first defect number is zero and the second defect number is non-zero as second-category zero-defect tasks; based on the workload of each type of zero-defect task, determine the probability density function corresponding to the corresponding type of zero-defect task, the probability density function is used to represent the probability distribution of the workload of the corresponding type of zero-defect task, the probability density function includes a first probability density function corresponding to the first type of zero-defect task and a second probability density function corresponding to the second type of zero-defect task; based on the first probability density function and the second probability density function, determine the defect distribution.
[0142] In one possible implementation, the analysis module 420 is specifically used to, if the defect distribution includes a boundary threshold of the workload corresponding to the first type of zero-defect tasks and the second type of zero-defect tasks; based on the first probability density function and the second probability density function, determine the boundary threshold; the processing module 430 is specifically used to, if the workload of the current task is less than the boundary threshold, determine that the expected code quality of the current task is not defect-free; or, if the workload of the current task is greater than the boundary threshold, determine that the expected code quality of the current task is defect-containing.
[0143] In one possible implementation, the analysis module 420 is specifically used to take the workload of each first-category zero-defect task as a first-category sample, and take the workload of each second-category zero-defect task as a second-category sample; based on the number of occurrences of each workload in each category of samples, determine the probability of occurrence of the workload in the corresponding category of samples; based on the probability of occurrence of each workload in each category of samples, determine the corresponding probability density function.
[0144] In a possible implementation, the analysis module 420 is specifically used to, for each type of sample, divide the same type of samples into at least two sample intervals based on the workload of each sample in the same type of samples, with the goal of maximizing the number of divided sample intervals and the number of samples in each sample interval being greater than a set number threshold; determine the middle value of the workload in each sample interval as the representative workload of the sample interval; and use the ratio of the number of samples in the sample interval to the total number of samples of the same type of samples as the probability of occurrence of the representative workload in the corresponding sample type.
[0145] In one possible implementation, the analysis module 420 is specifically used to, for each type of sample, fit a function to the probability of occurrence of each workload in the sample to obtain a fitting function for the corresponding sample; determine the integral value of the fitting function; based on the integral value, correct the fitting function, and use the corrected fitting function as the probability density function of the sample.
[0146] In a possible implementation, the analysis module 420 is specifically configured to determine at least one intersection point between the first probability density function and the second probability density function; and determine an intersection point from the at least one intersection point as a boundary threshold.
[0147] The code quality determination device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.
[0148] Figure 5 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 5As shown, the electronic device 50 provided in this embodiment includes: at least one processor 501 and a memory 502. Optionally, the device 50 also includes a communication component 503. The processor 501, the memory 502 and the communication component 503 are connected via a bus 504.
[0149] In a specific implementation process, at least one processor 501 executes the computer-executable instructions stored in the memory 502, so that at least one processor 501 executes the above method.
[0150] The specific implementation process of the processor 501 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0151] In the above embodiments, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the invention can be directly implemented as a hardware processor, or can be implemented by a combination of hardware and software modules in the processor.
[0152] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage.
[0153] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0154] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0155] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0156] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0157] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0158] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0159] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0160] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0161] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0162] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0163] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for determining code quality, characterized in that: include: Determine that the number of defects in the quality determination process for the current task is zero and determine the workload of the current task; Determine the defect distribution of the tasks in the historical records, wherein the defect distribution includes the relationship between the workload and the number of defects of the tasks in the historical records, and the number of defects includes the first number of defects in the quality determination process and the second number of defects in the application stage; Based on the defect distribution and the workload of the current task, an expected code quality of the current task is determined.
2. The method according to claim 1, characterized in that: The determining of defect distribution of tasks in the historical records includes: Determine the number of first defects in the quality determination process and the number of second defects in the application phase for the tasks in the history record; Determine a task where both the first defect number and the second defect number are zero as a first-category zero-defect task; Determine the task in which the first defect number is zero and the second defect number is non-zero as a second-category zero-defect task; Based on the workload of each type of zero-defect task, determine a probability density function corresponding to the corresponding type of zero-defect task, wherein the probability density function is used to represent the probability distribution of the workload of the corresponding type of zero-defect task, and the probability density function includes a first probability density function corresponding to the first type of zero-defect task and a second probability density function corresponding to the second type of zero-defect task; The defect distribution is determined based on the first probability density function and the second probability density function.
3. The method according to claim 2, characterized in that The defect distribution includes boundary thresholds of the workload corresponding to the first type of zero-defect tasks and the second type of zero-defect tasks; The determining the defect distribution based on the first probability density function and the second probability density function includes: Determining the boundary threshold based on the first probability density function and the second probability density function; The determining the expected code quality of the current task based on the defect distribution and the workload of the current task includes: If the workload of the current task is less than the boundary threshold, determining that the expected code quality of the current task is free of defects; or, If the workload of the current task is greater than the boundary threshold, it is determined that the expected code quality of the current task contains defects.
4. The method according to claim 2, characterized in that: The determining of the probability density function corresponding to the corresponding type of zero-defect task based on the workload of each type of zero-defect task includes: The workload of each first-category zero-defect task is taken as the first-category sample, and the workload of each second-category zero-defect task is taken as the second-category sample; Based on the number of occurrences of each workload in each type of sample, determine the probability of occurrence of the workload in the corresponding type of sample; Based on the occurrence probability of each workload in each type of sample, the corresponding probability density function is determined.
5. The method according to claim 4, characterized in that The determining the occurrence probability of the workload in the corresponding type of samples based on the number of occurrences of each workload in each type of samples includes: For each type of samples, based on the workload of each sample in the same type of samples, the samples in the same type of samples are divided into at least two sample intervals with the goal of maximizing the number of divided sample intervals and the number of samples in each sample interval being greater than a set number threshold; Determine the middle value of the workload in each sample interval as the representative workload of the sample interval; The ratio of the number of samples in the sample interval to the total number of samples of the same type is used as the occurrence probability of the representative workload in the corresponding sample type.
6. The method according to claim 4, characterized in that The method of determining the corresponding probability density function based on the occurrence probability of each workload in each type of sample includes: For each type of sample, the occurrence probability of each workload in the sample is fitted with a function to obtain a fitting function of the corresponding sample; determining an integral value of the fitting function; Based on the integral value, the fitting function is modified, and the modified fitting function is used as the probability density function of the sample.
7. The method according to any one of claims 3 to 6, characterized in that The step of determining the boundary threshold based on the first probability density function and the second probability density function comprises: determining at least one intersection point of the first probability density function and the second probability density function; From the at least one intersection point, an intersection point is determined as the boundary threshold.
8. A code quality determination device, characterized in that: include: A determination module is used to determine that the number of defects of the current task in the quality determination process is zero and to determine the workload of the current task; An analysis module, configured to determine a defect distribution of tasks in the historical records, wherein the defect distribution includes a relationship between a workload and a defect number of the tasks in the historical records, wherein the defect number includes a first defect number in the quality determination process and a second defect number in the application stage; A processing module is used to determine the expected code quality of the current task based on the defect distribution and the workload of the current task.
9. An electronic device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the code quality determination method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the code quality determination method according to any one of claims 1 to 7 when executed by a processor.