Method, device, equipment, storage medium and product for checking code compliance

By judging the compliance of code files and classifying non-compliant code types within a set time range, and providing modification solutions in conjunction with a neural network model, this solves the problem that existing tools cannot distinguish between newly added and modified code, and achieves fast and accurate code compliance checks and modifications.

CN114721715BActive Publication Date: 2024-11-22BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210366871.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-08
Publication Date
2024-11-22
Estimated Expiration
2042-04-08

AI Technical Summary

Technical Problem

Existing code compliance checking tools cannot quickly and accurately determine whether newly added or changed code is compliant, making it impossible to distinguish between issues with newly added or changed code and legacy issues.

Method used

By acquiring issue files and change files within a set time range, the target file is identified, and the code compliance is judged based on the number of lines of code and thresholds in the target file. Non-compliant code behaviors are further subdivided into first and second types, and a neural network model is used to identify non-compliant types and provide modification solutions.

Benefits of technology

It enables quick and accurate determination of the compliance of newly added or modified code, improving the efficiency and accuracy of code modification and reducing the workload of developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114721715B_ABST
    Figure CN114721715B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of distributed technology, and discloses a method, device, equipment, storage medium and product for checking code standardization, wherein the method comprises: obtaining a problem file within a set time range; obtaining a change file within a set time range; determining a file that is both a problem file and a change file as a target file; judging whether the number of problem code lines of the target file within the set time range is less than or equal to a threshold value of the target file; if not, determining the problem code lines in the target file that are within the set time range and within the previous time range that are not within the set time range as non-compliant code lines; determining the code lines in the target file that are both non-compliant code lines and change code lines as first non-compliant code lines; determining the code lines in the target file that are non-compliant code lines and not change code lines as second non-compliant code lines. The present invention can quickly and accurately determine whether the change code is compliant.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed technology, and in particular to a method, device, equipment, storage medium and product for checking code standardization. Background Art

[0002] There are many code compliance checking tools available today, such as p3c, sonar, checkstyle, etc. However, these tools are not friendly to existing projects. Existing checking tools can only check the entire code and scan out problematic code in the entire code, but cannot check only newly added or changed code.

[0003] This will cause the code problems introduced after the new or changed code to be mixed with the original legacy code problems, and it will be impossible to quickly and accurately determine whether the new or changed code is compliant. Therefore, there is an urgent need for a code standardization checking method that can quickly and accurately determine whether the new or changed code is compliant. Summary of the invention

[0004] The embodiment of the present invention provides a method, apparatus, device, storage medium and product for checking code compliance, which are used to quickly and accurately determine whether newly added or modified code is compliant, wherein the method includes:

[0005] Obtain a problem file within a set time range, wherein the problem file is a file containing a problem code, and the problem code includes an existing problem code and a changed problem code;

[0006] Obtain the changed files within the set time range, where the changed files are files where the changed codes are located;

[0007] Determine a file that is both the problem file and the change file as a target file; wherein the target file contains both the problem code and the change code;

[0008] Determine whether the number of problem code lines of the target file within a set time range is less than or equal to a threshold of the target file;

[0009] If so, determining that the changed code in the target file complies with the specification;

[0010] If not, then

[0011] Determine problematic code lines in the target file that are within the set time range and not within the time range before the set time range as non-compliant code lines;

[0012] Determine a code line in the target file that is both a non-compliant code line and a changed code line as a first non-compliant code line;

[0013] The code lines of the target file that are non-compliant code lines and not changed code lines are determined as second non-compliant code lines.

[0014] Preferably, the changed files include newly added files and / or modified original files.

[0015] Correspondingly, the changed code includes a newly added code and / or a modified existing code.

[0016] Preferably, the threshold of the target file is: the number of problematic code lines of the target file within a time range before a set time range.

[0017] Preferably, after determining that the changed code in the target file complies with the specification, the method further includes:

[0018] If the number of problematic code lines of the target file within the set time range is less than the threshold of the target file, the threshold of the target file is updated to the number of problematic code lines.

