Code grade evaluation method and device, storage medium and electronic equipment

By optimizing and analyzing the original code, the problem of inaccurate and subjective code quality evaluation in the prior art is solved, and a more accurate and efficient code quality evaluation is achieved.

CN119621515AActive Publication Date: 2025-03-14HANGZHOU HAILIANG DIGITAL TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510147850.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-11
Publication Date
2025-03-14
Estimated Expiration
2045-02-11

AI Technical Summary

Technical Problem

In the prior art, code quality evaluation tools can only conduct simple syntax and rule checks, resulting in inaccurate evaluation results, and rely on the developer's experience and preferences, and are vulnerable to subjective influence.

Method used

By optimizing the original code, the corrected code is obtained; the code difference between the original code and the corrected code is determined; based on the code difference, the corrected code level of the corrected code is determined, and the corrected code level is pushed to the object.

Benefits of technology

Code quality evaluation is carried out through code differences, reducing the influence of subjective factors and improving the accuracy and efficiency of code quality evaluation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621515A_ABST
    Figure CN119621515A_ABST
Patent Text Reader

Abstract

The invention provides a code grade evaluation method and device, a storage medium and electronic equipment. The method comprises the steps that an original code of a first object is optimized, and a correction code corresponding to the original code is obtained; determining a code difference degree between the original code and the correction code; and determining the correction code grade of the correction code based on the code difference degree, pushing the correction code grade to the first object, performing code quality evaluation through the code difference degree to reduce the influence of subjective factors, and improving the accuracy and efficiency of code quality evaluation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a code level assessment method, device, storage medium and electronic device. Background Art

[0002] In the field of software development, programmer code quality assessment is an important part of ensuring software stability and performance. However, as software scale and complexity continue to increase, the difficulty of accurately assessing code quality is also increasing.

[0003] At present, most of the code quality assessment tools in the related art conduct quantitative assessment of the quality of the code by analyzing the syntax, structure, naming conventions, etc. of the code. However, the code quality assessment tools in the related art can only perform simple syntax and rule checks, resulting in inaccurate assessment results. At the same time, the code quality assessment in the related art relies on the experience and preferences of the developer, which is easily affected by subjectivity, making the assessment results somewhat subjective. Summary of the invention

[0004] The present invention provides a code level evaluation method, device, storage medium and electronic device.

[0005] According to a first aspect of the present disclosure, a code level assessment method is provided, the method comprising: optimizing the original code of a first object to obtain a revised code corresponding to the original code; determining the code difference between the original code and the revised code; based on the code difference, determining the revised code level of the revised code, and pushing the revised code level to the first object.

[0006] In some embodiments of the present disclosure, the original code of the first object is optimized to obtain a corrected code corresponding to the original code. Before that, the method includes: obtaining a real-time input code of the first object; determining an abnormal code in the real-time input code; determining an initial correction suggestion corresponding to the abnormal code, and providing an initial correction prompt to the first object, so that the first object corrects the real-time input code based on the initial correction prompt to obtain the original code.

[0007] In some embodiments of the present disclosure, the original code of the first object is optimized to obtain a revised code corresponding to the original code, including: determining the evaluation results of the original code under multiple evaluation indicators, wherein the multiple evaluation indicators include code complexity, code repetition rate, code coverage rate, code style inconsistency ratio, code review feedback score, code safety rate, and code team assistance score; determining a comprehensive evaluation result of the original code based on the evaluation result and a preset weight corresponding to each evaluation indicator; comparing the comprehensive evaluation result with a preset scoring threshold, and determining an original code grade of the original code based on the comparison result, the original code grade including excellent grade, medium grade and poor grade; based on the original code grade of the original code, optimizing the original code of the first object to obtain a revised code.

[0008] In some embodiments of the present disclosure, the original code of the first object is optimized based on the original code level of the original code to obtain a corrected code, including: if the original code level is a medium level or a poor level, the weak content pre-marked in the original code is detected to determine the area to be corrected; based on the area to be corrected, a first correction suggestion is generated, and the original code is optimized based on the first correction suggestion to obtain a corrected code.

[0009] In some embodiments of the present disclosure, determining the code difference between an original code and a revised code includes: performing decomposition operations on the original code and the revised code respectively, constructing a first abstract grammar network corresponding to the original code and a second abstract grammar network corresponding to the revised code, the first abstract grammar network including a first code element corresponding to the original code, and the second abstract grammar network including a second code element corresponding to the revised code; constructing a dynamic programming table based on the first code element and the second code element; determining the longest common subsequence based on the dynamic programming table; determining the difference elements in the first code element and the second code element based on the longest common subsequence, and marking the difference elements to obtain a difference label; determining the difference distance between the first code element and the second code element; and determining the code difference based on the difference label and the difference distance in combination with a preset graph convolutional neural network.

[0010] In some embodiments of the present disclosure, based on the difference label and the difference distance, in combination with a preset graph convolutional neural network, determining the code difference degree includes: using the difference label and the difference distance as inputs of the preset graph convolutional neural network, and using the first hidden layer and the second hidden layer in the preset graph convolutional neural network to determine the code difference degree; The first hidden layer is formula 1: Formula 1 in, is the adjacency matrix of the graph data with self-connection, D is the degree matrix, is the normalized adjacency matrix; W(0) is the weight matrix of the first hidden layer.

[0011] The second hidden layer is formula 2: Formula 2 in, is the adjacency matrix of the graph data with self-connection, D is the degree matrix, is the normalized adjacency matrix, and W(1) is the weight matrix of the second hidden layer.

[0012] In some embodiments of the present disclosure, based on the code difference, determining the correction code level of the correction code includes: comparing the code difference and a preset difference threshold, and determining the correction code level of the correction code based on the comparison result, the correction code level including excellent level, medium level and poor level.

[0013] According to a second aspect of the present disclosure, there is provided a code level evaluation device, the device comprising: An optimization unit, configured to optimize the original code of the first object to obtain a modified code corresponding to the original code; A determination unit, used for determining the code difference between the original code and the revised code; The evaluation unit is used to determine a correction code level of the correction code based on the code difference, and push the correction code level to the first object.

[0014] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method of the first aspect is implemented.

[0015] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the method of the first aspect is implemented when the processor executes the computer program.

