Code quality detection method and device and computing equipment

Through a multi-level code quality detection method, real-time monitoring and detection of incremental code is carried out, which solves the problems of insufficient efficiency and accuracy in existing technologies and realizes efficient and accurate code quality detection.

CN120687345APending Publication Date: 2025-09-23DIGITAL TRADING SCI & TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510772751.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-23

AI Technical Summary

Technical Problem

The code quality detection in the existing technology is inefficient and has low accuracy. The entire code file needs to be submitted before detection can be performed, which is limited to simple syntax detection.

Method used

A multi-level code quality detection method is adopted, including static quality detection, model quality detection and test case detection. The next level of detection is only performed when the results of the previous level do not contain error-type vulnerabilities, and real-time monitoring and detection are performed on incremental code.

Benefits of technology

It improves the accuracy and efficiency of code quality detection, saves system resources, and provides timely feedback on detection results to facilitate user correction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120687345A_ABST
    Figure CN120687345A_ABST
Patent Text Reader

Abstract

The invention discloses a code quality detection method and device and computing equipment. The method comprises the following steps: acquiring an incremental code according to monitoring data for a code editor; performing static quality detection on the incremental code, and obtaining and displaying a static quality detection result; if the static quality detection result does not contain the error vulnerability, performing quality detection on the incremental code by utilizing a quality detection model, and obtaining and displaying a model quality detection result; and if the model quality detection result does not contain the error vulnerability, generating a test case corresponding to the incremental code, testing the incremental code by using the test case to obtain a test result, and displaying the test result. According to the scheme, a multi-level code quality detection mode is adopted, the code quality detection precision is improved, and system resources are saved; the detection result is timely fed back to the user after being obtained at each level, so that the user can timely correct the code; and code quality detection is carried out on incremental codes, so that the code quality detection efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a code quality detection method, apparatus, computing device, computer storage medium, and computer program product. Background Art

[0002] Code quality testing is the process of inspecting the quality of code during software development. It is a crucial part of the software development process and has a very important impact on the maintenance cost and stability of the software.

[0003] However, during the implementation process, the inventors found that the existing technology has the following defects: the existing technology requires the entire code file to be submitted before the code quality detection is performed on the entire code file, which leads to insufficient efficiency of code quality detection; moreover, the code quality detection in the existing technology is limited to simple syntax detection, etc., and the code quality detection accuracy is insufficient. Summary of the Invention

[0004] In view of the above problems, the present application is proposed to provide a code quality detection method, apparatus, computing device, computer storage medium and computer program product that overcome the above problems or at least partially solve the above problems.

[0005] According to a first aspect of the present application, a code quality detection method is provided, comprising:

[0006] Obtain incremental code based on monitoring data for the code editor;

[0007] Performing static quality testing on the incremental code, obtaining and displaying static quality testing results;

[0008] If the static quality inspection result does not contain error-type vulnerabilities, perform quality inspection on the incremental code using a quality inspection model, and obtain and display the model quality inspection result;

[0009] If the model quality detection result does not include error-type vulnerabilities, a test case corresponding to the incremental code is generated, the incremental code is tested using the test case to obtain a test result, and the test result is displayed.

[0010] In an optional implementation, obtaining incremental code according to monitoring data for the code editor includes:

[0011] It is monitored that the editing pause time of the code editor reaches a preset time, and incremental code is obtained.

[0012] In an optional implementation, obtaining incremental code according to monitoring data for the code editor includes:

[0013] Determine whether the time interval between the current time and the last incremental code acquisition time reaches a preset period;

[0014] If so, get the incremental code;

[0015] The preset period is dynamically adjusted according to the code editing speed and / or CPU load within a preset period.

[0016] In an optional implementation, performing static quality testing on the incremental code and obtaining and displaying the static quality testing result includes:

[0017] Performing a syntax quality test on the incremental code, obtaining and displaying the syntax quality test result;

[0018] If the syntax quality test result does not contain error-type vulnerabilities, then perform rule quality test on the incremental code, and obtain and display the rule quality test result;

[0019] If the static quality detection result does not include error-type vulnerabilities, using a quality detection model to perform quality detection on the incremental code includes: if the rule quality detection result does not include error-type vulnerabilities, using a quality detection model to perform quality detection on the incremental code.

[0020] In an optional embodiment, performing quality inspection on the incremental code using a quality inspection model, and obtaining and displaying the model quality inspection result includes:

