Code inspection method, system and device, medium and computer program product
Through the neural network-driven code inspection method, the problem of low adaptability and efficiency of code inspection in the existing technology is solved, and efficient and accurate code inspection and automated deployment are achieved to adapt to specific coding styles.
Patent Information
- Application Number
- CN202411268727.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-31
AI Technical Summary
Existing code checking methods rely on user-defined rules and are unable to learn and adapt to new programming patterns or error types, resulting in inadequacy and efficiency.
Adopt a neural network-based code inspection method, respond to the code inspection trigger conditions, determine the updated project code, perform static checks and unit checks, generate self-examination results, and perform automated deployment and operation results analysis after passing, and use the self-examination of the neural network. Learning characteristics improve adaptability.
It improves the efficiency and accuracy of code inspection, can adapt to the coding style of a specific project or team, customizes static inspection strategies, and improves the adaptability and automated deployment capabilities of code inspection.
Smart Images

Figure CN119226158A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software development, and in particular to a code checking method, system, device, medium and computer program product. Background Art
[0002] With the rapid development of the software industry, the demand for software is increasing, the software application environment is becoming increasingly complex, new businesses are emerging in an endless stream, old businesses are constantly iterating and updating, the software development team is getting larger and larger, and the developer level is uneven. Therefore, in order to ensure the quality of software development, it is necessary to conduct quality inspection on the code delivered by R&D.
[0003] Existing code checking methods or tools mainly rely on user-defined code checking rules, which are unable to self-learn and adapt to new programming patterns or error types. Manual updating and maintenance of checking rules are required, resulting in low adaptability and efficiency of code checking. Summary of the invention
[0004] The present invention provides a code checking method, system, device, medium and computer program product to solve the problems of low adaptability and low efficiency in the existing code checking methods.
[0005] According to one aspect of the present invention, there is provided a code checking method, the method comprising:
[0006] In response to a code check trigger condition, determining a project code to be updated;
[0007] Determine the target code module to be checked in the project code, and perform static check and unit check on the target code module based on the code check neural network to generate module self-check results;
[0008] When the module self-check result is passed, the project code is automatically deployed;
[0009] Based on the code checking neural network, the running results corresponding to the project code are analyzed to generate the project running result analysis results.
[0010] According to another aspect of the present invention, there is provided a code checking system, the system comprising:
[0011] A code update detection module, for determining the updated project code in response to a code check trigger condition;
[0012] The module self-check module is used to determine the target code module to be checked in the project code, and perform static check and unit check on the target code module based on the code check neural network to generate the module self-check result;
[0013] The package deployment module is used to automatically deploy the project code when the module self-check result is passed;
[0014] The project joint debugging module is used to analyze the running results corresponding to the project code based on the code inspection neural network and generate the project running result analysis results.
[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0016] at least one processor; and
[0017] a memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the code checking method described in any embodiment of the present invention.
[0019] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the code checking method described in any embodiment of the present invention when executed.
[0020] According to another aspect of the present invention, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the code checking method according to any embodiment of the present invention is implemented.
[0021] The technical solution of the embodiment of the present invention determines the updated project code by responding to the code inspection trigger condition; determines the target code module to be inspected in the project code, and performs static inspection and unit inspection on the target code module based on the code inspection neural network to generate a module self-inspection result; when the module self-inspection result is that the inspection is passed, the project code is automatically deployed; and the operation results corresponding to the project code are analyzed based on the code inspection neural network to generate a project operation result analysis result. This technical solution can improve the inspection efficiency and accuracy of the project code by performing static inspection and unit inspection on the target code module in the updated project code and analyzing the operation results corresponding to the project code through the code inspection neural network; at the same time, the self-learning characteristics of the code inspection neural network can be used to improve the adaptability of code inspection.
[0022] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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.
[0024] Figure 1 is a flowchart of a code checking method provided according to Embodiment 1 of the present invention;
[0025] Figure 2 is a flowchart of a code checking method provided according to Embodiment 2 of the present invention;
[0026] Figure 3 is a flowchart of a code checking method provided according to Embodiment 3 of the present invention;
[0027] Figure 4 is a structural diagram of a code checking system provided according to a fourth embodiment of the present invention;
[0028] Figure 5 It is a structural schematic diagram of an electronic device for implementing the code checking method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention 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 the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] Embodiment 1
[0032] Figure 1A flowchart of a code checking method is provided for the first embodiment of the present invention. This embodiment is applicable to checking codes during project development. The method can be executed by a code checking system. The code checking system can be implemented in the form of hardware and / or software. The code checking system can be configured in an electronic device. Figure 1 As shown, a code checking method provided in this embodiment includes the following steps:
[0033] S110 . In response to a code check triggering condition, determine the project code to be updated.
[0034] Among them, the code inspection trigger condition can be understood as the condition used to trigger the execution of the code inspection process, for example, it can include but is not limited to: automatic triggering at preset intervals, manual triggering by users (developers, testers, etc.) through visualization pages or code management tools, etc.
[0035] The updated project code may refer to the code that has been changed during the project development process, for example, it may be the project code after operations such as addition, modification, and deletion.
[0036] In an embodiment of the present invention, corresponding code check trigger conditions can be pre-configured according to actual application requirements, and then the code check system can continuously monitor whether the code check trigger condition is triggered, and after the condition is triggered, obtain the currently updated project code from the code storage location such as the code repository by comparing the project code version number.
[0037] S120, determining the target code module to be checked in the project code, and performing static check and unit check on the target code module based on the code check neural network to generate a module self-check result.
[0038] Among them, the target code module can be understood as a code module that is determined in the updated project code and subsequently self-checked. The target code module can be configured with different granularities, such as functions, methods, classes, or any other independent functional modules.
[0039] Static checking is a method of checking the code to find potential problems without executing the program. It analyzes the syntax, structure and style of the code, and applies predefined coding standards, programming language syntax rules and other programming information to find out the parts that may cause errors or potential problems. Static checking is an important part of the software development process. It can help developers find and fix problems early and improve code quality and maintainability.
[0040] Unit checking (testing) is a method of checking and verifying the smallest testable unit (such as a function) in a project code. It allows users to quickly verify whether each part of the project code works as expected, which helps to ensure the correctness, robustness and stability of the project code.
[0041] The module self-check result may refer to a code check result generated after static checking and unit checking are performed on the target code module. The module self-check result may include: a static checking result and a unit checking result.
[0042] In an embodiment of the present invention, after determining that the project code has been updated, the code inspection system can compare and analyze the currently updated project code with the project code that was submitted last and passed the code inspection, and determine the target code module that has been updated, such as the updated function; then the target code module is input into the pre-trained code inspection neural network for static inspection to check whether the target code module has errors such as non-compliance with coding specifications, resource leakage, array access out of bounds, null pointer reference, etc., and generate corresponding static inspection results; then the code inspection neural network is called to generate the use case configuration parameters of the test case corresponding to the target code module, such as the number of parameters required for the target code module to be tested, the parameter type, the specific location of the parameter when calling, etc., so that the user can write the test case corresponding to the target code module based on the above-mentioned use case configuration parameters, and then test the corresponding target code module according to the test case to determine whether the target code module has been run through, whether there are running errors and warnings, etc., and generate corresponding unit inspection results; finally, according to the static inspection results and unit inspection results corresponding to the target code module, the corresponding module self-inspection results are determined. Furthermore, if the module self-check passes, the subsequent code check process will be executed; if the module self-check fails, the subsequent code check process will be terminated, and the specific reasons for failure and modification suggestions will be fed back to the user, so that the user can modify and update the project code again based on the above specific reasons and modification suggestions.
[0043] S130. When the module self-check result is passed, the project code is automatically deployed.
[0044] In an embodiment of the present invention, when the updated project code passes the module self-check, it will enter the packaging and deployment stage, that is, the code inspection system can automatically deploy the project code after the module self-check passes. In a specific embodiment, the automatic deployment of the project code can be achieved by calling tools such as Jenkins, GitLab CI / CD, Ansible, etc.
[0045] S140, analyzing the operation results corresponding to the project code based on the code inspection neural network, and generating project operation result analysis results.
[0046] In an embodiment of the present invention, after the project code is deployed, the project joint debugging stage will be entered. In the project joint debugging stage, this embodiment will focus on the log output of the project code during operation, such as locating and analyzing the error information in the log, and analyzing the actual operation results of the project with the expected target operation results, etc. Specifically, the code checking system can monitor the logs output by the project code during operation in real time, and then determine the error information in the output logs through methods including but not limited to keyword matching, and then input the error information into the code checking neural network to determine the code line corresponding to the error information and trace the source of the error. At the same time, the error information can also be classified, for example, it can be classified into configuration problems, code writing problems, unclear requirements, etc.; in addition, the progress of the project operation can be understood by analyzing the logs, and then the expected target operation results of the current project can be determined by using the code checking neural network in combination with the project requirements. At the same time, the corresponding automated test script can be generated, and the actual project operation results obtained by testing the test script are compared with the expected target operation results. If the two are consistent, it indicates that the project test has passed, otherwise, it indicates that there is a deviation in the project operation result, and the code checking neural network can continue to be called to locate the code line with the deviation in the project code, so that the user can modify and update the project code again.
[0047] The technical solution of the embodiment of the present invention determines the updated project code by responding to the code inspection trigger condition; determines the target code module to be inspected in the project code, and performs static inspection and unit inspection on the target code module based on the code inspection neural network to generate a module self-inspection result; when the module self-inspection result is that the inspection is passed, the project code is automatically deployed; and the operation results corresponding to the project code are analyzed based on the code inspection neural network to generate a project operation result analysis result. This technical solution can improve the inspection efficiency and accuracy of the project code by performing static inspection and unit inspection on the target code module in the updated project code and analyzing the operation results corresponding to the project code through the code inspection neural network; at the same time, the self-learning characteristics of the code inspection neural network can be used to improve the adaptability of code inspection.
[0048] Furthermore, based on the above-mentioned embodiments of the invention, this embodiment provides a code checking method, further comprising:
[0049] Receive user feedback on module self-check results and project operation result analysis results, and update the code checking neural network based on the feedback information.
[0050] In an embodiment of the present invention, when the module self-check result and the project operation result analysis result show that the check failed, the user can manually analyze and solve the problem based on the specific reasons for the failure to pass the check, modification suggestions, error code lines and other information fed back by the code checking system, and send the corresponding feedback information to the code checking system, and then the code checking system can update the code checking neural network based on the above feedback information to optimize the neural network performance; wherein the feedback information may include but is not limited to the following newly added or modified by the user: static check rules, project coding specifications, project requirements, log monitoring keywords, classification types of log error information, modification suggestions for project codes, etc.
[0051] Embodiment 2
[0052] Figure 2 The flowchart of a code checking method provided in the second embodiment of the present invention is further optimized and expanded based on the above implementation, and can be combined with various optional technical solutions in the above implementation. Figure 2 As shown, a code checking method provided in the second embodiment specifically includes the following steps:
[0053] S210: Obtaining a version number of a project code detected by a preset version management tool at preset time intervals.
[0054] The preset time period can be understood as a time period configured for the code checking system to detect whether the project code has been updated. It can be understood that the preset time period can be set according to actual project requirements, for example, according to the actual update frequency of the project code. For example, the preset time period may not be limited to: 10 minutes, 24 hours, 7 days, etc. The preset version management tool may refer to a tool for efficiently managing project code versions, which may include but is not limited to: git, svn, gitee, github, gitlib and other tools.
[0055] In an embodiment of the present invention, the code checking system can call a preset version management tool such as git to scan the project code in the preset code repository according to a pre-configured preset time period, thereby obtaining the version number corresponding to the project code.
[0056] S220. When the version number changes, the currently updated project code is obtained from a preset code repository.
[0057] Among them, the preset code repository may refer to a centralized or distributed storage space used to store, manage, track and control project code changes.
[0058] In an embodiment of the present invention, when the code checking system detects that the version number corresponding to the project code has changed, the currently updated project code, that is, the project code currently submitted by the user, can be obtained from the preset code repository.
[0059] S230: Compare and analyze the currently updated project code with the project code that passed the code check last time to determine the target change code.
[0060] The target changed code may refer to the code that has been changed in the currently submitted project code, for example, the code may be the code after operations such as addition, modification, and deletion.
[0061] In the embodiment of the present invention, the code checking system may compare and analyze the currently submitted project code with the last submitted project code that passed the code checking, and determine the changed code in the currently updated project code, ie, the target changed code.
[0062] S240. Locate a target code module in the target change code; wherein the target code module at least includes: a target test function.
[0063] In an embodiment of the present invention, before performing module self-check on the target change code, the module that needs self-check, i.e., the target code module, can be determined first, wherein the target code module at least includes: a target test function, i.e., the smallest unit of self-check can be a function. In a specific embodiment, the target test function can be located in the target change code by means including but not limited to various code analysis tools.
[0064] S250, input the target test function into the code inspection neural network for static inspection, and generate a static inspection result.
[0065] In an embodiment of the present invention, a pre-trained code inspection neural network can be called to perform a static inspection on the target test function to check whether the target test function has errors such as non-compliance with coding standards, resource leakage, array access out of bounds, null pointer reference, etc., and generate corresponding static inspection results; wherein the static inspection results may include: whether the static inspection has passed, and information such as the inspection items that have not passed the static inspection.
[0066] S260, calling code to check the target test case configuration parameters corresponding to the target test function generated by the neural network.
[0067] Among them, the target test case configuration parameters can be understood as the relevant configuration parameters of the subsequent target test function corresponding to the target test case, for example, it can include but is not limited to: the number of parameters required by the target test function, parameter type, specific location of the parameters when calling, and other information.
[0068] In an embodiment of the present invention, the deep semantic fusion code can be called to check the target test case configuration parameters corresponding to the target test case generated by the neural network, so that the user can then write the corresponding target test case according to the target test case configuration parameters.
[0069] S270, testing the target test function according to the target test case to generate a unit inspection result; wherein the target test case is written and generated by the user according to the target test case configuration parameters.
[0070] In an embodiment of the present invention, before performing a unit check on a target test function, a user first generates a corresponding target test case according to the target test case configuration parameters provided by the code check neural network, and then the code check system can test the target test function according to the target test case to determine whether the target test function has been run successfully, whether there are any running errors and warnings, and generate corresponding unit check results at the same time; wherein the unit check results may include information such as whether the unit check has been passed, and the reasons for failing the unit check.
[0071] S280. When both the static inspection result and the unit inspection result are inspection passed, the module self-inspection result is determined as inspection passed; otherwise, the module self-inspection result is determined as inspection failed, and the reasons for the inspection failure and modification suggestions are fed back.
[0072] In an embodiment of the present invention, after performing static inspection and unit inspection on each target test function respectively, the code inspection system can determine the corresponding module self-inspection result based on the corresponding static inspection result and unit inspection result. Specifically, if the static inspection results and unit inspection results corresponding to all target test functions are all passed, the module self-inspection result is determined as passed; otherwise, the module self-inspection result is determined as failed, and the specific reasons for the failure of the module self-inspection and corresponding modification suggestions are fed back to the user through channels including but not limited to visualization pages, code management tools, etc., so that the user can modify and update the project code again.
[0073] S290. When the module self-check result is passed, a preset automatic deployment tool is called to automatically deploy the project code that has passed the module self-check.
[0074] Among them, the preset automated deployment tool may refer to a pre-configured tool for automatically packaging and deploying project codes that have passed module self-inspection, such as but not limited to: Jenkins, GitLab CI / CD, Ansible and other tools.
[0075] In an embodiment of the present invention, after the updated project code passes the module self-check, it will enter the packaging and deployment stage. At this time, the code inspection system can realize automatic packaging and deployment of the project code by calling preset automated deployment tools such as but not limited to Jenkins.
[0076] S2100. Obtain the log generated during the execution of the project code, and use the preset monitoring keywords to determine the error information in the log.
[0077] The preset monitoring keywords may refer to keywords used for key monitoring in the log, for example, may include but are not limited to: error, success, STEP1, failed, etc.
[0078] In an embodiment of the present invention, after the project code is deployed, the project joint debugging stage will be entered. In the project joint debugging stage, this embodiment will focus on the log output of the project code during operation and determine the error information in the log. Specifically, in the project deployment stage, the log output can be redirected to a unified file. The code inspection system can use various preset monitoring keywords to monitor the log information in the log file in real time, and when error keywords such as error and failed are detected, the error information can be determined in the output log, for example, the log line where the error occurs can be located.
[0079] S2110, input the error information into the code checking neural network, and output the classification result corresponding to the error information.
[0080] In an embodiment of the present invention, the error information located in the log can be input into a pre-trained code checking neural network. The code checking neural network will locate the corresponding code line in the project code and trace the source of the error (such as the error function, etc.) according to the input error information. At the same time, the code checking neural network can also classify the error information and output the corresponding classification results; wherein the classification results may include but are not limited to: configuration problems, code writing problems, unclear requirements, etc.
[0081] S2120. Determine the project operation progress in the log, and input the project operation progress and preset project requirements into the code inspection neural network to generate corresponding target project operation results and target test scripts.
[0082] The project operation progress may refer to the operation progress or operation status corresponding to the project code. The preset project requirements may refer to the expected results or status set for each step in the project code. For example, a preset project requirement may be: in STEP2, 2048 soft links need to be created under a local path A, and path A needs to be configured in configuration item C of configuration file B.
[0083] In an embodiment of the present invention, the code checking system can also analyze the running results (running effects) of the project based on the output log. Specifically, the execution path of the project code, that is, the project running progress, can be determined by methods including but not limited to inserting log recording statements at key positions in the project code in advance; then, the current project running progress and the pre-configured preset project requirements for the current project running progress are input into the code checking neural network together. After being processed by the code checking neural network, the expected target project running results and the corresponding target test script under the current project running progress are output.
[0084] S2130. Test the project code according to the target test script and generate the corresponding actual project operation results.
[0085] In an embodiment of the present invention, the code checking system can perform automated testing on the project code according to the target test script provided by the code checking neural network to determine the actual running effect of the project code under the current running progress, that is, the actual project running result.
[0086] S2140. When the actual project running result is consistent with the target project running result, the project running result analysis result is determined as the test passed. Otherwise, the project running result analysis result is determined as the running result has deviations. At the same time, the code checking neural network is called to locate the target code line with deviations in the project code.
[0087] In an embodiment of the present invention, after the execution of the target test script is completed, the code checking system can compare the generated actual project running results with the expected target project running results. If the two are consistent, it indicates that the project test has passed. Otherwise, the project running result analysis result is determined as a deviation in the running result. At the same time, the code checking neural network can continue to be called to locate the code line with the deviation in the project code, so that the user can modify and update the project code again.
[0088] The technical solution of the embodiment of the present invention is to trigger the module self-check of the updated code after monitoring the project code update, that is, call the code check neural network to perform static check and unit check on the target test function respectively; after the module self-check, call the preset automatic deployment tool to automatically deploy the project code that passes the module self-check; then call the code check neural network to analyze the log of the project code during operation, realize the location of log error information and deviation analysis of project operation results, which can improve the inspection efficiency and accuracy of the project code; at the same time, use the self-learning characteristics of the code check neural network to adapt to the coding style of a specific project or team, customize a specific code static check strategy, and improve the adaptability of code inspection.
[0089] Embodiment 3
[0090] Figure 3 This is a flowchart of a code checking method provided in Embodiment 3 of the present invention. Based on the above embodiments, this embodiment provides an implementation of a code checking method, which can realize automatic checking of project codes. Figure 3 As shown, a code checking method provided by Embodiment 3 of the present invention specifically includes the following steps:
[0091] S310. Code update.
[0092] In an embodiment of the present invention, after the user completes the update of the project code, the project code in the preset code repository can be scanned by preset version management tools such as but not limited to git, svn, gitee, github, gitlib, etc., so as to detect whether there is a new version number in the project.
[0093] S3201, trigger module self-check.
[0094] In an embodiment of the present invention, a detection strategy can be set for this step, for example, the version number of the project code is detected every 10 minutes and compared with the previous version number. If there is a difference, it means that the code has been updated and the next step of module self-check is triggered.
[0095] S330, module self-check.
[0096] In the embodiment of the present invention, when entering this step, the module that needs to be self-checked is first identified, and the minimum unit of self-checking is a function. To identify the content of the self-check, the difference between the last tested version and the current version needs to be compared, and then the corresponding function is found in the latest code for further testing.
[0097] S3301. Function static check.
[0098] In the embodiment of the present invention, the check contents of the function static check may include but are not limited to: whether there is non-compliance with the coding standard (whether there are comments in the function, whether the naming rules of the intermediate variables are standardized, whether the legality of the formal parameters is judged), resource leakage, array access out of bounds, null pointer reference, etc. After the deep semantic fusion code check neural network fully understands the programming information such as the coding standard and the programming language grammar rules in the project, it can be called to parse the program source code text information to generate the corresponding static check results.
[0099] S3302, module unit inspection.
[0100] In an embodiment of the present invention, a deep semantically fused code inspection neural network can be called to generate target test case configuration parameters corresponding to the target test case, which may include but is not limited to: the number of parameters required for the target test function, the parameter type, the specific location of the parameters when calling, and other information; then, the code inspection system can test the target test function according to the target test case to determine whether the target test function has passed the operation, whether there are any operation errors and warnings, and other information, and generate corresponding unit inspection results.
[0101] S3202. If the module self-check fails, modify the code again.
[0102] In an embodiment of the present invention, feedback can be provided to functions that fail self-check, and the specific reasons for failure and modification suggestions can be output, or a new version can be generated, so that the user can complete the modification and generate a new submission as quickly as possible.
[0103] S340, package and deploy.
[0104] In an embodiment of the present invention, after the updated project code passes the module self-check, it will enter the packaging and deployment stage. At this time, the code inspection system can realize automatic packaging and deployment of the project code by calling preset automated deployment tools such as but not limited to Jenkins.
[0105] S350: Analyze the operation results.
[0106] In an embodiment of the present invention, after the project code is deployed, the project joint debugging stage will be entered. In the project joint debugging stage, this embodiment will focus on the log output of the project code during operation, such as locating and analyzing the error information in the log, and analyzing the actual operation results of the project with the expected target pre-operation results, etc.
[0107] S3501. Analysis of error information.
[0108] In an embodiment of the present invention, the log output can be redirected to a unified file during the project deployment phase, and the code inspection system can call a pre-configured monitor to monitor the content of the log file output by the project in real time. It is not limited to monitoring some keywords, such as error, success, STEP1, etc. When an error message appears, the code inspection system can access the code inspection neural network to reflect all error messages. The code detection neural network locates the log line where the error appears and traces the source of the error based on the error message, and reflects and classifies the problems, which are not limited to the following categories: configuration problems, code writing problems, unclear requirements, etc. Users need to provide feedback to the code detection neural network at this stage to further strengthen the code inspection neural network's understanding of semantics.
[0109] S3502. Operation deviation analysis.
[0110] In an embodiment of the present invention, the progress of the project code operation can be known in combination with the log, and the code inspection neural network with deep semantic fusion adds training for the ability to understand project requirements. The code inspection system can access the code inspection neural network to reflect the progress of the project operation. The code inspection neural network combines the project requirements to feedback to the system the target project operation results that the current project should have and provides an automated test script; for example, the words STEP2 success appear in the log. According to the project requirements, 2048 soft links need to be created under a local path A in STEP2, and path A needs to be configured in configuration item C of configuration file B. Then the automated test script will find the value of configuration item C from configuration file B to obtain the path name, and check whether the number of files under the corresponding path A meets 2048, and whether the file type is a soft link. After the system runs the automated operation script, the operation results can be fed back to the code inspection neural network to further strengthen the neural network's understanding of project requirements and the process of creating automated test scripts.
[0111] S360. If there is a deviation in the running result, modify the code again.
[0112] In an embodiment of the present invention, after the execution of the target test script is completed, the code checking system can compare the generated actual project running results with the expected target project running results. If the two are inconsistent, it means that there is a deviation in the running results, and the reasons for failure and modification suggestions can be output, so that the user can complete the modification as soon as possible and generate a new submission.
[0113] The technical solution of the embodiment of the present invention may at least include the following beneficial effects: ① It can adapt to the coding style of a specific project or team and customize a specific code static inspection strategy; ② It utilizes the semantic depth understanding of the code inspection neural network to improve the adaptability to project requirements; ③ It can monitor the abnormal error information and project operation effects in the project joint debugging stage in real time, accurately locate the causes of abnormal errors, and provide corresponding code modification suggestions, thereby effectively improving the inspection efficiency and accuracy of the project code, as well as improving the project development efficiency; ④ Combined with the deep understanding of semantics, the unsatisfactory error information and project operation results can be traced, and the problems in different links such as deployment, configuration, coding, and demand analysis can be analyzed and assisted in locating.
[0114] Embodiment 4
[0115] Figure 4 This is a schematic diagram of the structure of a code checking system provided by Embodiment 4 of the present invention. Figure 4 As shown, the system includes:
[0116] A code update detection module 41, for determining the project code to be updated in response to a code check trigger condition;
[0117] A module self-check module 42 is used to determine a target code module to be checked in the project code, and perform static check and unit check on the target code module based on the code check neural network to generate a module self-check result;
[0118] The packaging and deployment module 43 is used to automatically deploy the project code when the module self-check result is passed;
[0119] The project joint debugging module 44 is used to analyze the operation results corresponding to the project code based on the code inspection neural network and generate project operation result analysis results.
[0120] The technical solution of the embodiment of the present invention determines the updated project code in response to the code inspection trigger condition through the code update detection module; the module self-inspection module determines the target code module to be inspected in the project code, and performs static inspection and unit inspection on the target code module based on the code inspection neural network to generate the module self-inspection result; the packaging and deployment module automatically deploys the project code when the module self-inspection result is inspection passed; the project joint debugging module analyzes the operation results corresponding to the project code based on the code inspection neural network to generate the project operation result analysis result. This technical solution can improve the inspection efficiency and accuracy of the project code by performing static inspection and unit inspection on the target code module in the updated project code and analyzing the operation results corresponding to the project code through the code inspection neural network; at the same time, the self-learning characteristics of the code inspection neural network are used to improve the adaptability of code inspection.
[0121] Further, based on the above-mentioned embodiment of the invention, the code update detection module 41 includes:
[0122] A version number acquisition unit, used to acquire the version number of the project code detected by a preset version management tool at every preset time period;
[0123] The project code acquisition unit is used to obtain the currently updated project code from the preset code repository when the version number changes.
[0124] Further, based on the above-mentioned embodiment of the invention, the module self-check module 42 includes:
[0125] A target change code determination unit is used to compare and analyze the currently updated project code with the project code that passed the code check last time to determine the target change code;
[0126] The target code module locating unit is used to locate the target code module in the target change code; wherein the target code module at least includes: a target test function;
[0127] A static inspection unit, used for inputting a target test function into a code inspection neural network for static inspection and generating a static inspection result;
[0128] A case configuration parameter generation unit, used for calling the code to check the target test case configuration parameters corresponding to the target test function generated by the neural network;
[0129] The unit inspection unit is used to test the target test function according to the target test case and generate the unit inspection result; wherein the target test case is written and generated by the user according to the target test case configuration parameters;
[0130] The module self-inspection result determination unit is used to determine the module self-inspection result as passed when both the static inspection result and the unit inspection result are passed; otherwise, the module self-inspection result is determined as failed, and the reasons for the failed inspection and modification suggestions are fed back.
[0131] Further, based on the above-mentioned embodiment of the invention, the packaging and deployment module 43 includes:
[0132] The automated deployment unit is used to call a preset automated deployment tool to automatically deploy the project code that has passed the module self-check when the module self-check result is passed.
[0133] Further, based on the above-mentioned embodiment of the invention, the project joint debugging module 44 includes:
[0134] An error information determination unit, used to obtain a log generated during the execution of the project code, and determine the error information in the log using a preset monitoring keyword;
[0135] An error classification unit, used to input the error information into the code checking neural network and output the classification result corresponding to the error information;
[0136] A test script generation unit, used to determine the project operation progress in the log, and input the project operation progress and preset project requirements into the code inspection neural network to generate the corresponding target project operation results and target test scripts;
[0137] The test unit is used to test the project code according to the target test script and generate the corresponding actual project operation results;
[0138] The operation result analysis unit is used to determine the project operation result analysis result as a test pass when the actual project operation result is consistent with the target project operation result; otherwise, the project operation result analysis result is determined as an operation result with deviation, and at the same time, the code checking neural network is called to locate the target code line with deviation in the project code.
[0139] Furthermore, based on the above-mentioned embodiment of the invention, the code checking system further includes:
[0140] The neural network update module is used to receive user feedback on module self-check results and project operation result analysis results, and update the code checking neural network according to the feedback information.
[0141] The code checking system provided in the embodiment of the present invention can execute the code checking method provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0142] Embodiment 5
[0143] Figure 5 A schematic diagram of an electronic device 50 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0144] like Figure 5 As shown, the electronic device 50 includes at least one processor 51, and a memory connected to the at least one processor 51 in communication, such as a read-only memory (ROM) 52, a random access memory (RAM) 53, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 51 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 52 or the computer program loaded from the storage unit 58 to the random access memory (RAM) 53. In the RAM 53, various programs and data required for the operation of the electronic device 50 can also be stored. The processor 51, the ROM 52, and the RAM 53 are connected to each other via a bus 54. An input / output (I / O) interface 55 is also connected to the bus 54.
[0145] A number of components in the electronic device 50 are connected to the I / O interface 55, including: an input unit 56, such as a keyboard, a mouse, etc.; an output unit 57, such as various types of displays, speakers, etc.; a storage unit 58, such as a disk, an optical disk, etc.; and a communication unit 59, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 59 allows the electronic device 50 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0146] The processor 51 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 51 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 51 executes the various methods and processes described above, such as the code checking method.
[0147] In some embodiments, the code inspection method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 58. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 50 via the ROM 52 and / or the communication unit 59. When the computer program is loaded into the RAM 53 and executed by the processor 51, one or more steps of the code inspection method described above may be performed. Alternatively, in other embodiments, the processor 51 may be configured to perform the code inspection method in any other suitable manner (e.g., by means of firmware).
[0148] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0149] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0150] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0151] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0152] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0153] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[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 is used to implement the code checking method described in any embodiment of the present invention.
[0155] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0156] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A code checking method, characterized in that: The method comprises: In response to a code check trigger condition, determining a project code to be updated; Determine a target code module to be checked in the project code, and perform static check and unit check on the target code module based on a code check neural network to generate a module self-check result; When the module self-check result is passed, automatically deploy the project code; The operation result corresponding to the project code is analyzed based on the code checking neural network to generate a project operation result analysis result.
2. The method according to claim 1, characterized in that The step of determining the updated project code in response to the code check trigger condition comprises: At each preset time period, obtaining the version number of the project code detected by a preset version management tool; When the version number changes, the project code that is currently being updated is obtained from a preset code repository.
3. The method according to claim 1, characterized in that The step of determining a target code module to be checked in the project code, and performing static checking and unit checking on the target code module based on a code checking neural network to generate a module self-check result includes: Compare and analyze the currently updated project code with the project code that passed the code check last time to determine the target change code; Locating the target code module in the target change code; wherein the target code module at least includes: a target test function; Inputting the target test function into the code checking neural network for static checking and generating a static checking result; Calling the code to check the target test case configuration parameters corresponding to the target test function generated by the neural network; Testing the target test function according to the target test case to generate a unit inspection result; wherein the target test case is written and generated by the user according to the target test case configuration parameters; When both the static inspection result and the unit inspection result are inspection passed, the module self-inspection result is determined as inspection passed; otherwise, the module self-inspection result is determined as inspection failed, and the reasons for the inspection failure and modification suggestions are fed back.
4. The method according to claim 1, characterized in that: When the module self-check result is that the check is passed, the project code is automatically deployed, including: When the module self-check result is that the check is passed, a preset automatic deployment tool is called to automatically deploy the project code that passes the module self-check.
5. The method according to claim 1, characterized in that The code checking neural network is used to analyze the operation result corresponding to the project code to generate a project operation result analysis result, including: Obtaining the log generated during the execution of the project code, and using the preset monitoring keywords to determine the error information in the log; Inputting the error information into the code checking neural network, and outputting the classification result corresponding to the error information; Determine the project operation progress in the log, and input the project operation progress and preset project requirements into the code inspection neural network to generate corresponding target project operation results and target test scripts; Testing the project code according to the target test script to generate corresponding actual project running results; When the actual project running result is consistent with the target project running result, the project running result analysis result is determined as a test pass; otherwise, the project running result analysis result is determined as a running result deviation, and the code checking neural network is called to locate the target code line with the deviation in the project code.
6. The method according to claim 1, characterized in that Also includes: Receive user feedback information on the module self-check result and the project operation result analysis result, and update the code check neural network according to the feedback information.
7. A code checking system, characterized in that: The system comprises: A code update detection module, for determining the updated project code in response to a code check trigger condition; A module self-check module, used for determining a target code module to be checked in the project code, and performing a static check and a unit check on the target code module based on a code check neural network to generate a module self-check result; A packaging and deployment module, used for automatically deploying the project code when the module self-check result is passed; The project joint debugging module is used to analyze the operation results corresponding to the project code based on the code checking neural network and generate project operation result analysis results.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the code checking method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the code checking method according to any one of claims 1 to 6 when executed.
10. 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 computer program implements the code checking method according to any one of claims 1 to 6.
Citation Information
Cited By
SoC integration quality inspection system
CN121501689A