[0016] The code level evaluation method provided by the present disclosure optimizes the original code of a first object to obtain a revised code corresponding to the original code; determines the code difference between the original code and the revised code; based on the code difference, determines the revised code level of the revised code, and pushes the revised code level to the first object. Code quality evaluation is performed through code difference to reduce the influence of subjective factors and improve the accuracy and efficiency of code quality evaluation.

[0017] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. Figure 1 A flowchart of a code level evaluation method provided by an embodiment of the present disclosure; Figure 2 A flowchart of another code level evaluation method provided by an embodiment of the present disclosure; Figure 3 A flowchart of another code level evaluation method provided by an embodiment of the present disclosure; Figure 4 A flowchart of another code level evaluation method provided by an embodiment of the present disclosure; Figure 5 A schematic diagram of the structure of a code level evaluation device provided by an embodiment of the present disclosure; Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0019] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0020] In the field of software development, programmer code quality assessment is an important part of ensuring software stability and performance. However, as software scale and complexity continue to increase, the difficulty of accurately assessing code quality is also increasing.

[0021] At present, most of the code quality assessment tools in related technologies conduct quantitative assessment of code quality by analyzing the syntax, structure, naming conventions, etc. of the code. However, the code quality assessment tools in related technologies can only perform simple syntax and rule checks, resulting in inaccurate assessment results. At the same time, the code quality assessment in related technologies relies on the experience and preferences of developers and is easily affected by subjectivity, making the assessment results somewhat subjective.

[0022] In order to solve the problems in the related technology, the code level evaluation method proposed in the present invention optimizes the original code of the first object to obtain the revised code corresponding to the original code; determines the code difference between the original code and the revised code; based on the code difference, determines the revised code level of the revised code, and pushes the revised code level to the first object, thereby improving the accuracy and efficiency of code quality evaluation, reducing the influence of subjective factors by performing code quality evaluation through code difference, achieving more accurate reflection of the actual quality level of the code, and providing more scientific and comprehensive support for code quality management in the software development process.

[0023] The following describes the code level evaluation method, device, electronic device, storage medium and computer program product of the embodiments of the present disclosure with reference to the accompanying drawings.

[0024] Figure 1 The following is a flow chart of a code level evaluation method provided by an embodiment of the present disclosure. Figure 1 As shown, the method includes: Step 101: Optimize the original code of the first object to obtain a modified code corresponding to the original code.

[0025] In some embodiments, the original code in the present disclosure can be stored in various places, such as a version control system (such as Git), a code library, a development environment, or a file provided from a first object. The first object in the present disclosure can refer to the owner, developer, etc. of the code.

[0026] To obtain the original code publicly, we first need to clarify the location where the original code is stored and how to access it, and ensure that we have sufficient permissions to access and extract the original code.

[0027] After determining the storage location and access method of the original code and having the access rights to the original code, the present disclosure can use appropriate tools (such as Git clone, FTP download, export from the development environment, etc.) to extract the original code.

[0028] After obtaining the original code of the first object, the present disclosure may also verify the integrity of the original code, and check whether the extracted code is complete without any damaged or missing files.

[0029] In some embodiments, the present disclosure may also periodically obtain the latest original code from the version control system according to a preset cycle.

[0030] After obtaining the original code of the first object, the present disclosure can perform a level evaluation on the original code to determine the original code level of the original code, and then optimize the original code based on the original code level to obtain a revised code.

[0031] Specifically, the present disclosure can perform a level evaluation on the extracted original code according to a preset code evaluation standard.

[0032] Among them, the preset code evaluation standard may include multiple evaluation indicators. The present disclosure can evaluate the original code based on multiple evaluation indicators to obtain the evaluation results of the original code under each evaluation indicator, thereby determining the original code level of the original code based on the evaluation results.

[0033] It is understandable that when evaluating the grade of the original code, the present disclosure may use static code analysis tools, code review, or manual evaluation methods to evaluate the code. After obtaining the original code grade, the present disclosure may record the original code grade and the evaluation results under each evaluation indicator in a report, generate an original code evaluation report, and send the original code evaluation report to the first object.

[0034] After obtaining the original code level of the original code, the present disclosure can perform targeted code optimization according to the original code level to improve code quality and performance.

[0035] Specifically, the present disclosure can be based on the original code level. When the level is medium or poor, the present disclosure can identify weak content in the original code, determine the area to be corrected in the original code, and generate correction suggestions corresponding to the area to be corrected, so as to correct the original code according to the correction suggestions.

[0036] Among them, weak content may include but is not limited to: redundant code, performance bottlenecks, security vulnerabilities, non-standard naming and comments, etc.

[0037] Step 102: Determine the code difference between the original code and the revised code.

[0038] In some embodiments, after obtaining the revised code, the present disclosure can determine the difference label and difference distance between the original code and the revised code; based on the difference label and difference distance, combined with a preset graph convolutional neural network, determine the code difference between the original code and the revised code.

[0039] Among them, before determining the code difference between the original code and the revised code, the present disclosure can determine the comparison range based on the code marked as bugfix (i.e., the revised code of the present disclosure) obtained from the code repository, and thus determine the code difference between the original code and the revised code based on the comparison range.

[0040] Specifically, if the code revision involves only a specific file or code block, the comparison scope is determined to be the specific file or code block. If the code revision involves multiple files or extensive code changes, the comparison scope is the entire project or module.

[0041] Step 103: Determine a revised code level of the revised code based on the code difference, and push the revised code level to the first object.

[0042] In some embodiments, the present disclosure may re-evaluate the level of the optimized revised code based on the code difference, and push the evaluation result to the first object.

[0043] Specifically, the present disclosure can compare the code difference degree with a preset difference threshold, and determine the correction code level of the correction code based on the comparison result, where the correction code level includes an excellent level, a medium level, and a poor level.

[0044] The present disclosure can determine the code level as an excellent level based on the comparison result between the code difference and the preset difference threshold when the code difference is greater than or equal to the third preset difference threshold; determine the code level as a medium level when the code difference is less than the third preset difference threshold and greater than or equal to the fourth preset difference threshold; and determine the code level as a poor level when the code difference is less than the fourth preset difference threshold.

[0045] Among them, after determining the correction code level of the correction code, the present invention can directly push the correction code level to the first object, or generate a level assessment report corresponding to the correction code based on the correction code level, and push the level assessment report to the first object. The level assessment report includes the original code level, code difference and correction code level.