[0021] Performing quality inspection on the incremental code using a quality inspection model to obtain model quality inspection results and vulnerability repair data;

[0022] Display the model quality test results and vulnerability repair data.

[0023] In an optional embodiment, after generating a test case corresponding to the incremental code, testing the incremental code using the test case to obtain a test result, and displaying the test result, the method further includes:

[0024] Pre-repairing the incremental code using the vulnerability repair data to obtain repair code;

[0025] The repair code is tested using the test case to obtain a repair test result, and comparison data between the repair test result and the test result is displayed.

[0026] According to a second aspect of the present application, a code quality detection device is provided, comprising:

[0027] The acquisition module is used to obtain incremental code based on the monitoring data of the code editor;

[0028] A static detection module is used to perform static quality detection on the incremental code, and obtain and display the static quality detection results;

[0029] A model detection module is used to perform quality detection on the incremental code using a quality detection model if the static quality detection result does not contain an error-type vulnerability, and obtain and display the model quality detection result;

[0030] A testing module is used to generate a test case corresponding to the incremental code if the model quality detection result does not contain an error-type vulnerability, use the test case to test the incremental code to obtain a test result, and display the test result.

[0031] In an optional implementation, the acquisition module is configured to: upon detecting that the editing pause duration of the code editor reaches a preset duration, acquire the incremental code.

[0032] In an optional embodiment, the acquisition module is used to: determine whether the time interval between the current time and the last incremental code acquisition time reaches a preset period;

[0033] If so, get the incremental code;

[0034] The preset period is dynamically adjusted according to the code editing speed and / or CPU load within a preset period.

[0035] In an optional embodiment, the static detection module is used to: perform syntax quality detection on the incremental code, and obtain and display the syntax quality detection result;

[0036] If the syntax quality test result does not contain error-type vulnerabilities, then perform rule quality test on the incremental code, and obtain and display the rule quality test result;

[0037] The model detection module is used to: if the rule quality detection result does not include error-type vulnerabilities, use the quality detection model to perform quality detection on the incremental code.

[0038] In an optional embodiment, the model detection module is used to: perform quality detection on the incremental code using a quality detection model to obtain model quality detection results and vulnerability repair data;

[0039] Display the model quality test results and vulnerability repair data.

[0040] In an optional embodiment, the testing module is used to: pre-repair the incremental code using the vulnerability repair data to obtain repair code;

[0041] The repair code is tested using the test case to obtain a repair test result, and comparison data between the repair test result and the test result is displayed.

[0042] According to a third aspect of the present application, a computing device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus;

[0043] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the above-mentioned code quality detection method.

[0044] According to a fourth aspect of the present application, a computer storage medium is provided, wherein the storage medium stores at least one executable instruction, and the executable instruction enables a processor to perform operations corresponding to the above-mentioned code quality detection method.

[0045] According to a fifth aspect of the present application, a computer program product is provided, comprising at least one executable instruction, wherein the executable instruction enables a processor to perform operations corresponding to the above-mentioned code quality detection method.

[0046] The code quality detection method, apparatus, computing device, computer storage medium and computer program product provided in this application adopt a multi-level code quality detection method of static quality detection → model quality detection → test case detection, and only perform quality detection of the next level when the quality detection results of the previous level do not contain error-type vulnerabilities, thereby improving the accuracy of code quality detection and saving system resources; and promptly feedback the detection results to the user after obtaining them at each level, so that the user can make timely corrections to the code; and this application performs code quality detection on incremental code, thereby improving the efficiency of code quality detection.

[0047] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present application. The same reference symbols are used throughout the drawings to represent the same components. In the drawings:

[0049] Figure 1 A schematic diagram of a code quality detection method according to the first embodiment of the present invention is shown;

[0050] Figure 2 A schematic diagram of a flow chart of an incremental code acquisition method provided in Example 1 of the present application is shown;

[0051] Figure 3 A schematic diagram of the architecture of a quality detection model provided in Example 1 of the present application is shown;

[0052] Figure 4 A schematic diagram of a quality inspection process using a test case provided in Example 1 of the present application is shown;

[0053] Figure 5 The following is a schematic diagram showing the architecture of a multi-level code quality detection method provided in Example 1 of the present application;

[0054] Figure 6 A schematic diagram of a code quality detection method according to the second embodiment of the present application is shown;