[0019] Preferably, after determining the code line of the target file that is a non-compliant code line and is not a changed code line as a second non-compliant code line, the method further includes:

[0020] Inputting the first non-compliant code line or the second non-compliant code line in the target file into a neural network model, and outputting the non-compliant type corresponding to the first non-compliant code line or the non-compliant type corresponding to the second non-compliant code line;

[0021] Determine, according to the non-compliance modification table, a modification scheme corresponding to the non-compliance type; wherein the non-compliance modification table records the non-compliance type and the modification scheme corresponding to the non-compliance type;

[0022] Combining the first non-compliant code line and the corresponding modification scheme to form first modification information;

[0023] The second non-compliant code line and the corresponding modification scheme are combined to form second modification information.

[0024] Preferably, after combining the second non-compliant code line and the corresponding modification scheme to form the second modification information, the method further includes:

[0025] sorting the first modification information and the second modification information according to priorities, wherein the priority of the first modification information is higher than that of the second modification information;

[0026] The sorted first modification information and the second modification information are sent to a developer, so that the developer can make modifications according to the sorting.

[0027] Preferably, after sending the sorted first modification information and the second modification information to the developer so that the developer makes modifications according to the sorting, the method further comprises:

[0028] After the developer modifies the first non-compliant code line according to the modification plan in the first modification information, the current problematic code line of the target file is detected and obtained in real time;

[0029] Calculate the number of lines of code that are reduced by the current number of problem lines of code in the target file compared to the number of problem lines of code within a set time range;

[0030] Determining whether the reduced number of code lines is greater than the first number of non-compliant code lines;

[0031] If so, then

[0032] Determine the code line that is both the second non-compliant code line and the current problematic code line as the code line to be modified;

[0033] Determine a modification plan corresponding to the code line to be modified, so that the developer can modify the code line to be modified according to the corresponding modification plan;

[0034] If not, the developer is made to modify the first non-compliant code line according to the modification plan corresponding to the first modification information, or to modify the second non-compliant code line according to the modification plan corresponding to the second modification information.

[0035] Preferably, if the reduced number of code lines is greater than the first number of non-compliant code lines, the method further includes:

[0036] Determine the code line that is the second non-compliant code line and does not belong to the current problematic code line as a passively modified code line;

[0037] determining a non-compliance type of the passively modified code line;

[0038] The modification scheme corresponding to the non-compliant type of the passively modified code row in the non-compliant modification table is adjusted to not require active modification.

[0039] The embodiment of the present invention further provides a device for checking code compliance, which is used to quickly and accurately determine whether the newly added or modified code is compliant. The device includes:

[0040] A first acquisition module is used to acquire a problem file within a set time range, wherein the problem file is a file containing a problem code, and the problem code includes an existing problem code and a changed problem code;

[0041] A second acquisition module is used to acquire a change file within a set time range, wherein the change file is a file where the change code is located;

[0042] A determination module, configured to determine a file that is both the problem file and the change file as a target file; wherein the target file contains both the problem code and the change code;

[0043] A judgment module, used to judge whether the number of problematic code lines of the target file within a set time range is less than or equal to a threshold of the target file;

[0044] If so, determining that the changed code in the target file complies with the specification;

[0045] If not, then

[0046] Determine problematic code lines in the target file that are within the set time range and not within the time range before the set time range as non-compliant code lines;

[0047] Determine a code line in the target file that is both a non-compliant code line and a changed code line as a first non-compliant code line;

[0048] The code lines of the target file that are non-compliant code lines and not changed code lines are determined as second non-compliant code lines.

[0049] An embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-mentioned code compliance checking methods when executing the computer program.

[0050] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements any of the above-mentioned code compliance checking methods.

[0051] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements any of the above-mentioned code compliance checking methods.