[0046] In summary, the technical solution provided by the present invention optimizes the original code of the first object to obtain the corrected code corresponding to the original code; determines the code difference between the original code and the corrected code; based on the code difference, determines the corrected code level of the corrected code, and pushes the corrected code level to the first object, and performs code quality assessment through code difference to reduce the influence of subjective factors and improve the accuracy and efficiency of code quality assessment.

[0047] As a possible implementation, Figure 2 The flowchart of another code level evaluation method shown in FIG. 1 is based on the above embodiment, and the original code of the first object is optimized to obtain the modified code corresponding to the original code. The specific process includes the following steps: Step 201: Obtain a real-time input code of a first object.

[0048] In some embodiments, the present disclosure may capture the code input by the first object in an editor or IDE (Integrated Development Environment), that is, the present disclosure may obtain the current input code of the first object from the editor according to a preset code acquisition cycle.

[0049] For example, the present disclosure may use a timer (such as setInterval) to periodically obtain the value in a text box (textarea or contenteditable div), or capture code content through an IDE plug-in or extension.

[0050] In order to provide real-time feedback, the present disclosure may also use technologies such as WebSocket to send the captured code to the server for analysis.

[0051] Step 202: Determine abnormal codes in the real-time input code.

[0052] In some embodiments, the present disclosure can analyze the captured real-time input code to identify abnormal codes that may exist therein, including obvious code errors such as syntax errors, logic errors, and type mismatches.

[0053] Specifically, the present disclosure may use static analysis, dynamic analysis, pattern matching and other techniques to detect abnormal codes.

[0054] When an abnormal code is detected, the present disclosure can also classify the detected errors, dividing the abnormal code into severe exceptions and warning exceptions, where severe exceptions refer to abnormal codes that cause the program to be unable to compile or run, and warning exceptions refer to abnormal codes that do not affect program operation but may cause performance problems or potential errors.

[0055] When an abnormal code is detected, the present disclosure may also record the abnormal code process for subsequent analysis and reporting.

[0056] For example, the present disclosure may use static code analysis tools (such as ESLint for JavaScript, Pylint for Python, etc.) in combination with predefined detection rules to check the code.

[0057] Step 203: Determine an initial correction suggestion corresponding to the abnormal code, and provide an initial correction prompt to the first object, so that the first object corrects the real-time input code based on the initial correction prompt to obtain the original code.

[0058] In some embodiments, the present disclosure can generate initial correction suggestions based on the detected abnormal code. The initial correction suggestions are used to quickly and accurately correct errors in the code.

[0059] Specifically, the present disclosure may use a preset rule base and a machine learning model to generate correction suggestions.

[0060] Correction suggestions can mark errors in the code editor and provide correction options, display error information and suggestions in a pop-up window, list errors and suggestions in logs or reports, and more.

[0061] The present disclosure can improve the user interaction interface, allow the first object to select, accept or reject the correction suggestion, and allow the first object to further edit or customize the correction content. In addition, the present disclosure can also automatically correct the abnormal code based on the correction suggestion to obtain the original code.

[0062] Wherein, when the first object corrects the real-time input code based on the initial correction prompt, the present disclosure can also verify whether the corrected code still contains anomalies and generate a final original code.

[0063] In summary, the present invention improves the code quality of the original code, reduces human errors, and improves development efficiency through an automated initial abnormal code detection and correction process.

[0064] As a possible implementation, Figure 3 The flowchart of another code level evaluation method shown in FIG. 1 is a flowchart of another code level evaluation method shown in FIG. 1 , based on the above embodiment, optimizing the original code of the first object to obtain the modified code corresponding to the original code, and the specific process includes the following steps: Step 301: Determine the evaluation results of the original code under multiple evaluation indicators, where the multiple evaluation indicators include code complexity, code repetition rate, code coverage rate, code style inconsistency ratio, code review feedback score, code safety rate, and code team assistance score.

[0065] In some embodiments, the present disclosure can evaluate the original code in multiple dimensions, including but not limited to code complexity, code duplication rate, code coverage rate, code style inconsistency ratio, code review feedback score, code safety rate, and code team assistance score.

[0066] As for code complexity, code complexity is used to measure the logical complexity of the code. High complexity may make it difficult to understand and maintain. The present disclosure can use static code analysis tools to calculate cyclomatic complexity and N-path complexity to identify logically complex code segments. The present disclosure can calculate the logical complexity of the code based on the calculated cyclomatic complexity and N-path complexity, combined with preset weights. Among them, when the logical complexity is higher than the preset complexity threshold, it means that the code is too complex and may need to be optimized.

[0067] Specifically, the cyclomatic complexity of the present disclosure is an indicator to measure the number of independent paths in the code, which is usually used to evaluate the logical complexity of the code. The present disclosure can be calculated by the following formula: M = E - N + 2P Where: M represents cyclomatic complexity; E represents the number of edges in the program (including jump edges and sequential edges in the control flow graph); N represents the number of nodes in the program (usually statements or instructions in the code); P represents the number of connected components in the program (if the program has only one connected component, P=1; otherwise, P is an integer greater than 1).

[0068] The present disclosure can utilize a static code analysis tool to automatically calculate the cyclomatic complexity of a code. The cyclomatic complexity of a code is calculated by the above formula.

[0069] NPath Complexity is another metric to measure code complexity that takes into account all possible execution paths in the code. Unlike cyclomatic complexity, NPath Complexity not only takes into account independent paths in the control flow graph, but also all possible execution paths generated by conditional statements (such as if-else, switch-case, etc.).

[0070] When calculating the N-path complexity, the present disclosure needs to traverse each conditional statement in the code and calculate the number of execution paths generated by each conditional statement. Then, these numbers are multiplied to obtain the N-path complexity of the entire code.

[0071] In order to perform code complexity analysis more effectively, the present disclosure may combine the use of static code analysis tools and large language models (such as the GPT series, BERT, etc.).

[0072] Static code analysis tools can automatically parse code, build control flow graphs, and calculate cyclomatic complexity and N-path complexity. Large language models can deeply analyze code, understand the logical structure and semantic relationships of code, and assist static code analysis tools in more accurate control flow graph construction and complexity calculation.

[0073] In addition, large language models can also provide optimization suggestions based on the code complexity analysis results, such as refactoring code, simplifying logic, etc.