[0055] Figure 7 A schematic diagram of the architecture of a multi-level code quality detection method provided in Example 2 of the present application is shown;

[0056] Figure 8 A schematic diagram of the structure of a code quality detection device provided in the third embodiment of the present application is shown;

[0057] Figure 9 A structural diagram of a computing device provided in Example 4 of the present application is shown. DETAILED DESCRIPTION

[0058] The following describes exemplary embodiments of the present application in more detail with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0059] Example 1

[0060] Figure 1 The following is a flow chart of a code quality detection method provided in Example 1 of the present application. Figure 1 As shown, the method includes the following steps:

[0061] S101: Obtain incremental code based on monitoring data for the code editor.

[0062] Users usually edit code through a code editor. In this embodiment of the present application, the execution device establishes a communication connection with the code editor. Monitoring data for the code editor can be transmitted through the communication connection. The monitoring data may include: code data generated by the user in the code editor, and may also include editing behavior data of the user in the code editor.

[0063] In an optional implementation, the incremental code may be acquired at a timing that adopts one or more of the following combinations:

[0064] Incremental code acquisition opportunity 1: When the code editor pauses for a preset duration, incremental code acquisition is triggered. Specifically, when the user pauses editing in the code editor for a preset duration, the incremental code acquisition process is triggered. This allows incremental code acquisition and code quality testing to be performed when the user pauses editing, reducing the code iteration cycle and improving coding fluency.

[0065] Incremental code acquisition timing 2: Determine whether the interval between the current time and the last incremental code acquisition time has reached a preset period; if so, acquire the incremental code. In this method, a corresponding incremental code acquisition period is configured. When the corresponding acquisition period is reached, the incremental code is acquired and the subsequent code quality inspection process is triggered.

[0066] Further optionally, the preset period may be a fixed period. For example, the fixed period may be a high-frequency period of every 5 seconds or 10 seconds, or a low-frequency period of every 60 seconds. In short, the fixed period should be less than the entire code submission period, so that real-time or near real-time detection of the code can be achieved.

[0067] Further optionally, the preset period can be dynamically adjusted according to the code editing speed and / or CPU load in the preset time period. Specifically, a basic period can be set to obtain the code editing speed and / or CPU load in the most recent period, and dynamically adjusted based on the basic period according to the code editing speed and / or CPU load. The adjusted preset period is negatively correlated with the code editing speed and positively correlated with the CPU load, etc. For example, if the code editing speed in the most recent period exceeds the basic speed, the preset period is adjusted up or down on the basic period, and the magnitude of the reduction is positively correlated with the code editing speed; if the code editing speed in the most recent period is lower than the basic speed, the preset period is adjusted up on the basic period, and the magnitude of the increase is positively correlated with the code editing speed. This approach can make the preset period compatible with the actual amount of coding, avoid the waste of system resources caused by frequent acquisition of incremental codes, and avoid the disadvantages of untimely code detection caused by too long an acquisition period. Accordingly, if the CPU load in the recent period exceeds the base load, the preset period is adjusted upward based on the base period, and the increase is positively correlated with the CPU load. If the CPU load in the recent period is lower than the base load, the preset period is adjusted upward or downward based on the base period, and the decrease is positively correlated with the CPU load. This approach ensures that the preset period is compatible with the actual system load, preventing code quality testing from placing excessive pressure on the system and ensuring system stability.

[0068] Incremental code acquisition opportunity three: determine whether the editing pause time of the code editor reaches the preset time; if so, obtain the incremental code; if not, determine whether the time interval between the current time and the last incremental code acquisition time reaches the preset period; if it reaches the preset period, obtain the incremental code.

[0069] When it is determined that the incremental code acquisition opportunity has arrived, the acquisition of the incremental code is triggered. In particular, the incremental code can be acquired by using a difference comparison algorithm. In addition, in an optional embodiment, the incremental code can be specifically acquired by using Figure 2 Steps S1011-S1013 shown obtain:

[0070] S1011, collecting current code data and obtaining historical code data.

[0071] When the time comes to acquire incremental code, the current code data is collected. Historically stored code data is also acquired. This historical code data includes the code text of the historical code, as well as the Abstract Syntax Tree (AST) obtained by parsing the historical code, the code fingerprints (e.g., hash values) of each code line, and each function.

