CN117435484A - Code error detection method, device, all-in-one machine and program product - Google Patents

Code error detection method, device, all-in-one machine and program product Download PDF

Info

Publication number
CN117435484A
CN117435484A CN202311381153.0A CN202311381153A CN117435484A CN 117435484 A CN117435484 A CN 117435484A CN 202311381153 A CN202311381153 A CN 202311381153A CN 117435484 A CN117435484 A CN 117435484A
Authority
CN
China
Prior art keywords
code
error detection
repair
target
target code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311381153.0A
Other languages
Chinese (zh)
Inventor
宋明
王金钖
刘权
魏思
胡国平
王凡
潘青华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
iFlytek Co Ltd
Original Assignee
iFlytek Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by iFlytek Co Ltd filed Critical iFlytek Co Ltd
Priority to CN202311381153.0A priority Critical patent/CN117435484A/en
Publication of CN117435484A publication Critical patent/CN117435484A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3608Software analysis for verifying properties of programs using formal methods, e.g. model checking, abstract interpretation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3628Software debugging of optimised code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Machine Translation (AREA)

Abstract

The invention provides a code error detection method, a device, an integrated machine and a program product, wherein the method comprises the following steps: acquiring an object code; performing rule error detection on the target code and/or performing code repair on the target code to obtain pre-error detection information of the target code; and carrying out code error detection on the target code based on the pre-error detection information. The method, the device, the integrated machine and the program product provided by the invention can obtain the pre-error detection information capable of assisting in locating the code error by carrying out regular error detection and/or code repair on the target code, and carry out the code error detection based on the pre-error detection information, thereby providing rich prompt for the code error detection, and effectively improving the reliability and the accuracy of the code error detection on the premise of realizing automatic code error detection.

Description