[0074] After obtaining the cyclomatic complexity and the N-path complexity, the present disclosure can calculate the comprehensive logical complexity of the current code according to the preset weights corresponding to the cyclomatic complexity and the preset weights corresponding to the N-path complexity, thereby realizing multi-dimensional evaluation according to the comprehensive logical complexity.

[0075] As for the code repetition rate, the code repetition rate is used to detect the redundant parts in the code. Reducing the repeated code can improve the maintainability and reusability of the code. The present disclosure can identify the repeated fragments in the code through semantic analysis technology, calculate the proportion of repeated code in the total code, and thus obtain the code repetition rate. Among them, when the code repetition rate is higher than the preset repetition threshold, it means that there are a lot of repeated codes in the code and reconstruction is required.

[0076] Specifically, the present disclosure can calculate the code duplication rate by using code clone detection technology, which refers to identifying similar or identical code fragments in the software code base through technical means. This reduces redundant code, reduces the size and complexity of the code base, improves the maintainability of the code (because when an error is found or a function needs to be updated, only one code needs to be modified), promotes code reuse, and improves development efficiency.

[0077] The code clone detection disclosed in the present invention can be based on text clone detection (i.e. identifying similar code snippets by comparing the character sequences of the code), and can also be based on semantic clone detection (i.e. identifying code snippets with the same or similar functions by parsing the abstract syntax tree (AST) of the code or performing more complex semantic analysis).

[0078] The clone detection tool in the present disclosure is a large model of deep learning or natural language processing, which uses a large model of deep learning or natural language processing to perform semantic analysis on the code to identify potential code clones. The implementation combines the advantages of text matching and semantic understanding, and can identify more complex code clones.

[0079] The present disclosure performs semantic analysis on the code through a clone detection tool (i.e., a large model of deep learning or natural language processing), identifies repeated code fragments in the code, and then counts the total number of characters or total number of lines of the repeated code fragments.

[0080] The disclosure also needs to count the total number of characters or lines of the entire code. The repetitive code rate of the code can be obtained by calculating the ratio of the total number of characters or lines of the repeated code fragments to the total number of characters or lines of the entire code.

[0081] As for code coverage, code coverage is used to indicate the degree to which the code is covered by tests, ensuring that the code is fully tested and improving the reliability and stability of the code. The present disclosure can use a test coverage tool to analyze the coverage of unit tests and integration tests to obtain code coverage. Among them, when the code coverage is lower than the preset coverage threshold, it means that there are untested code paths in the code, and test cases need to be added.

[0082] Specifically, the present disclosure can first calculate the unit test coverage and the integration test coverage, based on the unit test coverage and the integration test coverage, combined with the preset weight corresponding to the unit test coverage and the preset weight corresponding to the integration test coverage, to obtain the code coverage of the final code.

[0083] Unit test coverage is designed to measure the degree to which each module or function in the code is independently tested, while integration test coverage focuses on the testing of interactions between modules. Together, they ensure that the code is fully tested, thereby improving the reliability and stability of the software.

[0084] The present disclosure can use the test coverage tool in combination with the large model to automatically analyze the execution of test cases to obtain unit test coverage and integration test coverage. Common test coverage tools include JaCoCo (Java), Cobertura (Java), Coverage.py (Python), etc.

[0085] In addition, the present disclosure can also perform semantic analysis on test cases and codes through a large model to identify which code paths are covered by test cases and which are not covered, that is, to obtain uncovered code fragments. This helps to more accurately evaluate the adequacy of the test and provide developers with test case writing suggestions to improve the adequacy of the test and the quality of the code.

[0086] For the code style inconsistency ratio, the code style inconsistency ratio is used to indicate the degree of compliance between the code specification and the style, ensuring that the code follows a unified coding specification and style, and improving the readability and consistency of the code. The present disclosure can check the naming convention, indentation, space usage, etc. according to the coding specification, and use a large model for intelligent analysis to obtain the code style inconsistency ratio. Among them, when the code style inconsistency ratio is higher than the preset specification threshold, it means that the code style is inconsistent or does not meet the specification and needs to be adjusted.

[0087] Specifically, the present disclosure can first perform a style consistency check on the code to obtain a code style inconsistency ratio. The style consistency check is intended to ensure that all codes in the project are consistent in terms of naming conventions, indentation, space usage, etc., thereby improving code readability and team collaboration efficiency.

[0088] The present disclosure can use a large model for intelligent analysis, that is, use the large model to learn a large number of code samples, understand and identify different coding styles. Then, use the trained large model to compare the current code with the preset coding specifications (such as file structure, comment style, code structure, etc.) or the existing code style, and intelligently analyze the code fragments that do not meet the style consistency requirements, thereby calculating the ratio between the total number of characters or the total number of lines in the code fragments that do not meet the style consistency requirements and the total number of characters or the total number of lines in the entire code, and determining the code style inconsistency ratio of the current code.

[0089] At the same time, the present disclosure can also use the big model to provide developers with specific style unification suggestions based on the analysis results, such as modifying the naming method, adjusting the indentation level, deleting unnecessary spaces, etc.

[0090] The code review feedback score is used to indicate the overall quality of the code review, evaluate the code quality, discover potential problems through review, and make suggestions for improvement. The present disclosure can obtain the code review feedback score by having team members review the code and give feedback. Among them, when the code review feedback score is lower than the preset review threshold, it means that the code has many problems or requires major modifications, and needs to be paid attention to and improved.

[0091] Specifically, the code review feedback score disclosed herein can be calculated by combining the code review pass rate and the code review cycle with a preset weight.

[0092] The main purpose of the code review pass rate statistics is to measure the developer's response to code review feedback and their ability to improve. By counting the proportion of modification suggestions that are adopted, it can be intuitively reflected how much developers value feedback and their efforts in improving code quality.

[0093] The present disclosure can record the number of modification suggestions proposed in each code review and the number of suggestions that are finally adopted. Then, the code review pass rate is determined by calculating the ratio of the number of suggestions adopted to the number of modification suggestions proposed.

[0094] Among them, the present disclosure can also store the code review pass rate obtained each time, and draw a changing trend chart of the code review pass rate based on the historical code review pass rate, so as to observe whether the developer's response to feedback and improvement ability have improved.

[0095] At the same time, the disclosure can also perform code review cycle analysis, the main purpose of which is to evaluate the efficiency of code review and the speed of code quality improvement. By analyzing the time required for code to pass the review from submission, bottlenecks and problems in the review process can be revealed, thereby providing optimization suggestions for the team.

