Code standard proofreading and automatic complementing method and system, loading device and storage medium
By building a standard knowledge base and using large models for code interpretation and automatic completion, the problem of difficult code quality in collaborative development is solved, efficient code specification inspection and rapid iteration are achieved, and code quality and detection efficiency are significantly improved.
Patent Information
- Application Number
- CN202411882273.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-11
AI Technical Summary
During the collaborative development process, code quality is difficult to ensure, resulting in increased project maintenance difficulties and increased communication and understanding costs. In addition, there are lag and time-consuming and labor-intensive publicity of traditional R&D standards.
By building a standard knowledge base, using large models to interpret codes and standardized checks, automatically complete irregular codes, and improve code quality and standardization.
It realizes accurate defect identification and positioning, strictly standardized inspection, improves code quality, reduces potential risks caused by human negligence or wrong judgment, shortens the software development cycle, and improves detection efficiency.
Smart Images

Figure CN119806534A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a large model, and more specifically, to a method, system, loading device and storage medium for code standard proofreading and automatic completion. Background Art
[0002] In the software industry, it is difficult to ensure code quality, readability, reusability and other characteristics during collaborative development. This is often due to many factors, such as inconsistent understanding of R&D specifications or different requirements among members of the collaborative development team, as well as uneven capabilities of R&D personnel. As a result, after long-term collaborative development of the project, the quality of the code is uneven, the project becomes increasingly difficult to maintain, and it is even more difficult to control the code quality.
[0003] According to the traditional way, it is relatively time-consuming and labor-intensive to update and publicize R&D specifications to each R&D team member from time to time, and there is a lag in the work such as code pr. As a result, many large projects will gradually have quality problems soon after the development is completed and put into operation. With the turnover of R&D personnel, it will be more difficult to maintain in the later stage. As a result, the communication and understanding costs of collaborative development between different teams or new R&D personnel entering the project will increase synchronously with the passage of time. This is undoubtedly not a healthy development phenomenon for the continuous operation and iteration of the project. Summary of the invention
[0004] The technical problem to be solved by the present invention is to address the deficiencies in the prior art and provide a code standard proofreading and automatic completion method, system, loading device and storage medium, which improves code quality and reduces potential risks caused by human negligence or misjudgment.
[0005] The method for standardizing and automatically completing a code described in the present invention builds a standard knowledge base, interprets the submitted code to determine the correctness of the submitted code, and if the submitted code is incorrect, marks the incorrect code and generates prompt information, and then feeds back the prompt information; if the submitted code is correct, checks the standardization of the submitted code according to the standard knowledge base, and if the submitted code is not standard, performs code completion processing; if the submitted code is standard, inputs the submitted code into a code repository.
[0006] Preferably, the specification knowledge base is constructed as follows:
[0007] A standard training file of the code is obtained, the standard training file is vectorized, and then the vectorized standard training file is written into a vector database to form the standard knowledge base.
[0008] Preferably, the code interpretation includes: context analysis, business logic analysis, module division, function description, lexical analysis and grammatical analysis.
[0009] Preferably, the prompt information includes explaining the code by means of code annotation according to the incorrect code.
[0010] Preferably, the code completion process is specifically as follows:
[0011] Searching for an approximate code from a database according to the non-standard code, and using the approximate code as a recommended code;
[0012] Feeding the recommendation code back to the encoding tool through the API interface;
[0013] After the coding tool obtains the recommended code, the recommended code is displayed through the prompt window of the coding tool, and code completion is performed at the corresponding code that needs to be corrected, and the position of the code completion is marked.
[0014] Preferably, the approximate code is a standard code whose code type is consistent with the non-standard code type and whose semantic interpretation is consistent with that of the code.
[0015] A system based on the code standard proofreading and automatic completion method includes:
[0016] A standard knowledge base for storing basic data of standardization codes;
[0017] Large model module, used to vectorize the canonical training files and submitted code;
[0018] Code interpretation module, used to interpret the submitted code;
[0019] A code standard detection module, used to check the standardization of the submitted code according to the standard knowledge base;
[0020] The code generation module is used to perform code completion processing.
[0021] A loading device is provided in which the code standard proofreading and automatic completion system is installed. The loading device is used to receive the submitted code sent by the coding tool, and process it through the code standard proofreading and automatic completion system to transmit the correct and standardized code to the code warehouse.
[0022] A storage medium stores a code standard proofreading and automatic completion program, and the code standard proofreading and automatic completion program implements the code standard proofreading and automatic completion method when executed by a processor.
[0023] Beneficial Effects
[0024] The advantages of the present invention are:
[0025] 1. Automatically learn the defect patterns and R&D specifications in the code through the big model, and then perform code interpretation and normative checks on the submitted code, which can achieve accurate defect identification and location, as well as strict normative checks, which not only improves the code quality, but also reduces the potential risks caused by human negligence or misjudgment.
[0026] 2. Based on code interpretation and code standardization check, for non-standard submitted code, the code is improved through code completion, so that code verification and R&D standard check can be completed in a short time, greatly shortening the software development cycle, realizing rapid iteration and real-time detection, and significantly improving detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 The figure is a flow chart of the method for code standard proofreading and automatic completion of the present invention. DETAILED DESCRIPTION
[0028] The present invention will be further described below in conjunction with the embodiments, but it does not constitute any limitation to the present invention. Any limited number of modifications made by anyone within the scope of the claims of the present invention are still within the scope of the claims of the present invention.
[0029] See also Figure 1 , a method for code standard proofreading and automatic completion of the present invention comprises the following steps:
[0030] The first step is to build a specification knowledge base. The specification knowledge base is mainly used to define common specifications for the project. It can mainly solve the definition of specification consistency during collaborative development and reduce the need for R&D personnel to repeatedly query the specification manual for code adjustments. The basic data of R&D specifications can be entered into the vector library through vectorization conversion. For example, our rules for programming specifications, exception log specifications, MySQL specifications, engineering specifications, security specifications, unit testing, design specifications, naming specifications, etc. can be described in natural language and converted into content in the specification knowledge base. This component can replace the work of R&D personnel manually querying specification texts to improve R&D efficiency.
[0031] Specifically, obtain the standard training file of the code. The standard training file can adopt some mainstream standardized files in software development, or it can be customized, that is, the R&D specifications of mainstream companies on the market can be used, or the priorities of some R&D specifications can be customized. The standard training file is mainly used to train the knowledge base, and its knowledge content can cover the front-end, back-end, database, script and other directions. Call the open source big model to vectorize the standard training file through the open source big model. Among them, the open source big model can select different models according to our needs to process our natural language training content. The open source big model is combined with the vector library to vectorize the standard training file, and then write it into the vector database, that is, a standard knowledge base is formed, and the custom training operation is completed.
[0032] The second step is to interpret the submitted code. Code interpretation is mainly achieved through the open source big model. Code interpretation includes context analysis, business logic analysis, module division, function description, lexical analysis and syntax analysis. Among them, context analysis mainly analyzes whether the beginning and end of the code are complete; business logic analysis mainly analyzes whether the various logics of the code are complete; module division mainly divides the code into modules; function description mainly analyzes the learning function based on the open source big model and extracts the code function; lexical analysis is used to interpret and judge whether the words used in the code are correct; syntax analysis is used to judge whether the syntax of the code meets the corresponding syntax standards based on the open source big model.
[0033] Step 3: After the code is interpreted, the correctness of the submitted code can be judged based on the interpretation structure. If the submitted code is incorrect, the incorrect code will be marked and a prompt message will be generated, and then the prompt message will be fed back. Among them, the prompt message includes explaining the code through code comments based on the incorrect code, which is convenient for R&D personnel to understand and continue writing the code. If the submitted code is correct, the fourth step, that is, the code standardization check, will be carried out.
[0034] Step 4: After the code interpretation is completed, the submitted code is checked for standardization according to the standard knowledge base. If the submitted code is not standard, the code completion process is performed. If the submitted code is standard, the submitted code is entered into the code repository.
[0035] The code completion process is as follows: according to the non-standard code, the approximate code is searched from the database and used as the recommended code; the recommended code is fed back to the coding tool through the API interface; after the coding tool obtains the recommended code, the recommended code is displayed through the prompt window of the coding tool, and the code is completed at the corresponding code that needs to be corrected, and the position of the code completion is marked. The approximate code is a standardized code whose code type is consistent with the non-standard code type and whose semantic interpretation is consistent with the code.
[0036] A system based on the above-mentioned code standard proofreading and automatic completion method includes a standard knowledge base, a large model module, a code interpretation module, a code standard detection module and a code generation module.
[0037] Among them, the specification knowledge base is used to store the basic data of standardized codes. The specification knowledge base is mainly used to define common specifications for projects. It can mainly solve the definition of specification consistency during collaborative development and reduce the need for R&D personnel to repeatedly query the specification manual for code adjustment. The basic data of R&D specifications can be entered into the vector library through vectorization conversion. For example, our rules for programming specifications, exception log specifications, MySQL specifications, engineering specifications, security specifications, unit testing, design specifications, naming specifications, etc. can be described in natural language and converted into content in the specification knowledge base. This component can replace the work of R&D personnel to manually query the specification text and improve R&D efficiency.
[0038] The large model module is used to vectorize the standard training files and submitted codes. Specifically, the large model module is mainly used to integrate some optional large models on the market, such as open source large models. On the one hand, it processes our natural language (i.e., the defined R&D specification information), and calls the specification knowledge base to vectorize the R&D specification content we input to form vector library data. At the same time, we can choose different models for data processing and provide certain pluggable features so that R&D personnel can choose a more suitable model to refine the R&D data.
[0039] In the present invention, the open source big model and the standard knowledge base provide an API interface for the big model module to call individually and in an integrated manner, and the scheduling weight is regulated by the big model module.
[0040] The code interpretation module is used to interpret the submitted code. The code interpretation module is mainly used to explain the code information we have written. It can interpret the code content by combining the entire file with the context analysis, business logic analysis, module division, function description, lexical analysis and syntax analysis of the code information we currently write in the idea coding tool. On the one hand, it is to give the analyzed information to the code specification inspection module for code quality inspection and analysis. On the other hand, the code can also be explained in the form of comments or annotations to facilitate R&D personnel to understand and continue writing the code.
[0041] The code standard detection module is used to check the standardization of the submitted code according to the standard knowledge base. The code standard checking module mainly obtains the code information explained in the code interpretation module, and then combines it with the big model to call the standard knowledge base to identify whether the code written by the R&D personnel meets the established R&D specifications, and generates certain improvement suggestions. At the same time, it can be combined with code version management tools such as git or svn to perform submission constraints, that is, the code must be updated according to the R&D specifications before it can be submitted to the library, thereby automatically controlling and constraining the code quality to a certain extent.
[0042] The code generation module is used to perform code completion processing. The code generation module is mainly responsible for the generation and display of recommended codes and code completion. On the one hand, it makes optimization and improvement suggestions for the code that has been verified by the standards and generates sample code; on the other hand, it can also complete our code according to the context based on the situation of the code interpretation module, reducing the coding workload of R&D personnel.
[0043] A loading device is provided in which the above-mentioned code standard proofreading and automatic completion system is installed. The loading device is used to receive the submitted code sent by the coding tool, and process it through the code standard proofreading and automatic completion system, and transmit the correct and standardized code to the code warehouse.
[0044] A storage medium stores a code standard proofreading and automatic completion program, which implements the above-mentioned code standard proofreading and automatic completion method when executed by a processor.
[0045] The above is only a preferred embodiment of the present invention. It should be pointed out that for those skilled in the art, several modifications and improvements can be made without departing from the structure of the present invention, which will not affect the effect of the implementation of the present invention and the practicality of the patent.
Claims
1. A method for code standard proofreading and automatic completion, characterized in that: Build a standard knowledge base, interpret the submitted code to determine the correctness of the submitted code, and if the submitted code is incorrect, mark the incorrect code and generate prompt information, and then feedback the prompt information; If the submitted code is correct, then checking the standardization of the submitted code according to the standard knowledge base; if the submitted code is not standard, then performing code completion processing; If the submitted code is in compliance with the specification, the submitted code is input into the code repository.
2. A method for code standard proofreading and automatic completion according to claim 1, characterized in that: Constructing the specification knowledge base is specifically as follows: A standard training file of the code is obtained, the standard training file is vectorized, and then the vectorized standard training file is written into a vector database to form the standard knowledge base.
3. A method for code standard proofreading and automatic completion according to claim 1, characterized in that: The code interpretation includes: context analysis, business logic analysis, module division, function description, lexical analysis and syntax analysis.
4. A method for code standard proofreading and automatic completion according to claim 1, characterized in that: The prompt information includes explaining the code by means of code comments according to the incorrect code.
5. A method for code standard proofreading and automatic completion according to claim 1, characterized in that: The code completion process is specifically as follows: Searching for an approximate code from a database according to the non-standard code, and using the approximate code as a recommended code; Feeding the recommendation code back to the encoding tool through the API interface; After the coding tool obtains the recommended code, the recommended code is displayed through the prompt window of the coding tool, and code completion is performed at the corresponding code that needs to be corrected, and the position of the code completion is marked.
6. A method for code standard proofreading and automatic completion according to claim 5, characterized in that: The approximate code is a standardized code whose code type is consistent with the non-standard code type and whose semantic interpretation is consistent with the code.
7. A system based on the code standard proofreading and automatic completion method according to any one of claims 1 to 6, characterized in that: include: A standard knowledge base for storing basic data of standardization codes; Large model module, used to vectorize the canonical training files and submitted code; Code interpretation module, used to interpret the submitted code; A code standard detection module, used to check the standardization of the submitted code according to the standard knowledge base; The code generation module is used to perform code completion processing.
8. A loading device, characterized in that: The loading device is installed with the code standard proofreading and automatic completion system as described in claim 7, and the loading device is used to receive the submitted code sent by the coding tool, and process it through the code standard proofreading and automatic completion system to transmit the correct and standardized code to the code warehouse.
9. A storage medium, characterized in that: The storage medium stores a code standard proofreading and automatic completion program, and when the code standard proofreading and automatic completion program is executed by the processor, the code standard proofreading and automatic completion method according to any one of claims 1 to 7 is implemented.