[0052] In an embodiment of the present invention, a target file is determined based on problem files and changed files within a set time range, a threshold judgment is performed on the target file, and then non-compliant code lines are determined. The non-compliant code lines are further subdivided to obtain two types of code: problem code belonging to newly added code and / or changed existing code, and code that becomes problem code from existing non-problem code due to the generation of change code. The compliance of the code can be judged quickly and accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0054] Figure 1 A flowchart of a method for checking code compliance provided in an embodiment of the present invention;

[0055] Figure 2 A schematic diagram of a flow chart after determining a second non-compliant code line provided in an embodiment of the present invention;

[0056] Figure 3 A schematic diagram of a flow chart after forming second modification information provided in an embodiment of the present invention;

[0057] Figure 4 A schematic diagram of a process after sending the sorted first modification information and the second modification information to a developer provided in an embodiment of the present invention;

[0058] Figure 5 A flowchart of the case where the number of reduced code lines is greater than the first number of non-compliant code lines provided in an embodiment of the present invention;

[0059] Figure 6 A schematic diagram of the module structure of a device for checking code standardization provided in an embodiment of the present invention;

[0060] Figure 7 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention.

[0061] Description of the accompanying symbols:

[0062] 100. A first acquisition module;

[0063] 200, second acquisition module;

[0064] 300. Determine the module;

[0065] 400, judgment module;

[0066] 702. Computer equipment;

[0067] 704, processor;

[0068] 706. Memory;

[0069] 708, driving mechanism;

[0070] 710, input / output module;

[0071] 712. Input devices;

[0072] 714. Output devices;

[0073] 716. Presentation equipment;

[0074] 718. Graphical user interface;

[0075] 720, network interface;

[0076] 722. Communication link;

[0077] 724. Communication bus. DETAILED DESCRIPTION

[0078] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.

[0079] There are many code compliance checking tools available today, such as p3c, sonar, checkstyle, etc. However, these tools are not friendly to existing projects. Existing checking tools can only check the entire code and scan out problematic code in the entire code, but cannot check only newly added or changed code.

[0080] In order to solve the above problems, the embodiments of this article provide a method for checking code compliance. Figure 1 It is a flowchart of a method for checking code compliance provided in the embodiments of this invention. This specification provides method operation steps as described in the embodiments or flowcharts, but more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only order of execution. When the actual system or device product is executed, it can be executed in the order of the method shown in the embodiments or drawings or in parallel.

[0081] It should be noted that the terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this article described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0082] Reference Figure 1 ,This article provides a method for checking code standardization, including:

[0083] S101: Acquire a problem file within a set time range, wherein the problem file is a file containing a problem code, and the problem code includes an existing problem code and a changed problem code;

[0084] S102: Acquire a change file within a set time range, wherein the change file is a file where the change code is located;

[0085] S103: Determine a file that is both the problem file and the change file as a target file; wherein the target file contains both the problem code and the change code;

[0086] S104: Determine whether the number of problem code lines of the target file within a set time range is less than or equal to a threshold of the target file;

[0087] S105: If yes, determining that the changed code in the target file complies with the specification;

[0088] S106: If not, then

[0089] S1061: Determine problematic code lines in the target file that are within the set time range and are not within the time range before the set time range as non-compliant code lines;

[0090] S1062: Determine a code line in the target file that is both a non-compliant code line and a changed code line as a first non-compliant code line;

[0091] S1063: Determine the code line of the target file that is a non-compliant code line and is not a changed code line as a second non-compliant code line.

[0092] Normally, after a code change, there may be problems in the changed code. Of course, there may also be problems in the previous stock code. The problem codes described in this article refer to all problematic codes within the set time range. The problem codes include existing problem codes and changed problem codes. If there is a problem in the changed code, the problem code is the changed problem code; if there is a problem in the stock code, the problem code is the stock problem code.

[0093] The set time range can be adjusted according to needs. The set time range mentioned in this article can be, for example, 8:00 to 9:00 this morning, or from a certain time yesterday to the current time today.