[0096] That is, the present disclosure can record the time of each code submission and the time when it finally passes the review. By calculating the difference between the time of passing the review and the time of code submission, the code review cycle is obtained. When the code review cycle exceeds the preset review cycle threshold, bottlenecks and problems in the review process can be further identified, such as insufficient reviewers, unclear review standards, etc.

[0097] After obtaining the code review pass rate and the code review cycle, the present disclosure may combine the preset weight corresponding to the code review pass rate and the preset weight corresponding to the code review cycle to calculate the final code review feedback score.

[0098] The code safety rate is used to indicate the security level of the code, ensuring that the code does not contain security vulnerabilities and improving the security of the software. The present disclosure can use security analysis tools to check whether there are common security vulnerabilities in the code, such as SQL injection, XSS, etc., and obtain the code safety rate based on the inspection results. Among them, when the code safety rate is lower than the preset security threshold, it means that there is a security risk and it needs to be repaired immediately.

[0099] Specifically, the security analysis tool in the present disclosure may be a large model technology, and the present disclosure may use the large model technology to perform in-depth static analysis of the code to discover potential security vulnerabilities and weaknesses. These vulnerabilities may include common security threats such as SQL injection, cross-site scripting (XSS), cross-site request forgery (CSRF), etc.

[0100] That is, the present disclosure can use the big model to perform a comprehensive scan of the code and identify potential security issues. Then, based on known security vulnerability patterns and attack vectors, check whether there are vulnerable code snippets in the code. After obtaining the code snippets, the present disclosure can calculate the ratio between the total number of characters or lines of the vulnerable code snippets and the total number of characters or lines of the entire code to determine the code security rate of the current code.

[0101] At the same time, the present disclosure can also use the big model to generate detailed security coding suggestions for the detected vulnerable code snippets, and guide developers on how to repair and improve them.

[0102] In addition, the present disclosure can conduct a security library usage assessment, that is, assess whether developers have used secure third-party libraries and APIs and followed the best security practices. Third-party libraries and APIs are widely used in software development, but they may also bring potential security risks.

[0103] For the code team assistance score, the code team assistance score is used to indicate the performance of the code of the first object in team collaboration, evaluate the performance of the code in team collaboration, and promote cooperation and communication between team members. The present disclosure can evaluate the code submission frequency of the first object, merge conflict resolution efficiency and other indicators in combination with the feedback of team members to obtain the code team assistance score. Among them, when the code team assistance score is lower than the preset assistance threshold, it means that there are problems in team collaboration, and the collaboration process and communication method need to be optimized.

[0104] Specifically, the present disclosure may first calculate the code submission frequency and the code merging score, and then use the code submission frequency and the code merging score to obtain the code team assistance score.

[0105] The code submission frequency statistics disclosed in this paper are intended to evaluate the activity and work rhythm of developers by recording and analyzing the number of code submissions and the amount of code submitted each time within a certain period of time. This helps the team understand the work habits and efficiency of each member, and thus put forward targeted suggestions for optimizing collaboration efficiency.

[0106] That is, the present disclosure can use the data recorded by the version control system (such as Git) to collect the code submission records of the first object (i.e., the developer). The collected data is statistically analyzed to calculate the number of submissions of each developer, and then the ratio of the number of code submissions to the total number of submissions is calculated by using the number of submissions to obtain the code submission frequency.

[0107] The present disclosure can also calculate the code snippets of each code submission by each developer, calculate the ratio between the total number of characters or the total number of lines of the code snippets of each code submission and the total number of characters or the total number of lines of the entire code, and determine the code submission amount.

[0108] The code merge score is mainly to evaluate code merge conflicts, aiming to evaluate the efficiency and quality of developers in resolving conflicts during the code merge process, as well as the frequency of code merges. This helps the team identify and resolve bottlenecks and problems in the merge process and optimize the merge process.

[0109] That is, the present invention can record the conflicts that occur during each code merge and their resolution, analyze the time required for developers to resolve the conflicts and the quality of the resolved code, and count the frequency of code merges. Based on the time required to resolve the conflicts and the quality of the resolved code, and the frequency of code merges, a code merge score is calculated to understand the collaboration habits of team members and the speed of project progress.

[0110] After obtaining the code submission frequency and the code merge score, the present disclosure may calculate the code team assistance score using the preset weight corresponding to the code submission frequency and the preset weight corresponding to the code merge score.

[0111] Step 302: Based on the evaluation result and the preset weight corresponding to each evaluation indicator, determine the comprehensive evaluation result of the original code.

[0112] In some embodiments, after obtaining the evaluation result of each evaluation indicator, the present disclosure multiplies the evaluation result of each evaluation indicator by its corresponding preset weight, and then sums them up to obtain a comprehensive evaluation result.

[0113] Among them, the preset weight corresponding to each evaluation result is not limited in the embodiment of the present disclosure and is based on actual conditions.

[0114] Step 303, compare the comprehensive evaluation result with the preset scoring threshold, and determine the original code level of the original code based on the comparison result, where the original code level includes excellent level, medium level and poor level.

[0115] In some embodiments, the present disclosure may compare the comprehensive evaluation result with a preset scoring threshold to determine the grade of the original code.

[0116] Specifically, the present disclosure may set clear scoring thresholds, such as excellent level (90 points and above), medium level (60-89 points) and poor level (59 points and below).

[0117] The present disclosure can determine the code level as an excellent level based on the comparison result between the comprehensive evaluation result and the preset evaluation threshold value. When the comprehensive evaluation result is greater than or equal to the first preset evaluation threshold value, the code level is determined to be a medium level; when the comprehensive evaluation result is less than the first preset evaluation threshold value and greater than or equal to the second preset evaluation threshold value, the code level is determined to be a poor level.

[0118] Step 304: Optimize the original code of the first object based on the original code level of the original code to obtain a modified code.

[0119] In some embodiments, if the original code level is medium or poor, the weak content pre-marked in the original code is detected to determine the area to be corrected; based on the area to be corrected, a first correction suggestion is generated, and based on the first correction suggestion, the original code is optimized to obtain the corrected code.

[0120] In some embodiments, the pre-annotated weak contents in the present disclosure are known potential problems, performance bottlenecks, security vulnerabilities, and parts that do not comply with best practices that are pre-annotated by the first object when the code is input.

[0121] The present disclosure can conduct in-depth evaluation and analysis of these pre-marked weak areas through static code analysis tools, dynamic testing, code review and other methods to determine which parts actually have problems or can be further optimized. Based on the detection results, it is clear which areas need to be corrected, and these areas will be used as areas to be corrected.

[0122] In some embodiments, the present disclosure can use code optimization tools or intelligent algorithms to automatically generate a series of first correction suggestions based on specific problems in the area to be corrected. These first correction suggestions may include code refactoring, algorithm optimization, security reinforcement, performance improvement, etc.

[0123] After determining the first correction suggestion, the present invention makes corresponding modifications and optimizations to the original code according to the first correction suggestion, such as modifying the code structure of the original code, adjusting the algorithm logic of the original code, adding security measures to the original code, improving the readability of the original code, etc., so as to obtain the corrected code.

[0124] This disclosure further improves the quality and performance of the code by performing targeted optimization and correction on the weak contents in the original code.

[0125] In summary, the present invention determines the original code level of the original code by analyzing the original code using multiple evaluation indicators and calculating the evaluation results of each evaluation indicator, thereby achieving a comprehensive and objective evaluation of the quality of the original code, which not only helps to improve the readability, maintainability and security of the code, but also promotes team collaboration and continuous improvement.

[0126] As a possible implementation, Figure 4 The flowchart of another code level evaluation method shown in FIG. 1 is a flowchart of another code level evaluation method, which, based on the above embodiment, determines the specific process of the code difference between the original code and the modified code, including the following steps: Step 401, decomposing the original code and the revised code respectively, constructing a first abstract grammar network corresponding to the original code and a second abstract grammar network corresponding to the revised code, wherein the first abstract grammar network includes first code elements corresponding to the original code, and the second abstract grammar network includes second code elements corresponding to the revised code.

[0127] In some embodiments, the present disclosure can decompose the revised code and the original code into first code elements and second code elements, respectively, and the code elements include a series of lexical units (tokens), such as keywords, identifiers, operators, separators, etc. According to the grammatical rules of the programming language, the lexical units are organized into a grammatical structure to form an abstract syntax tree (AST), that is, a first abstract syntax network corresponding to the original code and a second abstract syntax network corresponding to the revised code.

[0128] Specifically, in the present disclosure, each node vi in ​​the first abstract grammar network and the second abstract grammar network not only represents a grammatical element (the grammatical elements include variables, operators and statement blocks), but also represents the relationship between these elements, such as parent-child relationship, sibling relationship or other types of dependency relationship. The present disclosure can also construct the first abstract grammar network as the first graph data and the second abstract grammar network as the second graph data, i=1,2,...N, N is the total number of nodes.

[0129] Step 402: construct a dynamic programming table based on the first code element and the second code element.

[0130] In some embodiments, after obtaining the first abstract syntax network corresponding to the original code and the second abstract syntax network corresponding to the revised code, the present disclosure may construct a dynamic programming table.

[0131] That is, based on the first code element and the second code element, create a two-dimensional array dp, where dp[i][j] represents the length of the longest common subsequence of the first i elements of the first code element sequence X and the first j elements of the Dell code element sequence Y (elements include functions, classes, and modules). The size of the array is (m+1) x (n+1), where m and n are the lengths of sequences X and Y, respectively. Sequence X is the first code element, and sequence Y is the second code element.

[0132] Initialize the first row and first column of the two-dimensional array dp to 0, because the empty sequence is a subsequence of any sequence and has length 0.

[0133] A double loop is used to traverse each element of the first code element sequence X and the second code element sequence Y, and a two-dimensional array is calculated, that is, a dynamic programming table is obtained.

[0134] Step 403: determine the longest common subsequence based on the dynamic programming table.

[0135] In some embodiments, the present disclosure can compare the sizes of the two-dimensional data of the first code element and the two-dimensional data of the second code element in the dynamic planning table to determine the longest common subsequence; when the two-dimensional data of the first code element is equal to the two-dimensional data of the second code element, the longest common subsequence is determined to be the two-dimensional data of the first code element and the two-dimensional data of the second code element; when the two-dimensional data of the first code element is not equal to the two-dimensional data of the second code element, the two-dimensional data of the maximum value between the two-dimensional data of the first code element and the two-dimensional data of the second code element is determined to be the longest common subsequence.

[0136] Specifically, for dp[i][j], there are two cases: If X[i-1] is equal to Y[j-1], then dp[i][j] = dp[i-1][j-1] + 1, because the longest common subsequence includes X[i-1] and Y[j-1].

[0137] If X[i-1] is not equal to Y[j-1], then dp[i][j] = max(dp[i-1][j], dp[i][j-1]), because the longest common subsequence either does not include X[i-1] or does not include Y[j-1], whichever is larger.

[0138] After calculating the two-dimensional array, we can start from dp[m][n] and trace back the longest common subsequence. If dp[i][j] = dp[i-1][j-1] + 1, then X[i-1] and Y[j-1] are part of the longest common subsequence; otherwise, based on the size relationship between dp[i-1][j] and dp[i][j-1], decide whether to exclude X[i-1] or Y[j-1].

[0139] Step 404: determine the difference element between the first code element and the second code element based on the longest common subsequence, and mark the difference element to obtain a difference tag.

[0140] In some embodiments, after obtaining the longest common subsequence, the differences between the two original sequences and the longest common subsequence can be compared to analyze which elements of the two sequences differ, thereby understanding the specific changes between different versions or different parts of the code.

[0141] The present disclosure can traverse two original sequences, and mark the elements that are not in the longest common subsequence as difference elements. In this way, the elements that have changed in the two sequences (i.e., difference elements) can be clearly found, and then the difference elements can be marked to determine the difference labels. The present disclosure can comprehensively extract difference labels and extract relevant features from the difference results, such as frequently changing node types, key functions or variables involved in the changes, etc. These features can help further analyze the impact of code changes, such as whether they have an impact on key functions, performance, etc.

[0142] Step 405: determine the difference distance between the first code element and the second code element.

[0143] In some embodiments, after determining the difference element, the present disclosure can determine the difference distance (i.e., edit distance) between the first code element and the second code element. The difference distance refers to the minimum number of operations required to convert one sequence into another sequence through insertion, deletion, or substitution operations. Based on the longest common subsequence, the edit distance between the two sequences can be calculated.