[0072] S1012: Locate the changed code blocks of the current code data compared with the historical code data based on the code fingerprint and / or syntax tree comparison algorithm.

[0073] The code fingerprint of each code line, each function, and other units in the current code data is calculated. By comparing the code fingerprints of the current code data with the historical code data, the changed code lines can be quickly located. By comparing the new abstract syntax tree of the current code data with the old abstract syntax tree of the historical code data, the changed syntax nodes (such as functions and classes) can be quickly located. The changed code lines and the code blocks (functions or classes) where the syntax nodes are located are then identified as changed code blocks.

[0074] S1013: Obtain incremental code according to the changed code block.

[0075] In actual implementation, the changed code block can be directly used as the incremental code block; or the associated code blocks of the changed code block can be determined, and the changed code block and the associated code blocks can be used as incremental code.

[0076] Step S102: Perform static quality testing on the incremental code, and obtain and display the static quality testing results.

[0077] After acquiring the incremental code, static quality testing is first performed on the incremental code. This involves using a static quality testing algorithm to perform a first-level quality check on the incremental code. This static quality testing may include syntax quality testing and / or rule quality testing. Once the static quality testing results are obtained, they are presented to the user promptly. For example, static quality testing results can be displayed through a marker renderer or diagnostic panel, allowing users to obtain the quality test results in a timely manner.

[0078] Among them, the static quality detection results obtained in the embodiment of the present application include corresponding vulnerabilities, which can be divided into two categories. The first category is error-type vulnerabilities, which are vulnerabilities that affect program operation; the second category is warning-type vulnerabilities, which do not affect program operation.

[0079] Step S103, determining whether the static quality detection result contains an error-type vulnerability; if not, executing step S104; if so, executing step S101.

[0080] If the static quality inspection result contains error-type vulnerabilities, the inspection of this incremental code is terminated and step S101 is executed to inspect the next incremental code, thereby saving system resources; if the static quality inspection result does not contain error-type vulnerabilities, the next level of quality inspection is carried out, that is, step S104 is executed.

[0081] Step S104: perform quality inspection on the incremental code using the quality inspection model, and obtain and display the model quality inspection results.

[0082] If the static quality check results do not contain error-type vulnerabilities, a second-level quality check is performed using the quality check model. The test results output by the second model are the model quality check results. The model quality check results are displayed to the user in a timely manner. This application does not limit the specific display method of the model quality check results. For example, the model quality check results can be displayed in a list, log, or other format.

[0083] In an optional implementation, the quality detection model may be a large language model. In the implementation process, the incremental code and the corresponding prompt words are input into the quality detection model to obtain the model quality detection result output by the quality detection model.

[0084] In an optional embodiment, the quality detection model may include multiple sub-models, each sub-model is used to perform quality detection on the code from different dimensions. Figure 3 As shown, the quality inspection model includes: a security inspection model, a performance inspection model, a maintainability inspection model, an aggregation unit, a prioritization unit, and an output unit. The security inspection model is used to detect code security vulnerabilities and potential safety hazards; the performance inspection model is used to detect code performance bottlenecks and performance optimization points; and the maintainability inspection model is used to detect code maintainability vulnerabilities. Each sub-model can be pre-trained using a machine learning algorithm and corresponding sample data. After obtaining incremental code, the quality inspection model calls sub-models in multiple dimensions to perform multi-dimensional analysis on the incremental code, thereby obtaining sub-model quality inspection results output by each sub-model. The aggregation unit further aggregates the sub-model quality inspection results output by each sub-model. The prioritization unit then calculates the priority of each sub-model quality inspection result based on the confidence level and sub-model weight of each sub-model quality inspection result. The sub-model quality inspection results are then ranked according to their priority, and the ranked sub-model quality inspection results are ultimately output, thus obtaining the model quality inspection results of the quality inspection model.

[0085] Step S105, determine whether the model quality detection result contains error-type vulnerabilities; if not, execute step S106; if so, execute step S101.

[0086] The model quality detection vulnerabilities included in the model quality detection results can be divided into error vulnerabilities and warning vulnerabilities. If the model quality detection results do not include error vulnerabilities, the next level of quality detection is carried out, that is, step S106 is executed. If the model quality detection results include error vulnerabilities, the quality detection of the current incremental code is terminated and the process proceeds to step S101 to obtain the next incremental code at the corresponding triggering time.