[0094] Since all codes exist in corresponding files, for example, file 1 is the code for data acquisition, and file 2 is the code for data transmission, when checking for code problems, the inspection is generally carried out in files. If there is a problem code in a file (it may be a problem in the changed code or a problem in the existing code), then the file is a problem file.

[0095] The changed code includes the newly added code and / or the changed stock code. Accordingly, the changed file includes the newly added file and / or the changed original file. Within the set time range, the developer may have added new code or changed the stock code, or both at the same time. These codes are the changed code. Because developers usually make code changes in files, files with changed code are called changed files.

[0096] If a file contains a problem code, the file is a problem file; if a file contains a change code, the file is a change file; if a file contains both a problem code and a change code, the file is determined to be a target file, that is, a file that is both a problem file and a change file is determined to be a target file.

[0097] For the codes in the target file, there are several situations, for example: 1. There are 10 lines of code in the target file, of which 3-5 are problem codes, and 6-10 are behavior change codes; 2. There are 10 lines of code in the target file, of which 3-5 are problem codes, and 4-10 are behavior change codes; 3. There are 10 lines of code in the target file, of which 6-10 are problem codes, and 6-10 are behavior change codes.

[0098] The above situations can be summarized as: the problem code and the change code have no intersection, the problem code and the change code have an intersection, and the intersection between the problem code and the change code also includes: the problem code and the change code have a partial intersection, and the problem code is the change code.

[0099] In the embodiments of this article, the threshold value of the target file can be: the number of problem code lines of the target file in the previous time range of the set time range, which can of course be set according to actual conditions. In terms of time sequence, the previous time range is before the set time range, and within the previous time range, there is no changed code within the set time range. For example, the set time range is 8-9 this morning, and the previous time range is 7-8 this morning. There are only 5 lines of code in the target file within the previous time range, and the changed code is generated within the set time range, and there are 10 lines of code in the target file.

[0100] Assuming that there are 3 lines of problem code in the previous time range and 8 lines of problem code in the set time range, it can be determined that the number of problem code lines increased due to the change code generated within the set time range, that is, the change code does not meet the specifications, that is, the problem code in the target file that belongs to the set time range and does not belong to the previous time range of the set time range behaves as non-compliant code.

[0101] Compliance with the specification mentioned here means that there are no problems. It can be understood that the existence of problems includes the following two possibilities: there is a problem with the change code itself, and the generation of the change code causes the existing code that was not a problem code to become a problem code. It should be distinguished that the change code in this article includes new code and / or modified existing code. The new code is easy to understand, that is, from nothing to something, and the modified existing code means that a certain line of existing code has been modified. Different from this concept is that the generation of the change code causes the existing code to change from a code that was not a problem code to a problem code. These existing codes that were not a problem code were not modified, but the generation of the change code caused the existing code that was not modified to have problems and become a problem code.

[0102] The number of problem code lines of the target file in the time range before the set time range can be used as the threshold of the target file. The reason is that the problem code in the previous time range already existed, and as long as the number of problem code lines within the set time range is greater than the number of problem code lines that originally existed, it proves that there is a problem with the changed code within the set time range, or that the generation of the changed code causes the code in the stock code that was not originally a problem code to become a problem code.

[0103] From the above analysis, it can be seen that if the number of problematic code lines within the set time range increases compared to the number of problematic code lines within the previous time range, then the increased code lines (problematic code lines within the set time range and not within the previous time range of the set time range) are non-compliant code lines, and non-compliant code lines are divided into two situations, resulting in two types of non-compliant codes. Therefore, in the embodiment of this article, after determining the non-compliant code lines, it is also necessary to distinguish which type the non-compliant code lines belong to.

[0104] The two specific types are as follows: the code that is both a non-compliant code line and a changed code line is determined as the first non-compliant code line. Since the changed code has been explained above: the changed code includes the newly added code and / or the changed existing code, the first non-compliant code line refers to the problem code in the newly added code and / or the changed existing code within the set time range. The code line that is a non-compliant code line and not a changed code line is determined as the second non-compliant code line. The second non-compliant code line refers to the code within the set time range that has caused the existing code to become a problem code due to the generation of the changed code.