[0144] Step 406, based on the difference label and the difference distance, combined with a preset graph convolutional neural network, determine the code difference.

[0145] In some embodiments, after obtaining the difference distance and the difference label, the present disclosure can use the large model and the GCN algorithm to calculate the node difference degree. That is, the difference label and the difference distance are used as the input of the preset graph convolutional neural network, and the first hidden layer and the second hidden layer in the preset graph convolutional neural network are used to determine the code difference degree.

[0146] The present disclosure can input the difference labels and difference distances corresponding to the difference elements into the large model, and calculate the difference degree of each node vi (ie, the difference element) through a preset graph convolutional neural network (GCN) algorithm.

[0147] The input feature of the graph convolutional neural network preset in the present disclosure is Hvi(0). Hvi(0) is the initial feature vector of the difference element, which contains the difference label and the difference distance.

[0148] The graph structure of the preset graph convolutional neural network in this disclosure is: The adjacency matrix of the graph data with self-connection is usually defined as =A+I, where A is the original adjacency matrix and I is the identity matrix. D is the degree matrix, i.e., a diagonal matrix whose diagonal elements are the degrees of each node (i.e., the number of edges directly connected to the node).

[0149] The GCN layer includes the first hidden layer, which uses the ReLU activation function, and the second hidden layer, which uses the Sigmoid activation function.

[0150] For each difference element, its detection result is calculated as follows: The first hidden layer is formula 1: Formula 1 in, is the adjacency matrix of the graph data with self-connection, D is the degree matrix, is the normalized adjacency matrix; W(0) is the weight matrix of the first hidden layer.

[0151] The second hidden layer is formula 2: Formula 2 in, is the adjacency matrix of the graph data with self-connection, D is the degree matrix, is the normalized adjacency matrix, and W(1) is the weight matrix of the second hidden layer.

[0152] The output result of the preset graph convolutional neural network in the present disclosure may be a value in Hvi(2) or a further processed output (for example, taking the value of a specific dimension as the difference).

[0153] In the above manner, the present disclosure can input the difference label and the difference distance into the GCN model, and calculate the difference degree of each difference element through the algorithm of the model.

[0154] In summary, the present disclosure determines the code difference between the original code and the revised code, evaluates the revised code level of the revised code based on the code difference, and implements the code level evaluation using the code difference, thereby reducing the influence of subjectivity on the evaluation result and improving the accuracy of the evaluation. At the same time, the present disclosure uses the code difference to evaluate the code level of the revised code to achieve a dual evaluation of the code level, further reducing the influence of subjectivity and more objectively evaluating the quality of the original code.

[0155] Corresponding to the above-mentioned code level evaluation method, the present invention also proposes a code level evaluation device. Since the device embodiment of the present invention corresponds to the above-mentioned method embodiment, details not disclosed in the device embodiment can be referred to the above-mentioned method embodiment, and will not be repeated in the present invention.

[0156] Figure 5 A schematic diagram of a code level evaluation device provided by an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, the device comprises: An optimization unit 510, configured to optimize the original code of the first object to obtain a modified code corresponding to the original code; A determination unit 520, configured to determine a code difference between the original code and the modified code; The evaluation unit 530 is configured to determine a correction code level of the correction code based on the code difference, and push the correction code level to the first object.

[0157] In some embodiments of the present disclosure, the code level assessment device further includes: an acquisition unit, which is used to acquire the real-time input code of the first object before optimizing the original code of the first object to obtain the corrected code corresponding to the original code; determine the abnormal code in the real-time input code; determine the initial correction suggestion corresponding to the abnormal code, and provide an initial correction prompt to the first object, so that the first object corrects the real-time input code based on the initial correction prompt to obtain the original code.

[0158] In some embodiments of the present disclosure, the optimization unit 510 is used to: determine the evaluation results of the original code under multiple evaluation indicators, wherein the multiple evaluation indicators include code complexity, code repetition rate, code coverage rate, code style inconsistency ratio, code review feedback score, code safety rate, and code team assistance score; determine the comprehensive evaluation results of the original code based on the evaluation results and the preset weights corresponding to each evaluation indicator; compare the comprehensive evaluation results with the preset scoring threshold, and determine the original code level of the original code based on the comparison results, the original code levels including excellent level, medium level and poor level; optimize the original code of the first object based on the original code level of the original code to obtain the corrected code.

[0159] In some embodiments of the present disclosure, the optimization unit 510 is used to: if the original code level is medium or poor, detect the weak content pre-marked in the original code to determine the area to be corrected; based on the area to be corrected, generate a first correction suggestion, and optimize the original code based on the first correction suggestion to obtain a corrected code.

[0160] In some embodiments of the present disclosure, the determination unit 520 is used to: perform decomposition operations on the original code and the revised code respectively, construct a first abstract grammar network corresponding to the original code and a second abstract grammar network corresponding to the revised code, the first abstract grammar network includes a first code element corresponding to the original code, and the second abstract grammar network includes a second code element corresponding to the revised code; construct a dynamic programming table based on the first code element and the second code element; determine the longest common subsequence based on the dynamic programming table; determine the difference elements in the first code element and the second code element based on the longest common subsequence, and mark the difference elements to obtain a difference label; determine the difference distance between the first code element and the second code element; determine the code difference degree based on the difference label and the difference distance in combination with a preset graph convolutional neural network.

[0161] In some embodiments of the present disclosure, the determination unit 520 is used to: use the difference label and the difference distance as inputs of a preset graph convolutional neural network, and use the first hidden layer and the second hidden layer in the preset graph convolutional neural network to determine the code difference degree; The first hidden layer is formula 1: Formula 1 in, is the adjacency matrix of the graph data with self-connection, D is the degree matrix, is the normalized adjacency matrix; W(0) is the weight matrix of the first hidden layer.

[0162] The second hidden layer is formula 2: Formula 2 in, is the adjacency matrix of the graph data with self-connection, D is the degree matrix, is the normalized adjacency matrix, and W(1) is the weight matrix of the second hidden layer.

[0163] In some embodiments of the present disclosure, the evaluation unit 530 is used to compare the code difference with a preset difference threshold, and determine a correction code level of the correction code based on the comparison result, where the correction code level includes an excellent level, a medium level, and a poor level.

[0164] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and the principle is the same, which is not limited in this embodiment.

[0165] Based on the above Figures 1 to 4 The method shown in the figure, accordingly, this embodiment also provides a computer program product, including a computer program, which implements the above-mentioned Figures 1 to 4 The method shown.

[0166] Based on the above Figures 1 to 4 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figures 1 to 4 The method shown.

[0167] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.

[0168] like Figure 6 The figure shows a hardware structure diagram of an electronic device of the present invention, including: at least one processor 601; and, A memory 602 is communicatively connected to at least one of the processors 601; wherein, The memory 602 stores instructions that can be executed by at least one of the processors. The instructions are executed by at least one of the processors to enable the at least one of the processors to perform the code level assessment method as described above.

[0169] Figure 6 A processor 601 is taken as an example.

[0170] The electronic device may further include: an input device 603 and a display device 604 .

[0171] The processor 601, the memory 602, the input device 603 and the display device 604 may be connected via a bus or other means, and the figure takes the connection via a bus as an example.

[0172] The memory 602 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the review content generation method in the embodiment of the present application, for example, Figures 1 to 4The processor 601 executes various functional applications and data processing by running the non-volatile software programs, instructions and modules stored in the memory 602, that is, the code level evaluation method in the above embodiment is implemented.

[0173] The memory 602 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created according to the use of the review content generation method, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 602 may optionally include a memory remotely arranged relative to the processor 601, and these remote memories may be connected to the device for executing the review content generation method via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0174] The input device 603 can receive user clicks and generate signal inputs related to user settings and function controls of the review content generation method. The display device 604 can include display devices such as a display screen.

[0175] The one or more modules are stored in the memory 602 and, when executed by the one or more processors 601 , execute the code level evaluation method in any of the above method embodiments.

[0176] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.

[0177] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.

[0178] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.

[0179] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. By applying the solution of this embodiment, compared with the current prior art, this embodiment optimizes the original code of the first object to obtain the corrected code corresponding to the original code; determines the code difference between the original code and the corrected code; based on the code difference, determines the corrected code level of the corrected code, and pushes the corrected code level to the first object, and performs code quality assessment through code difference to reduce the influence of subjective factors and improve the accuracy and efficiency of code quality assessment.

[0180] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0181] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.

Claims

1. A code level evaluation method, characterized in that: The method comprises: Optimizing the original code of the first object to obtain a modified code corresponding to the original code; determining a code difference between the original code and the revised code; Based on the code difference, a revised code level of the revised code is determined, and the revised code level is pushed to the first object.

2. The method according to claim 1, characterized in that Before optimizing the original code of the first object to obtain the corrected code corresponding to the original code, the method includes: Obtaining a real-time input code of the first object; Determining an abnormal code in the real-time input code; An initial correction suggestion corresponding to the abnormal code is determined, and an initial correction prompt is given to the first object, so that the first object corrects the real-time input code based on the initial correction prompt to obtain the original code.

3. The method according to claim 1, characterized in that The optimizing the original code of the first object to obtain the corrected code corresponding to the original code includes: Determine the evaluation results of the original code under multiple evaluation indicators, wherein the multiple evaluation indicators include code complexity, code repetition rate, code coverage rate, code style inconsistency ratio, code review feedback score, code safety rate, and code team assistance score; Determine a comprehensive evaluation result of the original code based on the evaluation result and the preset weight corresponding to each evaluation indicator; Comparing the comprehensive evaluation result with a preset scoring threshold, and determining an original code grade of the original code based on the comparison result, wherein the original code grade includes an excellent grade, a medium grade, and a poor grade; Based on the original code level of the original code, the original code of the first object is optimized to obtain the modified code.

4. The method according to claim 1, characterized in that: The step of optimizing the original code of the first object based on the original code level of the original code to obtain the corrected code includes: If the original code level is medium or poor, detect the pre-marked weak content in the original code to determine the area to be corrected; Based on the area to be corrected, a first correction suggestion is generated, and based on the first correction suggestion, the original code is optimized to obtain the corrected code.

5. The method according to claim 1, characterized in that The determining of the code difference between the original code and the revised code comprises: Decomposing the original code and the revised code respectively, constructing a first abstract syntax network corresponding to the original code and a second abstract syntax network corresponding to the revised code, wherein the first abstract syntax network includes a first code element corresponding to the original code, and the second abstract syntax network includes a second code element corresponding to the revised code; Constructing a dynamic programming table based on the first code element and the second code element; Based on the dynamic programming table, determining the longest common subsequence; Based on the longest common subsequence, determining a difference element between the first code element and the second code element, and marking the difference element to obtain a difference label; determining a difference distance between the first code element and the second code element; Based on the difference label and the difference distance, combined with a preset graph convolutional neural network, the code difference degree is determined.

6. The method according to claim 5, characterized in that The determining of the code difference based on the difference label and the difference distance in combination with a preset graph convolutional neural network includes: Using the difference label and the difference distance as inputs of the preset graph convolutional neural network, and using the first hidden layer and the second hidden layer in the preset graph convolutional neural network to determine the code difference degree; The first hidden layer is Formula 1: Formula 1 in, is the adjacency matrix of the graph data with self-connection, D is the degree matrix, is the normalized adjacency matrix; W(0) is the weight matrix of the first hidden layer; The second hidden layer is Formula 2: Formula 2 in, is the adjacency matrix of the graph data with self-connection, D is the degree matrix, is the normalized adjacency matrix, and W(1) is the weight matrix of the second hidden layer.

7. The method according to claim 5, characterized in that The determining of the correction code level of the correction code based on the code difference comprises: The code difference degree is compared with a preset difference threshold, and based on the comparison result, a correction code grade of the correction code is determined, wherein the correction code grade includes an excellent grade, a medium grade, and a poor grade.

8. A code level evaluation device, characterized in that: The device comprises: An optimization unit, configured to optimize an original code of the first object to obtain a modified code corresponding to the original code; A determination unit, configured to determine a code difference between the original code and the revised code; An evaluation unit is used to determine a correction code level of the correction code based on the code difference, and push the correction code level to the first object.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium 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.

Citation Information

Patent Citations

  • Version code quality portrait construction method and device based on multi-level labels

    CN117472739A

  • Code quality evaluation model training method and device and code quality evaluation method and device

    CN118093385A

  • Code quality control method and device, electronic equipment and storage medium

    CN118796677A

  • Source code correction assistance apparatus and source code correction assistance method

    US20220405063A1