[0087] Step S106: Generate a test case corresponding to the incremental code, use the test case to test the incremental code to obtain a test result, and display the test result.

[0088] If the model quality check results do not contain error-related vulnerabilities, the model enters the third level of quality control: test case testing. During implementation, test cases are first generated based on the incremental code. These test cases are then used for testing and the test results are obtained. Finally, the test results are presented to the user in the form of test reports and logs.

[0089] In an optional implementation, the specific implementation process of the third level quality inspection (quality inspection using test cases) can be as follows: Figure 4 Specifically, after determining to enter the third level of quality inspection, the editor plug-in initiates a request to generate a test case, and the test generation engine generates a test case based on the request (corresponding to Figure 4 ) and show it to the developer. After the open user confirms the execution, submit the incremental code and test cases (corresponding to Figure 4 Submit code and test suites (in the test execution sandbox) to the test execution sandbox environment, where test cases are executed in the sandbox's secure environment, ensuring the security of the system's online business. The test result library stores test case execution results and provides users with feedback on test progress. After the test is completed, a visual report is generated and provided to the user. In addition, coverage testing can be performed and test cases can be regenerated based on the test results to improve test accuracy.

[0090] In an optional embodiment, a use case generation model may be generated in advance, for example, the use case generation model may be a large language model, and the incremental code and the use case generation prompt words are input into the use case generation model to obtain the test case output by the use case generation model.

[0091] In an optional embodiment, the test case can be generated specifically through the following steps: determining the function to be tested in the incremental code and the corresponding abstract syntax tree through a code analysis algorithm, and obtaining the basic data such as the function logic path, function signature, parameter type, return value type, etc. corresponding to the incremental code to extract basic features, that is, the basic features include function name, abstract syntax tree, execution logic, parameters, etc.; further performing input and output analysis, determining the input / output data type and corresponding parameter range of the incremental code through algorithms such as tracing variable transmission paths, and extracting input / output features; and obtaining parameter extreme values ​​through boundary condition analysis; and detecting abnormal paths, and extracting abnormal path features; providing the extracted features and the incremental code and / or the associated code of the incremental code (such as context data, etc.) to a test case generator (for example, a corresponding computer model, etc.) to generate a test case.

[0092] by Figure 5 For example, the embodiment of the present application performs three levels of testing on incremental code: the first level is static quality testing, the second level is model quality testing, and the third level is test case quality testing. After each level obtains the corresponding test results, the results are displayed visually in a timely manner, so that users can grasp the test results in a timely manner and make timely corrections to the code. In addition, the next level of testing needs to be triggered when the test results of the previous level do not contain errors or vulnerabilities, thereby saving system resources.

[0093] It can be seen that the code quality detection method provided in the embodiment of the present application adopts a multi-level code quality detection method of static quality detection → model quality detection → test case detection, and only performs quality detection of the next level when the quality detection result of the previous level does not contain error-type vulnerabilities, thereby improving the accuracy of code quality detection and saving system resources; and promptly feeds back to the user after obtaining the detection results at each level, so that the user can make timely corrections to the code; and this application performs code quality detection on incremental code to improve the efficiency of code quality detection.

[0094] Example 2

[0095] Figure 6 FIG2 shows a flow chart of a code quality detection method provided in Example 2 of the present application. Figure 6 As shown, the method specifically includes the following steps:

[0096] Step S601: Obtain incremental code based on monitoring data for the code editor.

[0097] Step S602: Perform syntax quality detection on the incremental code, and obtain and display the syntax quality detection result.

[0098] In the embodiment of the present application, the incremental code is first subjected to a syntax quality check, and the syntax quality check results are displayed in a timely manner. The syntax quality check includes checking the integrity of the incremental code, checking the syntax legality and compliance, etc. The embodiment of the present application does not limit the specific syntax quality check algorithm.

[0099] Step S603, determining whether the syntax quality detection result contains an error-type vulnerability; if not, executing step S604; if so, executing step S601.

[0100] If the syntax quality test result contains error-type vulnerabilities, the subsequent quality test is terminated in time, and step S601 is executed to obtain and quality test the next incremental code; if the syntax quality test result does not contain error-type vulnerabilities, the next level of quality test is performed, that is, step S604 is executed.

[0101] Step S604: perform rule quality testing on the incremental code, and obtain and display the rule quality testing results.

[0102] If the syntax quality test results do not contain error-type vulnerabilities, the incremental code is subjected to a second-level quality test, namely, rule quality test, to obtain and display the rule quality test results. Specifically, rule quality test uses the configured rule algorithm to perform code style testing, security testing, logic testing, code smell detection, etc. on the incremental code. The embodiments of this application do not limit the specific rule detection algorithm.

[0103] Step S605 , determining whether the rule quality detection result includes an error-type vulnerability; if not, executing step S606 ; if so, executing step S601 .

[0104] If the rule quality detection result contains error-type vulnerabilities, the detection of this incremental code is terminated, and step S601 is executed to perform the next incremental code quality detection; if the rule quality detection result does not contain error-type vulnerabilities, step S606 is executed to perform the next level of quality detection.

[0105] Step S606: Use the quality inspection model to perform quality inspection on the incremental code, obtain the model quality inspection results and vulnerability repair data; and display the model quality inspection results and vulnerability repair data.

[0106] If the rule quality test results do not contain error-type vulnerabilities, the third-level quality test will be performed through the quality test model, and the model quality test results will be displayed to the user in a timely manner.

[0107] Furthermore, to further improve vulnerability repair efficiency and accuracy, in embodiments of the present application, the quality inspection model can also output vulnerability repair data and present the repair data to the user. For example, incremental code, quality inspection prompts, and vulnerability repair prompts can be provided to the quality inspection model. The quality inspection model will not only output each quality inspection vulnerability, but also output vulnerability repair suggestions for each quality inspection vulnerability.

[0108] Step S607, determine whether the model quality detection result contains error-type vulnerabilities; if not, execute step S608; if so, execute step S601.

[0109] Step S608: Generate a test case corresponding to the incremental code, use the test case to test the incremental code to obtain a test result, and display the test result.

[0110] If the model quality inspection results do not contain error-type vulnerabilities, it enters the fourth level of quality inspection, namely test case inspection.

[0111] In an optional embodiment, after generating test cases corresponding to the incremental code, using the test cases to test the incremental code to obtain test results, and displaying the test results, the incremental code can also be pre-repaired using vulnerability repair data to obtain repair code, that is, the repair code is the code obtained after repairing the incremental code using the vulnerability repair suggestions output by the quality test model. The repair code is further tested using test cases (that is, test cases that test the incremental test) to obtain repair test results, and the repair test results and comparison data of the test results are displayed. This allows users to intuitively determine the repair effect based on the comparison data, further improving the efficiency and accuracy of vulnerability repair.

[0112] by Figure 7 For example, the embodiment of the present application performs four levels of testing on incremental code, namely, the first level is syntax quality testing, the second level is rule quality testing, the third level is model quality testing, and the fourth level is test case quality testing. After each level obtains the corresponding test results, the results are displayed visually in a timely manner so that users can grasp the test results in a timely manner and make timely corrections to the code; and the detection of the next level needs to be triggered when the test results of the previous level do not contain errors or vulnerabilities, thereby saving system resources.

[0113] It can be seen that the code quality detection method provided in the embodiment of the present application adopts a multi-level code quality detection method of syntax quality detection → rule quality detection → model quality detection → test case detection, and only performs quality detection of the next level when the quality detection result of the previous level does not contain error-type vulnerabilities, thereby further improving the accuracy of code quality detection and saving system resources; and promptly feeds back to the user after obtaining the detection results at each level, so that the user can make timely corrections to the code; and this application performs code quality detection on incremental code to improve the efficiency of code quality detection.

[0114] Example 3

[0115] Figure 8 FIG. 1 shows a schematic diagram of a code quality detection device provided in Example 3 of the present application. Figure 8 As shown, the apparatus 800 includes: an acquisition module 810 , a static detection module 820 , a model detection module 830 , and a testing module 840 .

[0116] An acquisition module 810 is configured to acquire incremental code based on monitoring data of the code editor;

[0117] A static detection module 820 is configured to perform static quality detection on the incremental code, and obtain and display static quality detection results;

[0118] A model detection module 830 is configured to, if the static quality detection result does not contain an error-type vulnerability, perform a quality detection on the incremental code using a quality detection model, and obtain and display a model quality detection result;

[0119] The testing module 840 is used to generate a test case corresponding to the incremental code if the model quality detection result does not contain an error-type vulnerability, use the test case to test the incremental code to obtain a test result, and display the test result.

[0120] In an optional implementation, the acquisition module 810 is configured to: upon detecting that the editing pause duration of the code editor reaches a preset duration, acquire incremental code.

[0121] In an optional embodiment, the acquisition module 810 is used to: determine whether the time interval between the current time and the last incremental code acquisition time reaches a preset period;

[0122] If so, get the incremental code;

[0123] The preset period is dynamically adjusted according to the code editing speed and / or CPU load within a preset period.

[0124] In an optional embodiment, the static detection module 820 is used to: perform syntax quality detection on the incremental code, obtain and display the syntax quality detection result;

[0125] If the syntax quality test result does not contain error-type vulnerabilities, then perform rule quality test on the incremental code, and obtain and display the rule quality test result;

[0126] The model detection module 830 is used to: if the rule quality detection result does not include error-type vulnerabilities, use the quality detection model to perform quality detection on the incremental code.

[0127] In an optional embodiment, the model detection module 830 is used to: perform quality detection on the incremental code using a quality detection model to obtain model quality detection results and vulnerability repair data;

[0128] Display the model quality test results and vulnerability repair data.

[0129] In an optional implementation, the testing module 840 is configured to: pre-repair the incremental code using the vulnerability repair data to obtain repair code;

[0130] The repair code is tested using the test case to obtain a repair test result, and comparison data between the repair test result and the test result is displayed.

[0131] It can be seen that the code quality detection device provided in the embodiment of the present application adopts a multi-level code quality detection method of static quality detection → model quality detection → test case detection, and only performs quality detection of the next level when the quality detection result of the previous level does not contain error-type vulnerabilities, thereby improving the accuracy of code quality detection and saving system resources; and promptly feeds back to the user after obtaining the detection results at each level, so that the user can make timely corrections to the code; and this application performs code quality detection on incremental code to improve the efficiency of code quality detection.

[0132] Example 4

[0133] Figure 9 The schematic diagram of the structure of a computing device provided in the fourth embodiment of the present application is shown. The specific embodiments of the present application do not limit the specific implementation of the computing device.

[0134] like Figure 9 As shown, the computing device may include: a processor (processor) 902 , a communication interface (Communications Interface) 904 , a memory (memory) 906 , and a communication bus 908 .

[0135] Processor 902, communication interface 904, and memory 906 communicate with each other via a communication bus 908. Communication interface 904 is used to communicate with other devices, such as clients or other server network elements. Processor 902 is used to execute program 910, which may specifically perform the steps described in the aforementioned embodiment of the code quality detection method for a computing device.

[0136] Specifically, the program 910 may include program codes, which include computer operation instructions.

[0137] Processor 902 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the computing device may be processors of the same type, such as one or more CPUs, or may be processors of different types, such as one or more CPUs and one or more ASICs.

[0138] Memory 906 is used to store program 910. Memory 906 may include high-speed RAM memory, or may also include non-volatile memory (non-volatile memory), such as at least one disk storage. Program 910 can specifically be used to enable processor 902 to perform the operations in the above method embodiment.

[0139] Example 5

[0140] Embodiment 5 of the present application provides a non-volatile computer storage medium, which stores at least one executable instruction or computer program, and the executable instruction or computer program can enable a processor to perform operations corresponding to the code quality detection method in any of the above method embodiments.

[0141] Example 6

[0142] Embodiment 6 of the present application provides a computer program product, which includes at least one executable instruction or computer program, and the executable instruction or computer program can enable a processor to perform operations corresponding to the code quality detection method in any of the above method embodiments.

[0143] In summary, according to the computing device, computer storage medium and computer program product provided in the embodiments of the present application, a multi-level code quality detection method of static quality detection → model quality detection → test case detection is adopted, and the quality detection of the next level is performed only when the quality detection result of the previous level does not contain error-type vulnerabilities, thereby improving the accuracy of code quality detection and saving system resources; and after obtaining the detection results at each level, timely feedback is given to the user to facilitate the user to make timely corrections to the code; and this application performs code quality detection on incremental code to improve the efficiency of code quality detection.

[0144] The algorithm or demonstration provided here are not inherently relevant to any particular computer, virtual system or other equipment. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing this type of system. In addition, the present application embodiment is not directed to any specific programming language yet. It should be understood that various programming languages ​​can be utilized to realize the content of the present application described here, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the present application.

[0145] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.

[0146] Similarly, it should be understood that in order to streamline the present application and aid in understanding one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present application, the various features of the embodiments of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed application requires more features than those explicitly recited in each claim. Rather, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims following the detailed description are hereby expressly incorporated into the detailed description, with each claim itself serving as a separate embodiment of the present application.

[0147] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition may be divided into multiple submodules or subunits or subcomponents. All features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed herein may be combined in any combination, except that at least some of such features and / or processes or units are mutually exclusive. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0148] Furthermore, those skilled in the art will appreciate that although some embodiments herein include certain features included in other embodiments but not other features, combinations of features from different embodiments are intended to be within the scope of this application and to form different embodiments. For example, in the claims below, any of the claimed embodiments may be used in any combination.