[0105] Through the method in this article, the target file is determined according to the problem files and changed files within the set time range, and the threshold judgment is performed on the target file to determine the non-compliant code lines. The non-compliant code lines are further subdivided to obtain two types of code: the problem code in the newly added code and / or the changed existing code, and the code that becomes the problem code due to the generation of the changed code. The compliance of the code can be judged quickly and accurately.

[0106] In the embodiment of this article, if the threshold of the target file is not the number of problem code lines of the target file within the time range before the set time range, but a value set according to the actual situation, the actual situation mentioned in this article is more likely to be when the target file is initially generated, and the number of problem code lines in the target file when the target file is initially generated is the threshold of the target file, then after determining that the changed code in the target file meets the specification, it also includes:

[0107] If the number of problematic code lines of the target file within the set time range is less than the threshold of the target file, the threshold of the target file is updated to the number of problematic code lines.

[0108] It is understandable that after the change code is generated within the set time range, the first situation may lead to an increase in problem code, and the second situation may lead to a decrease in problem code. The reason is that the generation of the change code reduces the problems of the existing problem code. After the second situation occurs, the threshold of the target file needs to be modified accordingly. The threshold of the updated target file is the number of problem code lines.

[0109] For the first case, the increase in problem codes is generally because there are problem codes in the changed code or the generation of the changed code causes the existing non-problem code to become problem code. Developers are then required to process these problem codes, and after processing, these problem codes will no longer exist. Therefore, the threshold of the target file remains unchanged. However, if the problem code still exists after the developer processes it, the threshold of the target file also needs to be updated according to the number of problem code lines.

[0110] Reference Figure 2 In the embodiment of this article, after determining the code line of the target file that is a non-compliant code line and not a changed code line as the second non-compliant code line, the method further includes:

[0111] S201: inputting the first non-compliant code line or the second non-compliant code line in the target file into a neural network model, and outputting the non-compliant type corresponding to the first non-compliant code line or the non-compliant type corresponding to the second non-compliant code line;

[0112] S202: Determine a modification plan corresponding to the non-compliant type according to a non-compliant modification table; wherein the non-compliant modification table records the non-compliant type and the modification plan corresponding to the non-compliant type;

[0113] S203: combining the first non-compliant code line and the corresponding modification scheme to form first modification information;

[0114] S204: Combine the second non-compliant code line and the corresponding modification solution to form second modification information.

[0115] The neural network model is a trained model, and the neural network model can be used to determine the non-compliance type corresponding to the first non-compliant code line and the second non-compliant code line. After the non-compliance type is determined, the corresponding modification plan can be determined according to the non-compliance modification table, and the non-compliance type and the modification plan are combined to form the first modification information or the second modification information.

[0116] Reference Figure 3 In the embodiment of this article, the combining of the second non-compliant code line and the corresponding modification scheme to form the second modification information further includes:

[0117] S301: sorting the first modification information and the second modification information according to priorities, wherein the priority of the first modification information is higher than that of the second modification information;

[0118] S302: Send the sorted first modification information and the second modification information to a developer, so that the developer can make modifications according to the sorting.

[0119] It is understandable that if the target file has the first non-compliant code and the second non-compliant code within the set time range, the first modification information and the second modification information will be generated accordingly; if only the first non-compliant code or the second non-compliant code exists, the first modification information or the second modification information will be generated. Priority will only exist when both the first modification information and the second modification information exist. If only the first modification information or the second modification information exists, there will be no priority.

[0120] Reference Figure 4 In the embodiment of this invention, after sending the sorted first modification information and the second modification information to the developer so that the developer can make modifications according to the sorting, the method further includes:

[0121] S401: After the developer modifies the first non-compliant code line according to the modification plan in the first modification information, the current problematic code line of the target file is detected and obtained in real time;