Code error detection method, device, all-in-one machine and program product
Technical Field
The present invention relates to the field of artificial intelligence technology, and in particular, to a code error detection method, apparatus, integrated machine, and program product.
Background
As code development becomes increasingly complex, efficient code processing is also becoming increasingly important.
At present, after debugging and error reporting, a developer is usually required to perform code error detection by himself, which has higher requirements on professional ability of the developer, larger workload of manual detection and lower code error detection efficiency.
Disclosure of Invention
The invention provides a code error detection method, a device, an all-in-one machine and a program product, which are used for solving the defects of low code error detection efficiency and poor reliability in the prior art.
The invention provides a code error detection method, which comprises the following steps:
acquiring an object code;
performing rule error detection on the target code and/or performing code repair on the target code to obtain pre-error detection information of the target code;
and carrying out code error detection on the target code based on the pre-error detection information.
According to the code error detection method provided by the invention, the code error detection rule is carried out on the target code, and/or the code repair is carried out on the target code, so as to obtain the pre-error detection information of the target code, which comprises the following steps:
performing rule error detection on the target code to obtain grammar error of the target code;
performing code repair on the target code to obtain a repair code, and determining a repair record corresponding to the target code based on a comparison result of the target code and the repair code;
determining the grammar error and/or the repair record as the pre-error detection information.
According to the code error detection method provided by the invention, the repair record comprises the repaired position and/or the repaired content.
According to the code error detection method provided by the invention, the code error detection is carried out on the target code based on the pre-error detection information, and the code error detection method comprises the following steps:
marking the pre-error detection information in the target code to obtain a marked code;
and inputting the labeling code into a code large model to obtain a code error detection result output by the code large model.
According to the code error detection method provided by the invention, the marking of the pre-error detection information in the target code to obtain the marked code comprises the following steps:
marking the grammar error in the pre-error detection information at the tail of a code line where the grammar error is located in the target code;
and/or the number of the groups of groups,
marking the single-row repair content in the target code at the end of the code row corresponding to the single-row repair content under the condition that the repair record in the pre-error detection information comprises the single-row repair content; in the case where the repair record includes multiple lines of repair content, the multiple lines of repair content are annotated in the object code in the form of segment annotations.
According to the code error detection method provided by the invention, the rule error detection is carried out on the target code, and the code error detection method comprises the following steps:
based on a static scanning tool, scanning grammar errors in the target code, repairing the current grammar errors in the target code under the condition that the current grammar errors are obtained by scanning, and returning the repaired target code as the target code to continue scanning until the scanning is completed.
According to the code error detection method provided by the invention, the repairing of the current grammar error in the target code comprises the following steps:
and inputting the current grammar error and the target code into a code large model to obtain the repaired target code output by the code large model.
The invention also provides a code error detection device, comprising:
an acquisition unit configured to acquire an object code;
the pre-checking unit is used for carrying out rule error detection on the target code and/or carrying out code repair on the target code to obtain pre-checking information of the target code;
and the error detection unit is used for carrying out code error detection on the target code based on the pre-error detection information.
The invention also provides a code error detection integrated machine, which comprises a memory, a processor, a computer program stored in the memory and capable of running on the processor, and a code large model, wherein the processor is used for realizing the code error detection method when calling the code large model to execute the program, and the code large model is used for carrying out code error detection based on pre-error detection information.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a code error detection method as described in any of the above.
The invention also provides a computer program product comprising a computer program which when executed by a processor implements a code error detection method as described in any one of the above.
The code error detection method, the code error detection device, the integrated machine and the program product provided by the invention can obtain the pre-error detection information capable of assisting in positioning the code error by carrying out regular error detection and/or code repair on the target code, and carry out code error detection based on the pre-error detection information, so that rich prompts are provided for code error detection, and the reliability and the accuracy of code error detection are effectively improved on the premise of realizing automatic code error detection.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a code error detection method provided by the invention;
FIG. 2 is a flow chart of a method for obtaining pre-error detection information provided by the invention;
FIG. 3 is a flow chart of a code error detection method based on pre-error detection information provided by the invention;
FIG. 4 is a schematic diagram of the structure of the code error detection apparatus provided by the present invention;
FIG. 5 is a schematic diagram of the code error detection all-in-one machine according to the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Code error detection usually needs research personnel to accomplish by oneself, and this is higher to research personnel's professional ability requirement, and the work load of manual detection is great, and code error detection efficiency is lower.
With the development of large language model (Large Language Model, LLM) technology, LLM models applied to programming languages, i.e., large code models, have been developed. However, since the code big model is focused on understanding and reasoning of programming language, the ability to find code errors is weak, and code error detection effect based on the code big model is not ideal.
Based on the above problems, the embodiment of the invention provides a code error detection method. FIG. 1 is a flow chart of a code error detection method provided by the invention, as shown in FIG. 1, the method comprises:
in step 110, object code is obtained.
Here, the target code is a code that needs code error detection. The object code may be a code written in any programming language, for example, a C language code, a Python language code, or a Java language code, which is not particularly limited in the embodiment of the present invention.
And 120, performing rule error detection on the target code and/or performing code repair on the target code to obtain pre-error detection information of the target code.
Specifically, the target code is subjected to rule error detection, that is, the target code is subjected to code error detection based on a preset rule, and the rule referred to herein can be a code grammar rule summarized in advance, for example, a naming rule, that is, the names of variables, functions, classes and the like must start with letters or underlines, and can include letters, numbers, underlines and specific symbols; for another example, data type rules, i.e., variables and constants must declare their data types, such as integers, floating point numbers, characters, etc.
By carrying out rule error detection on the target code, grammar errors existing in the target code can be obtained, and further, the information such as the positions of the grammar errors and the types of the grammar errors in the target code can be recorded into pre-error detection information of the target code.
In addition, the code repairing can be carried out on the target code, the code repairing can be realized through a code large model, and it can be understood that the code large model is better in the capability of carrying out code repairing than the code large model because the code large model is focused on understanding and reasoning of a programming language, and the code error detecting can be assisted by the result of carrying out code repairing through the code large model.
Here, by performing code repair on the target code, the code after repair can be obtained, and further, the location to be repaired in the target code, that is, the location where the code error may exist, can be located based on the repair code, and such location can be included in the pre-error detection information of the target code.
It should be noted that, the operations performed on the target code, that is, the rule error detection and the code repair, may be performed alternatively or both, and thus the obtained pre-error detection information may include only the information obtained by the rule error detection, may include only the information obtained by the code repair, and may include both the information obtained by the rule error detection and the information obtained by the code repair, which is not particularly limited in the embodiment of the present invention.
And 130, performing code error detection on the target code based on the pre-error detection information.
Specifically, after the pre-error detection information is obtained, the pre-error detection information can be used as auxiliary information in code error detection, and rich prompts are provided for positioning code errors in the target code in the code error detection process, so that the reliability and accuracy of code error detection are improved.
For example, the Prompt can be generated based on the pre-error detection information, and the Prompt and the target code are input into the code large model together for code error detection, so that the code large model can better locate the code error in the target code according to the pre-error detection information in the Prompt when the code large model detects the code error, and a more reliable and accurate code error detection result is output.
The method provided by the embodiment of the invention acquires the pre-error detection information capable of assisting in positioning the code error by carrying out regular error detection and/or code repair on the target code, and carries out the code error detection based on the pre-error detection information, thereby providing rich prompts for the code error detection, and effectively improving the reliability and the accuracy of the code error detection on the premise of realizing automatic code error detection.
Based on the above embodiments, fig. 2 is a flowchart of a method for obtaining pre-error detection information according to the present invention, as shown in fig. 2, step 120 includes:
and step 121, performing rule error detection on the target code to obtain the grammar error of the target code.
Here, rule error detection may be performed on the object code by pre-collected grammar rules, thereby obtaining grammar errors existing in the object code. Further, regular error detection may be achieved by an open source static scan tool, where the static scan tool may be spotbugs, TScanCode, pclint, etc.
And 122, performing code repair on the target code to obtain a repair code, and determining a repair record corresponding to the target code based on a comparison result of the target code and the repair code.
Specifically, the target code may be input into the code large model for code repair, resulting in a repaired code output by the code large model, referred to herein as a repair code.
After the repair code is obtained, reference may be made to the repair code and the object code, thereby obtaining a comparison result between the object code and the repair code. The comparison result here reflects a portion where there is a difference between the target code and the repair code, that is, a difference before and after the code repair.
The portion of the object code that is modified in the repair code, i.e., the code in the object code that needs to be repaired, may be determined based on the comparison result and noted as the repair record corresponding to the object code.
Step 123, determining the syntax error and/or the repair record as the pre-error detection information.
Specifically, in the case where only step 121 is performed and step 122 is not performed, syntax errors obtained by rule error detection may be registered in pre-error detection information; in the case where only step 122 is performed and step 121 is not performed, the repair record may be posted to pre-error detection information; in the case of performing both step 121 and step 122, the syntax error and the repair record may be entered together into the pre-error detection information.
Based on any of the above embodiments, the repair record includes a location of the repair and/or content of the repair.
In particular, the repair record may include the location of the repair, i.e., the location of the portion of the repair in the object code at the time of the code repair. By recording the location of the repair, the large model of the help code can be located directly to the code where errors are likely to exist when code error detection is performed at step 130.
In addition, the repair record may also include the contents of the repair, i.e., the portion of the code repair that results from the code repair is different than the target code. By recording the contents of the repair, the code macro model can be assisted in understanding the correct code logic when performing code error detection at step 130, thereby making it easier to locate errors present in the object code.
It will be appreciated that the location of the repair and the contents of the repair may also be included in the repair record to aid the code-large model in code error detection from both an error location and code understanding perspective.
Based on any of the above embodiments, fig. 3 is a flow chart of a code error detection method based on pre-error detection information provided in the present invention, as shown in fig. 3, step 130 includes:
step 131, marking the pre-error detection information in the target code to obtain a marked code;
and 132, inputting the labeling code into a code large model to obtain a code error detection result output by the code large model.
Specifically, in order to implement code error detection based on the pre-error detection information, the pre-error detection information may be marked in the target code first, so as to obtain a marked code carrying an error that may exist in the prompt code.
Here, the labeling of the target code may be implemented based on the type of error and the location of the error that may exist in the target code that is involved in the pre-error detection information. For example, a line of code or a section of code in the target code may be located based on a location in the pre-error detection information where an error may exist, and the line or the section of code may be prompted in the form of an annotation at the end of the line or the end of the section; further, the line may also be written in annotated form or the section of code may have an error type of error.
The marking codes obtained through marking in the mode retain the code form of the target codes while adding the pre-error detection information, so that the marking codes after marking can be directly input into the code large model, the code large model can detect the code of the marking codes based on the pre-error detection information carried by the marking codes, and the code error detection result output by the code large model is obtained.
Based on any of the above embodiments, step 131 includes:
and marking the grammar error in the pre-error detection information at the tail of a code line where the grammar error is located in the target code in the case that the grammar error obtained based on rule error detection exists in the pre-error detection information.
In particular, for grammar errors obtained based on rule error detection, the mark can be marked at the tail of a code line where the grammar errors are located in a comment mode, so that the positioning of the grammar errors and the marking of error contents are realized through the marked form. The error content here is the content obtained by scanning the code by regular error detection. For example, the following may be noted at the end of the line:
#invalid character’:’(U+FFIA)[syntax]
based on any of the above embodiments, step 131 includes:
aiming at the situation that a repair record obtained based on code repair exists in pre-error detection information, marking a single-row repair content in the target code at the end of a code row corresponding to the single-row repair content when the repair record in the pre-error detection information comprises the single-row repair content; in the case where the repair record includes multiple lines of repair content, the multiple lines of repair content are annotated in the object code in the form of segment annotations.
Specifically, for a repair record obtained based on code repair and comparison, repair contents in the repair record can be marked in the target code. It is understood that the repair content herein is the code after repair that is obtained by comparing the target code with the repair code.
Here, the repair content may be further divided, thereby obtaining a single line of repair content and a plurality of lines of repair content. The code content obtained by repairing a single line of repairing content only aims at a single line of codes, and the code content obtained by repairing a plurality of lines of continuous codes is obtained by repairing a plurality of lines of repairing content.
For the situation that a single-row repair content exists, the single-row repair content can be directly marked at the tail of a corresponding code row in the target code;
for the case where multiple lines of repair content exist, the multiple lines of repair content may be marked at corresponding multiple lines of code in the object code by way of segment annotation tags.
Here, whether for a single line of repair content or multiple lines of repair content, the specific mark may be in the form of:
# the code should be modified here as: xxxxx
It will be appreciated that "xxxxx" in the above labels is used to denote modification.
Based on any of the above embodiments, step 130 includes:
marking grammar errors and repair records in the pre-error detection information in the target code respectively to obtain grammar marking codes and repair marking codes;
respectively inputting the grammar annotation code and the repair annotation code into a code large model to obtain a first error detection result of the grammar annotation code and a second error detection result of the repair annotation code which are respectively output by the code large model;
and determining a code error detection result of the target code based on the first error detection result and the second error detection result.
Specifically, in addition to uniformly labeling the grammar error and the repair record on the target code, so that the code large model can combine the grammar error and the repair record to detect the code of the target code, the grammar error and the repair record can be respectively labeled on the target code, so that the code large model can detect the code of the target code based on the grammar error and the repair record respectively. In this case, the code big model outputs two types of error detection results, wherein the first error detection result is obtained by performing code error detection based on grammar errors, and the second error detection result is obtained by performing code error detection based on repair records.
After obtaining the two types of error detection results, the first error detection result and the second error detection result can be integrated, and the integrated error detection result is used as a code error detection result of the target code.
Based on any of the foregoing embodiments, in step 120, performing rule error detection on the object code includes:
based on a static scanning tool, scanning grammar errors in the target code, repairing the current grammar errors in the target code under the condition that the current grammar errors are obtained by scanning, and returning the repaired target code as the target code to continue scanning until the scanning is completed.
In particular, rule error detection may be implemented based on an open-source static scan tool.
Conventional static scanning tools stop scanning during a grammar error scan for object code, typically after a grammar error is scanned.
In the embodiment of the invention, in order to scan all grammar errors in the target code, when the grammar errors are scanned based on the static scanning tool, the grammar errors scanned at the current time are recorded as current grammar errors, and the target code is repaired aiming at the scanned current grammar errors, so that the target code after the repair is obtained. It is understood that the repaired object code referred to herein is the object code repaired against the current syntax error.
After the code repair for the current grammar error is completed, the repaired target code can be used as a new target code, the scanning is continuously performed based on the static scanning tool, if the new grammar error is obtained by scanning in the process, the steps can be repeated, the target code repair is performed for the new current grammar error, the repaired target code is used as the new target code, and the scanning is continuously performed based on the static scanning tool.
After the grammar errors are obtained through the operation, the grammar errors are repaired, and then the scanning is continued, the rule error detection of the complete target code can be completed based on the static scanning tool, so that all grammar errors in the target code are obtained, omission of grammar error scanning is avoided, and therefore richer reference information is provided for the error detection of the subsequent code.
Based on any of the above embodiments, in step 120, the repairing the current syntax error in the object code includes:
and inputting the current grammar error and the target code into a code large model to obtain the repaired target code output by the code large model.
Specifically, in the process of rule error detection based on a static scanning tool, in order to scan all grammar errors in the target code, it is necessary to repair the current grammar error after each grammar error detection. Code repair here may be implemented through a code large model.
Further, the current grammar error can be marked in the target code to obtain the code marked with the error to be repaired, and the code marked with the error to be repaired is input into the code large model, so that the code large model can repair the current grammar error.
According to the method provided by the embodiment of the invention, the grammar errors detected in the rule error detection process are repaired in real time through the code large model, so that the rule error detection can be continuously performed until all grammar errors in the target code are detected, and the execution efficiency of the code error detection is improved.
Based on any of the above embodiments, a code error detection method may include the following steps:
first, an object code to be detected is acquired.
Secondly, based on the static scanning tool, grammar error detection is carried out on the target code, under the condition that the static scanning tool outputs the current grammar error, the current grammar error in the target code is repaired by calling the code large model, and the target code after the current grammar error repair is completed is continuously applied to the grammar error detection of the static scanning tool, so that the static scanning tool can complete full code scanning on the target code, and detect all grammar errors in the target code.
In addition, the target code can be directly input into the code large model, the code large model carries out code repair on the target code, and the repair code output by the code large model is obtained. The object code and the repair code may then be compared to generate a repair record based on the comparison of the two, where the repair record includes the location of the repair and the contents of the repair.
And marking the grammar errors and the repair records in the target codes to obtain marked codes, inputting the marked codes into a code large model, and referring to the grammar errors and the repair records marked in the marked codes by the code large model to detect the code of the target codes so as to obtain the code error detection result of the target codes.
The method provided by the embodiment of the invention acquires the pre-error detection information capable of assisting in positioning the code error by carrying out the regular error detection and the code repair on the target code, and carries out the code error detection based on the pre-error detection information, thereby providing rich prompts for the code error detection, and effectively improving the reliability and the accuracy of the code error detection on the premise of realizing the automatic code error detection.
The code error detecting apparatus provided by the present invention will be described below, and the code error detecting apparatus described below and the code error detecting method described above may be referred to correspondingly to each other.
FIG. 4 is a schematic diagram of a code error detection apparatus according to the present invention, as shown in FIG. 4, the apparatus includes:
an acquisition unit 410 for acquiring an object code;
a pre-checking unit 420, configured to perform rule error detection on the target code and/or perform code repair on the target code, so as to obtain pre-checking information of the target code;
and an error detection unit 430, configured to detect code error of the target code based on the pre-error detection information.
The device provided by the embodiment of the invention acquires the pre-error detection information capable of assisting in positioning the code error by carrying out regular error detection and/or code repair on the target code, and carries out the code error detection based on the pre-error detection information, so that rich prompts are provided for the code error detection, and the reliability and the accuracy of the code error detection are effectively improved on the premise of realizing automatic code error detection.
Based on any of the above embodiments, the pre-detection unit is configured to:
performing rule error detection on the target code to obtain grammar error of the target code;
performing code repair on the target code to obtain a repair code, and determining a repair record corresponding to the target code based on a comparison result of the target code and the repair code;
determining the grammar error and/or the repair record as the pre-error detection information.
Based on any of the above embodiments, the repair record includes a location of the repair and/or content of the repair.
Based on any of the above embodiments, the error detection unit is configured to:
marking the pre-error detection information in the target code to obtain a marked code;
and inputting the labeling code into a code large model to obtain a code error detection result output by the code large model.
Based on any of the above embodiments, the error detection unit is configured to:
marking the grammar error in the pre-error detection information at the tail of a code line where the grammar error is located in the target code;
and/or the number of the groups of groups,
marking the single-row repair content in the target code at the end of the code row corresponding to the single-row repair content under the condition that the repair record in the pre-error detection information comprises the single-row repair content; in the case where the repair record includes multiple lines of repair content, the multiple lines of repair content are annotated in the object code in the form of segment annotations.
Based on any of the above embodiments, the pre-detection unit is configured to:
based on a static scanning tool, scanning grammar errors in the target code, repairing the current grammar errors in the target code under the condition that the current grammar errors are obtained by scanning, and returning the repaired target code as the target code to continue scanning until the scanning is completed.
Based on any of the above embodiments, the pre-detection unit is configured to:
and inputting the current grammar error and the target code into a code large model to obtain the repaired target code output by the code large model.
FIG. 5 illustrates a physical structure diagram of a code error detection all-in-one machine, as shown in FIG. 5, which may include: processor 510, communication interface (Communications Interface) 520, memory 530, and communication bus 540, wherein processor 510, communication interface 520, memory 530 complete communication with each other through communication bus 540. Processor 510 may invoke a computer program and code big model in memory 530 to perform a code error detection method comprising:
acquiring an object code;
performing rule error detection on the target code and/or performing code repair on the target code to obtain pre-error detection information of the target code;
and carrying out code error detection on the target code based on the pre-error detection information.
The code large model is used for realizing code error detection based on pre-error detection information and can also be used for realizing code repair.
Here, the code error detection all-in-one may be an all-in-one that privately deploys a large model of code. The large code model and the computer program for calling the model stored in the memory in the code error detection integrated machine can be obtained by downloading and installing based on a computer program installation package or an update package acquired by a model provider, wherein the large code model can be placed in the installation package or the update package in the form of a model file.
In addition, the computer program and the large model of code in the memory 530 may be implemented in the form of software functional units and stored in a computer readable storage medium when sold or used as a separate product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product comprising a computer program, the computer program being storable on a non-transitory computer readable storage medium, the computer program, when executed by a processor, being capable of performing the code error detection method provided by the above methods, the method comprising:
acquiring an object code;
performing rule error detection on the target code and/or performing code repair on the target code to obtain pre-error detection information of the target code;
and carrying out code error detection on the target code based on the pre-error detection information.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the code error detection method provided by the above methods, the method comprising:
acquiring an object code;
performing rule error detection on the target code and/or performing code repair on the target code to obtain pre-error detection information of the target code;
and carrying out code error detection on the target code based on the pre-error detection information.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A code error detection method, comprising:
acquiring an object code;
performing rule error detection on the target code and/or performing code repair on the target code to obtain pre-error detection information of the target code;
and carrying out code error detection on the target code based on the pre-error detection information.
2. The code error detection method according to claim 1, wherein the performing rule error detection on the target code and/or performing code repair on the target code to obtain pre-error detection information of the target code includes:
performing rule error detection on the target code to obtain grammar error of the target code;
performing code repair on the target code to obtain a repair code, and determining a repair record corresponding to the target code based on a comparison result of the target code and the repair code;
determining the grammar error and/or the repair record as the pre-error detection information.
3. The code error detection method of claim 2, wherein the repair record includes a location of the repair and/or content of the repair.
4. The code error detection method of claim 1, wherein the code error detection of the object code based on the pre-error detection information comprises:
marking the pre-error detection information in the target code to obtain a marked code;
and inputting the labeling code into a code large model to obtain a code error detection result output by the code large model.
5. The code error detection method of claim 4, wherein the marking the pre-error detection information in the object code to obtain a marked code comprises:
marking the grammar error in the pre-error detection information at the tail of a code line where the grammar error is located in the target code;
and/or the number of the groups of groups,
marking the single-row repair content in the target code at the end of the code row corresponding to the single-row repair content under the condition that the repair record in the pre-error detection information comprises the single-row repair content; in the case where the repair record includes multiple lines of repair content, the multiple lines of repair content are annotated in the object code in the form of segment annotations.
6. The code error detection method according to any one of claims 1 to 5, wherein the performing regular error detection on the object code includes:
based on a static scanning tool, scanning grammar errors in the target code, repairing the current grammar errors in the target code under the condition that the current grammar errors are obtained by scanning, and returning the repaired target code as the target code to continue scanning until the scanning is completed.
7. The code error detection method of claim 6, wherein the repairing the current syntax error in the object code comprises:
and inputting the current grammar error and the target code into a code large model to obtain the repaired target code output by the code large model.
8. A code error detection apparatus, comprising:
an acquisition unit configured to acquire an object code;
the pre-checking unit is used for carrying out rule error detection on the target code and/or carrying out code repair on the target code to obtain pre-checking information of the target code;
and the error detection unit is used for carrying out code error detection on the target code based on the pre-error detection information.
9. A code error detection all-in-one machine comprising a memory, a processor, a computer program stored on the memory and executable on the processor, and a code large model, wherein the processor is operative to implement the code error detection method of any one of claims 1 to 7 when invoking the code large model to execute the program, the code large model being operative to perform code error detection based on pre-error detection information.
10. A computer program product comprising a computer program which, when executed by a processor, implements the code error detection method of any of claims 1 to 7.
CN202311381153.0A 2023-10-23 2023-10-23 Code error detection method, device, all-in-one machine and program product Pending CN117435484A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311381153.0A CN117435484A (en) 2023-10-23 2023-10-23 Code error detection method, device, all-in-one machine and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311381153.0A CN117435484A (en) 2023-10-23 2023-10-23 Code error detection method, device, all-in-one machine and program product