[0149] The various component embodiments of the present application can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all of the functions of some or all of the components according to the embodiments of the present application. The application can also be implemented as a device or apparatus program (e.g., computer program and computer program product) for performing a part or all of the methods described herein. Such a program implementing the present application can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0150] It should be noted that the above embodiments illustrate rather than limit the present application, and that a person skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between brackets should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present application may be implemented by means of hardware comprising several different elements and by means of appropriately programmed computers. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments should not be understood as limiting the order of execution unless otherwise specified.

Claims

1. A code quality detection method, characterized in that: include: Obtain incremental code based on monitoring data for the code editor; Performing static quality testing on the incremental code, obtaining and displaying static quality testing results; If the static quality inspection result does not contain error-type vulnerabilities, perform quality inspection on the incremental code using a quality inspection model, and obtain and display the model quality inspection result; If the model quality detection result does not include error-type vulnerabilities, a test case corresponding to the incremental code is generated, the incremental code is tested using the test case to obtain a test result, and the test result is displayed.

2. The method according to claim 1, characterized in that Obtaining incremental code based on monitoring data for the code editor includes: It is monitored that the editing pause time of the code editor reaches a preset time, and incremental code is obtained.

3. The method according to claim 1, characterized in that Obtaining incremental code based on monitoring data for the code editor includes: Determine whether the time interval between the current time and the last incremental code acquisition time reaches a preset period; If so, get the incremental code; The preset period is dynamically adjusted according to the code editing speed and / or CPU load within a preset period.

4. The method according to any one of claims 1 to 3, characterized in that The performing static quality detection on the incremental code and obtaining and displaying the static quality detection result includes: Performing a syntax quality test on the incremental code, obtaining and displaying the syntax quality test result; If the syntax quality test result does not contain error-type vulnerabilities, then perform rule quality test on the incremental code, and obtain and display the rule quality test result; If the static quality detection result does not include error-type vulnerabilities, using a quality detection model to perform quality detection on the incremental code includes: if the rule quality detection result does not include error-type vulnerabilities, using a quality detection model to perform quality detection on the incremental code.

5. The method according to any one of claims 1 to 3, characterized in that The performing quality inspection on the incremental code using the quality inspection model and obtaining and displaying the model quality inspection result includes: Performing quality inspection on the incremental code using a quality inspection model to obtain model quality inspection results and vulnerability repair data; Display the model quality test results and vulnerability repair data.

6. The method according to claim 5, characterized in that After generating a test case corresponding to the incremental code, testing the incremental code using the test case to obtain a test result, and displaying the test result, the method further includes: Pre-repairing the incremental code using the vulnerability repair data to obtain repair code; The repair code is tested using the test case to obtain a repair test result, and comparison data between the repair test result and the test result is displayed.

7. A code quality detection device, characterized in that: include: The acquisition module is used to obtain incremental code based on the monitoring data of the code editor; A static detection module is used to perform static quality detection on the incremental code, and obtain and display the static quality detection results; A model detection module is used to perform quality detection on the incremental code using a quality detection model if the static quality detection result does not contain an error-type vulnerability, and obtain and display the model quality detection result; A testing module is used to generate a test case corresponding to the incremental code if the model quality detection result does not contain an error-type vulnerability, use the test case to test the incremental code to obtain a test result, and display the test result.

8. A computing device, characterized in that include: A processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the code quality detection method according to any one of claims 1 to 6.

9. A computer storage medium, characterized in that The storage medium stores at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the code quality detection method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises at least one executable instruction, wherein the executable instruction enables a processor to execute an operation corresponding to the code quality detection method according to any one of claims 1 to 6.