[0122] S402: Calculate the number of lines of code that are reduced by the current number of problem lines of code in the target file compared to the number of problem lines of code within a set time range;

[0123] S403: Determine whether the reduced number of code lines is greater than the first number of non-compliant code lines;

[0124] S404: If yes, then

[0125] S4041: Determine a code line that is both the second non-compliant code line and the current problematic code line as a code line to be modified;

[0126] S4042: Determine a modification plan corresponding to the code line to be modified, so that the developer modifies the code line to be modified according to the corresponding modification plan;

[0127] S405: If not, the developer is instructed to modify the first non-compliant code line according to the modification plan corresponding to the first modification information, or to modify the second non-compliant code line according to the modification plan corresponding to the second modification information.

[0128] After the developer receives the first modification information and the second modification information within the set time range at the same time, he will first modify the first non-compliant code line according to the modification plan in the first modification information. Since the first non-compliant code corresponds to the problem code in the changed code within the set time range, after the first non-compliant code line is modified, the problem code in the changed code within the set time range will disappear. At this time, after real-time detection of the current problem code line of the target file, the problem code line in the changed code will not exist in the current problem code line.

[0129] In addition to the disappearance of the problem code in the changed code within the set time range, the code (the second non-compliant code line) that has become a problem code due to the generation of the changed code may also disappear accordingly. Therefore, at this time, it is necessary to calculate the number of code lines that have decreased compared to the number of problem code lines within the set time range compared to the current number of problem code lines in the target file. If the number of code lines that have decreased is greater than the first number of non-compliant code lines, it means that the second non-compliant code lines have also decreased accordingly. However, it is possible that the second non-compliant code lines are completely reduced to zero, that is, as the developer modifies the first non-compliant code line, the second non-compliant code line disappears accordingly. It is also possible that a part of the second non-compliant code lines is reduced, and there are still some second non-compliant code lines. This part of the code lines is the code lines to be modified. The code lines to be modified belong to both the second non-compliant code lines and the current problem code lines. For the code lines to be modified, the developers still need to modify them according to the corresponding modification plan.

[0130] This can reduce the workload of developers accordingly and improve their code modification efficiency.

[0131] However, if the number of reduced code lines is less than or equal to the first number of non-compliant code lines, the reason for being less than may be that the developer did not completely modify the first non-compliant code line successfully, and the reason for being equal to is that the first non-compliant code line was completely modified successfully but the second non-compliant code line generated by it was not reduced accordingly. At this time, the developer modifies the first non-compliant code line according to the modification plan corresponding to the first modification information, or modifies the second non-compliant code line according to the modification plan corresponding to the second modification information.

[0132] Reference Figure 5 In the embodiment of this article, if the reduced number of code lines is greater than the first number of non-compliant code lines, it also includes:

[0133] S501: Determine a code line that is a second non-compliant code line and is not a current problematic code line as a passively modified code line;

[0134] S502: Determine the non-compliance type of the passively modified code line;

[0135] S503: Adjust the modification scheme corresponding to the non-compliant type of the passively modified code line in the non-compliant modification table to not require active modification.

[0136] If the number of reduced code lines is greater than the number of the first non-compliant code lines, it means that the first non-compliant code line has been completely modified successfully, and the second non-compliant code line generated by it has also reduced the problem accordingly, then the code line that belongs to the second non-compliant code line and does not belong to the current problem code line is determined as a passively modified code line, and the passively modified code line is the problem code line in the second non-compliant code line that is reduced accordingly due to the successful modification of the first non-compliant code line. The modification plan in the non-compliant modification table corresponding to the non-compliant type of these passively modified code lines is adjusted to not require active modification, that is, only the first non-compliant code line needs to be modified, and these passively modified code lines can be modified accordingly.

[0137] This can improve the non-compliant modification table, reduce the workload of subsequent developers when making code modifications, and improve work efficiency.

[0138] The present invention also provides a device for checking code standardization, as described in the following embodiments. Since the principle of solving the problem by the device is similar to that of a method for checking code standardization, the implementation of the device can refer to the implementation of a method for checking code standardization, and the repeated parts will not be repeated.

[0139] Reference Figure 6 A device for checking code compliance provided in an embodiment of the present invention includes: a first acquisition module 100, a second acquisition module 200, a determination module 300, and a judgment module 400.

[0140] The first acquisition module 100 is used to acquire problem files within a set time range, wherein the problem files are files containing problem codes, and the problem codes include existing problem codes and changed problem codes;

[0141] The second acquisition module 200 is used to acquire a change file within a set time range, wherein the change file is a file where the change code is located;

[0142] A determination module 300 is used to determine a file that is both the problem file and the change file as a target file; wherein the target file contains both the problem code and the change code;

[0143] A judgment module 400 is used to judge whether the number of problematic code lines of the target file within a set time range is less than or equal to a threshold of the target file;

[0144] If so, determining that the changed code in the target file complies with the specification;

[0145] If not, then

[0146] Determine problematic code lines in the target file that are within the set time range and not within the time range before the set time range as non-compliant code lines;

[0147] Determine a code line in the target file that is both a non-compliant code line and a changed code line as a first non-compliant code line;

[0148] The code lines of the target file that are non-compliant code lines and are not changed code lines are determined as second non-compliant code lines.

[0149] An embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-mentioned code compliance checking methods when executing the computer program.

[0150] Reference Figure 7 As shown, the above method for determining the correctness of an interface is run on a computer device 702. The computer device 702 may include one or more processors 704, such as one or more central processing units (CPUs) or graphics processing units (GPUs), each of which may implement one or more hardware threads. The computer device 702 may also include any memory 706, which is used to store any kind of information such as code, settings, data, etc. In a specific embodiment, a computer program on the memory 706 and that can be run on the processor 704, when the computer program is run by the processor 704, can execute instructions according to the above method. Non-limitingly, for example, the memory 706 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 702. In one embodiment, when the processor 704 executes the associated instructions stored in any memory or combination of memories, the computer device 702 can perform any operation of the associated instructions. The computer device 702 also includes one or more drive mechanisms 708 for interacting with any memory, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.

[0151] The computer device 702 may also include an input / output module 710 (I / O) for receiving various inputs (via input devices 712) and for providing various outputs (via output devices 714). A specific output mechanism may include a presentation device 716 and an associated graphical user interface 718 (GUI). In other embodiments, the input / output module 710 (I / O), input device 712, and output device 714 may not be included, and the computer device 702 may be used as a computer device in a network. The computer device 702 may also include one or more network interfaces 720 for exchanging data with other devices via one or more communication links 722. One or more communication buses 724 couple the components described above together.

[0152] The communication link 722 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 722 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.

[0153] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements any of the above-mentioned code standardization checking methods.

[0154] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements any of the above-mentioned code standardization checking methods.

[0155] In the embodiment of the present invention, compared with the technical solutions in the prior art, a target file is determined based on the problem files and changed files within a set time range, a threshold judgment is performed on the target file, and then non-compliant code lines are determined, and the non-compliant code lines are further subdivided to obtain two types of codes, namely, problem codes in newly added codes and / or changed existing codes, and codes that become problem codes from existing non-problem codes due to the generation of changed codes. This allows for quick and accurate compliance judgment of the code.

[0156] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0157] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0158] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0159] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0160] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for checking code standardization, characterized in that: include: Obtain a problem file within a set time range, wherein the problem file is a file containing a problem code, and the problem code includes an existing problem code and a changed problem code; Obtain the changed files within the set time range, where the changed files are files where the changed codes are located; Determine a file that is both the problem file and the changed file as a target file; The target file contains both the problem code and the changed code; Determine whether the number of problem code lines of the target file within a set time range is less than or equal to a threshold of the target file; the threshold of the target file is: the number of problem code lines of the target file within a time range before the set time range; If so, determining that the changed code in the target file complies with the specification; If not, then Determine problematic code lines in the target file that are within the set time range and not within the time range before the set time range as non-compliant code lines; Determine a code line in the target file that is both a non-compliant code line and a changed code line as a first non-compliant code line; The code lines of the target file that are non-compliant code lines and are not changed code lines are determined as second non-compliant code lines.

2. The method according to claim 1, characterized in that The changed files include newly added files and / or modified original files. Correspondingly, the changed code includes a newly added code and / or a modified existing code.

3. The method according to claim 1, characterized in that After determining that the changed code in the target file meets the specification, the following step is further included: If the number of problematic code lines of the target file within the set time range is less than the threshold of the target file, the threshold of the target file is updated to the number of problematic code lines.

4. The method according to claim 1, characterized in that After determining the code line of the target file that is a non-compliant code line and is not a changed code line as a second non-compliant code line, the following further comprises: Inputting the first non-compliant code line or the second non-compliant code line in the target file into a neural network model, and outputting the non-compliant type corresponding to the first non-compliant code line or the non-compliant type corresponding to the second non-compliant code line; Determine, according to the non-compliance modification table, a modification scheme corresponding to the non-compliance type; wherein the non-compliance modification table records the non-compliance type and the modification scheme corresponding to the non-compliance type; Combining the first non-compliant code line and the corresponding modification scheme to form first modification information; The second non-compliant code line and the corresponding modification scheme are combined to form second modification information.

5. The method according to claim 4, characterized in that After combining the second non-compliant code line and the corresponding modification scheme to form the second modification information, the method further includes: sorting the first modification information and the second modification information according to priorities, wherein the priority of the first modification information is higher than that of the second modification information; The sorted first modification information and the second modification information are sent to a developer, so that the developer can make modifications according to the sorting.

6. The method according to claim 5, characterized in that After sending the sorted first modification information and the second modification information to the developer so that the developer makes modifications according to the sorting, the following further includes: After the developer modifies the first non-compliant code line according to the modification plan in the first modification information, the current problematic code line of the target file is detected and obtained in real time; Calculate the number of lines of code that are reduced by the current number of problem lines of code in the target file compared to the number of problem lines of code within a set time range; Determining whether the reduced number of code lines is greater than the first number of non-compliant code lines; If so, then Determine the code line that is both the second non-compliant code line and the current problematic code line as the code line to be modified; Determine a modification plan corresponding to the code line to be modified, so that the developer can modify the code line to be modified according to the corresponding modification plan; If not, the developer is made to modify the first non-compliant code line according to the modification plan corresponding to the first modification information, or to modify the second non-compliant code line according to the modification plan corresponding to the second modification information.

7. The method according to claim 6, characterized in that If the reduced number of code lines is greater than the first number of non-compliant code lines, the method further includes: Determine the code line that is the second non-compliant code line and does not belong to the current problematic code line as a passively modified code line; determining a non-compliance type of the passively modified code line; The modification scheme corresponding to the non-compliant type of the passively modified code row in the non-compliant modification table is adjusted to not require active modification.

8. A device for checking code compliance, characterized in that: include: A first acquisition module is used to acquire a problem file within a set time range, wherein the problem file is a file containing a problem code, and the problem code includes an existing problem code and a changed problem code; A second acquisition module is used to acquire a change file within a set time range, wherein the change file is a file where the change code is located; A determination module, used for determining a file that is both the problem file and the changed file as a target file; The target file contains both the problem code and the changed code; A judgment module, used to judge whether the number of problematic code lines of the target file within a set time range is less than or equal to a threshold of the target file; The threshold of the target file is: the number of problem code lines of the target file within the time range before the set time range; If so, determining that the changed code in the target file complies with the specification; If not, then Determine problematic code lines in the target file that are within the set time range and not within the time range before the set time range as non-compliant code lines; Determine a code line in the target file that is both a non-compliant code line and a changed code line as a first non-compliant code line; The code lines of the target file that are non-compliant code lines and are not changed code lines are determined as second non-compliant code lines.

9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

11. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.