Publications (1)

Publication Number Publication Date
CN117435484A true CN117435484A (en) 2024-01-23

Family

ID=89554673

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311381153.0A Pending CN117435484A (en) 2023-10-23 2023-10-23 Code error detection method, device, all-in-one machine and program product

Country Status (1)

Country Link
CN (1) CN117435484A (en)

Similar Documents

Publication Publication Date Title
CN110704297B (en) Code review method, device, computer equipment and storage medium
US11176329B2 (en) Source code compiler using natural language input
US20080086718A1 (en) Method and Apparatus for Identifying Authors of Changes Between Multiple Versions of a File
US8938383B2 (en) Enabling test script play back in different locales
CN117009231B (en) Automatic generation method and device for high-reliability unit test based on conversational large language model
KR101979329B1 (en) Method and apparatus for tracking security vulnerable input data of executable binaries thereof
US11250128B2 (en) System and method for detecting source code anomalies
CN114547318A (en) Fault information acquisition method, device, equipment and computer storage medium
CN116627848B (en) Automatic test method and system for application program
Seiler et al. Comparing traceability through information retrieval, commits, interaction logs, and tags
CN117435484A (en) Code error detection method, device, all-in-one machine and program product
CN117113080A (en) Data processing and code processing method, device, all-in-one machine and storage medium
Wuisang et al. An evaluation of the effectiveness of openai's chatGPT for automated python program bug fixing using quixbugs
CN112925874B (en) Similar code searching method and system based on case marks
CN115454445A (en) Code checking method and device, computer readable storage medium and terminal
US11366742B2 (en) Automated identification of lines of code related to errors field
CN114219438A (en) Document file distribution method, device, equipment and medium based on RPA and AI
Ronchieri et al. Sentiment analysis for software code assessment
CN112148581A (en) Code specification checking method, device, system and storage medium
CN114911698B (en) Automatic test method and device, electronic equipment and storage medium
CN112099837B (en) Software development support method, device and readable medium
CN112035367B (en) Method and system for checking workflow correctness of big data platform
CN114564400A (en) Method, device, medium and electronic equipment for guiding software test
CN112015653A (en) Problem positioning method, server and storage medium
CN117931150A (en) Method and device for automatically correcting code style

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination