Cppcheck incremental static code scanning method and system

Through the Cppcheck incremental static code scanning method, an incremental scan report is generated using the submission information and code difference files, which solves the problem of low incremental scanning efficiency in the code submission process in the prior art, and realizes efficient and accurate code defect detection.

CN119576739APending Publication Date: 2025-03-07BEIJING SIFANG JIBAO ENG TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411560414.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-04
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

The existing technology is difficult to realize efficient incremental static code scanning during the code submission process, which leads to long-term, many problems and is not detailed enough to effectively deal with incremental code scanning.

Method used

The Cppcheck incremental static code scanning method is used to obtain the submission information of the code submitted, generate the old version and the new version of the XML report, and parse it based on the code difference file, obtain line number change information, proofread the report to ensure consistency, and finally generate an incremental scan report.

Benefits of technology

It realizes efficient scanning of newly added and changed code files, which greatly shortens the time and improves accuracy. It can obtain code context background information, generate highly targeted incremental scanning reports, and directly obtain the defects introduced in this submission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576739A_ABST
    Figure CN119576739A_ABST
Patent Text Reader

Abstract

The invention discloses a Cppcheck incremental static code scanning method and a Cppcheck incremental static code scanning system. Obtaining a code change file list and a newly-added file list of primary code submission, all code files of the code change and the newly-added file and a new and old version code difference file; performing Cppcheck code scanning on the code files in the code change file list to generate an old version xml report; meanwhile, renaming all code files with changed codes and newly added codes, if files with changed or newly added code file includes are renamed files, carrying out file name change on include code lines, and generating a new version xml report after scanning; analyzing based on the code difference file of the new version and the old version to obtain line number changes of all changed same code files of the new version and the old version; checking the new version xml report based on the naming change information of the code file; checking the old version xml report based on the line number change information; and analyzing the new and old version xml reports based on the python xml related library, extracting code defects and problems introduced by newly added and changed codes, and generating an xml incremental scanning report. The code file scanning efficiency and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of code scanning, and in particular relates to a Cppcheck incremental static code scanning method and system. Background Art

[0002] Software quality is directly related to the credibility of the software and user satisfaction. Ensuring software quality is one of the important concerns of software development, and good code quality control is an important activity in software quality control. As a static code analysis method, code static checking can scan program code through lexical analysis, syntax analysis, and data flow analysis without running the code to find potential problems and defects in it, and provide the problem in the form of detection reports. The quality of the software is formed during the entire software development process. Discovering code defects at the code writing node can greatly reduce the cost of repairing defects. Static code scanning during code submission can effectively ensure the quality of the code base, discover potential problems and defects in advance, avoid excessive repair costs caused by late discovery of problems, and reduce later debugging and repair work.

[0003] Cppcheck is a static checking tool for C / C++ code defects. Different from C / C++ compilers and other analysis tools, Cppcheck is a supplementary check that performs strict logic checks on the product's source code. It only checks bugs that the compiler cannot check, and does not check syntax errors. The checks performed include automatic variable checks, array boundary checks, class checks, expired and obsolete function checks, abnormal memory and release checks, memory leak checks, operating system resource release checks, abnormal STL function usage checks, code format errors, etc. The Cppcheck open source code tool provides a parameter --xml for specifying the generation of xml reports. At the same time, Cppcheck supports developers to customize rules.

[0004] The current code scanning solution used in the code submission process is to perform a static scan of the entire code, which is time-consuming, has many problems, is difficult to fix at one time, and is not suitable for intercepting code submission through full problems; the detection of modified code files reflects the full problems of the modified code files, but the modified code files may only have changes to a certain function or even a certain line, which is not precise enough; only diff code is scanned, and the code context background code and variable definition initialization code content are missing, and the scanning is not accurate enough; the solution of using the svn blame command to obtain the submitted versions of different lines to remove the problems of the corresponding lines submitted last is only applicable after the code is successfully submitted, and cannot be obtained before the code is submitted. All existing technologies cannot effectively deal with incremental scanning of code. Summary of the invention

[0005] In order to solve the deficiencies in the prior art, the present invention provides a Cppcheck incremental static code scanning method and system to solve the technical problem that only incremental code defects are reflected during a code submission process.

[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions.

[0007] The present invention first discloses a Cppcheck incremental static code scanning method, which comprises the following steps:

[0008] Step 1: Obtain the submission information of a code submission, which includes a list of code change files and a list of newly added files, all code files of code changes, all newly added code files, and a file of differences between the new and old versions of the code;

[0009] Step 2: Perform Cppcheck code scanning on the code files in the code change file list to generate an old version xml report;

[0010] Step 3: While generating the old version XML report, rename all code files that have been changed and all newly added code files. If the file included in the changed or newly added code file is a renamed file, change the file name of the include code line and generate a new version XML report after scanning;

[0011] Step 4: Analyze the difference files between the new and old versions of the code to obtain the line number change information of the same code files of all changes between the new and old versions, so as to analyze the same problems in the new and old XML reports;

[0012] Step 5: Based on the naming change information of the code file, the new version of the XML report is proofread; based on the line number change information, the old version of the XML report is proofread. After the proofreading is completed, the same problems in the new and old versions of the XML report are consistent;

[0013] Step 6: Analyze the new and old version XML reports based on the Python XML related library, extract the code defects and problems introduced by the new code and the changed code in the new version, and generate the final XML incremental scanning report.

[0014] The present invention further includes the following preferred embodiments:

[0015] The step of obtaining submission information of a code submission further includes:

[0016] Use the svnlook changed command of the svnpre-commit hook to obtain the commit information of this code commit, where:

[0017] Use the svnlook cat command to obtain the code file after the code is added or changed, named

[0018] ${line}_${name}, where line is the line number of the code file in change.txt, and name is the file name of the code file; change.txt is a list of code changed files and newly added files, with one code file per line;

[0019] Use the svnlook diff command to obtain the code diff file and the diff of the baseline version.

[0020] The performing Cppcheck code scanning on the code files in the code change file list to generate an old version xml report further includes:

[0021] For the changed code file list oldchecklist in change.txt to be scanned, start the Cppcheck code scanning tool in the Cppcheck command line mode, and set the scanning parameters to cppcheck

[0022] --file-list=oldchecklist--xml--output-file=oldoutput, scans the old version of the code. After the scan is completed, the command execution ends.

[0023] The method further comprises: renaming all code files of code changes and all newly added code files, if the files included in the changed or newly added code files are renamed files, changing the file names of the included code lines, and generating a new version xml report after scanning, further comprising:

[0024] The checklist of newly added or changed code files in the change.txt file to be scanned is named ${line}_${name}. Both versions of the code are scanned at the same time.

[0025] Copy ${line}_${name} to the corresponding directory, start the Cppcheck code scanning tool in Cppcheck command line mode, and set the scanning parameter to cppcheck--file-list=checklist--xml

[0026] --output-file=newoutput, scan the new version of the code, and the command execution ends after the scan is completed.

[0027] The step of parsing the code difference file between the new and old versions to obtain line number change information of the same code file of all changes between the new and old versions further includes:

[0028] Read the diff file line by line until the reading is completed. When encountering the Modified mark, record the line number change of the next changed code file. When encountering content that indicates a new line or a deleted line starting with a + or - mark, calculate and record the line number change. After traversing line by line, obtain the line number change record of all changed codes, that is, the line number of a line in the old code after the change in the new code.

[0029] The method of proofreading the new version of the XML report based on the naming change information of the code file and proofreading the old version of the XML report based on the line number change information further includes:

[0030] For the new version of the XML report obtained by scanning, change the naming method of ${line}_${name} to

[0031] ${name}, perform this check to make the naming of each code file consistent with the old version of the XML report, so that the content of the same problem node is consistent;

[0032] For the scanned old version XML report, the line number change information of each problem is proofread and modified to the line number of the new version code, so that for the same problem, the problem description is consistent with that of the new version XML report.

[0033] The analysis of the new and old version XML reports based on the Python XML related library, extraction of code defects and problems introduced by the newly added code and the changed code in the new version, and generation of the final XML incremental scanning report further includes:

[0034] Use the xml.etree.ElementTree python library to load the error nodes of the old and new versions, and traverse the error problem nodes in the new report. If they already exist in the old version of the xml report node, it means that they are existing problems and they are filtered out; if they do not exist in the old version of the xml report node, it means that they are newly introduced problems and need to be retained; after the traversal is completed, assemble a new xml scan report, which is the final Cppcheck scan report with the submitted code added.

[0035] The present invention also discloses a Cppcheck incremental static code scanning system using the aforementioned Cppcheck incremental static code scanning method, comprising:

[0036] The submission information acquisition module is used to obtain the submission information of a code submission, wherein the submission information includes a list of code changed files and a list of newly added files, all code files of code changes, all newly added code files, and a file of differences between the new and old versions of the code;

[0037] An old version XML report generation module is used to perform Cppcheck code scanning on the code files in the code change file list to generate an old version XML report;

[0038] The new version XML report generation module is used to rename all code files that have been changed and all newly added code files while generating the old version XML report. If the file included in the changed or newly added code file is a renamed file, the file name of the included code line is changed, and the new version XML report is generated after scanning;

[0039] The line number change acquisition module is used to parse the code difference files between the new and old versions to obtain the line number change information of the same code file of all changes between the new and old versions, so as to analyze the same problems in the new and old XML reports;

[0040] A proofreading module is used to proofread the new version of the XML report based on the naming change information of the code file; proofread the old version of the XML report based on the line number change information, and after the proofreading is completed, the same problems in the new and old versions of the XML report are consistent;

[0041] The scanning report generation module is used to analyze the new and old versions of XML reports based on the Python XML related library, extract the code defects and problems introduced by the new code and the changed code in the new version, and generate the final XML incremental scanning report.

[0042] Accordingly, the present application also discloses a terminal, including a processor and a storage medium;

[0043] The storage medium is used to store instructions;

[0044] The processor is used to operate according to the instructions to execute the steps of the aforementioned Cppcheck incremental static code scanning method.

[0045] Correspondingly, the present application also discloses a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the aforementioned Cppcheck incremental static code scanning method are implemented.

[0046] The beneficial effects of the present invention are that compared with the prior art, the present invention provides a Cppcheck incremental static code scanning method and system, which scans based on the entire newly added and changed code files, which greatly shortens the time consumption compared to scanning all code files and has high efficiency; other code context background information except diff code can be obtained, including the intermediate process of variable definition and assignment, etc., which has higher accuracy than directly scanning diff code; after scanning, the code diff file is parsed to obtain the code line number changes between the new and old codes, and the old xml report is compared with the new xml report after line number proofreading, which can remove historical code problems irrelevant to the current submission, making the report more targeted and directly obtaining the defects newly introduced by the code submitted this time. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 It is a flow chart of the Cppcheck incremental static code scanning method in the present invention.

[0048] Figure 2 It is a flow chart of parsing code diff in the present invention to obtain the line number changes of the new and old versions.

[0049] Figure 3 This is a sample description of the XML report obtained by the Cppcheck static code scanning in the present invention. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the present invention more clear, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0051] The embodiments described in this application are only some embodiments of the present invention, not all embodiments. Based on the spirit of the present invention, other embodiments obtained by ordinary technicians in this field without creative work are all within the protection scope of the present invention.

[0052] In view of the deficiencies in the prior art, the present invention proposes a Cppcheck incremental static code scanning method and system, which obtains defects in the incremental code through code scanning based on the incremental code submitted once, and generates a report, so as to intercept problems before the code is submitted, avoiding problems such as missing variable definitions and missing context of the code caused by only scanning the diff code, and scans the entire code file with changes and additions twice, and then extracts the newly introduced problems after scanning.

[0053] See also Figure 1 As shown, the Cppcheck incremental static code scanning method disclosed in the present invention comprises the following steps:

[0054] Step 1: Obtain the submission information of a code submission, which includes a list of code change files and a list of newly added files, all code files of code changes, all newly added code files, and a file of differences between the new and old versions of the code.

[0055] The code submission of the present invention is based on the SVN version management tool, and has nothing to do with the type of code version management tool used. The SVN look changed command of the SVN pre-commit hook is used to obtain the submission information of this code submission, including:

[0056] Code change file list and new file list change.txt, one code file per line, new additions are marked with A, and changes are marked with U;

[0057] Use the svnlook cat command to obtain the code file after the code is added or changed, named

[0058] ${line}_${name}. Where line is the line number of a code file in change.txt, and name is the file name of the code file;

[0059] Use the svnlook diff command to obtain the code diff file and the diff of the baseline version.

[0060] Step 2: Perform Cppcheck code scanning on the code files in the code change file list to generate an old version xml report.

[0061] For the changed code file list oldchecklist in change.txt to be scanned, start the Cppcheck code scanning tool in the Cppcheck command line mode, and set the scanning parameters to cppcheck

[0062] --file-list=oldchecklist--xml--output-file=oldoutput, scans the old version of the code. After the scan is completed, the command execution ends.

[0063] Step 3: While generating the old version of the XML report, rename all code files that have been changed and all newly added code files. If the files included in the changed or newly added code files are renamed files, change the file names of the include code lines and generate a new version of the XML report after scanning.

[0064] Prepare a checklist of code files to be scanned (the code files added or changed in change.txt), and name it as a list of codes named ${line}_${name}, which is used to start scanning two versions at the same time to reduce time. Copy these new code files ${line}_${name} to the corresponding directory, start the Cppcheck code scanning tool in the Cppcheck command line mode, and set the scanning parameters to "cppcheck

[0065] --file-list=checklist--xml--output-file=newoutput", scan the new version of the code, and the command ends after the scan is completed. After the old version scan process is completed, both scans are completed.

[0066] Step 4: Analyze the difference files between the new and old versions of the code to obtain the line number change information of the same code file of all changes between the new and old versions, so as to analyze the same problems in the new and old XML reports.

[0067] Parse the diff code file to obtain the line number changes of the modified code file. Only the modified files in the diff file are considered, because only the modified files will have line number changes. The parsing process is as follows Figure 2 As shown. Read the diff file line by line until the reading is finished. If Modified is encountered, it means that the line number change of the next modified code file needs to be re-recorded. If a new line or a deleted line is found starting with a + or - sign, the line number change is calculated and recorded. After traversing line by line, the line number change record of all the modified codes is obtained, that is, the line number of a line in the old code after the change in the new code.

[0068] Step 5: Based on the naming change information of the code file, proofread the new version of the XML report; based on the line number change information, proofread the old version of the XML report. After the proofreading is completed, the same problems in the new and old versions of the XML report remain consistent.

[0069] For the new version of the XML report obtained by scanning, change the naming method of ${line}_${name} to

[0070] ${name}, perform this proofreading to make the naming of each code file consistent with the old version of the XML report, so that the content of the same problem node can be consistent.

[0071] For the old version of the XML report obtained by scanning, the line numbers of each problem are checked according to the line number change information obtained above, and modified to the line numbers of the new version of the code, so that for the same problem, the problem description is consistent with that of the new version of the XML report. The format of the XML report is as follows: Figure 3 shown.

[0072] Step 6: Analyze the new and old version XML reports based on the Python XML related library, extract the code defects and problems introduced by the new code and the changed code in the new version, and generate the final XML incremental scanning report.

[0073] Compare the nodes of the new and old versions of the XML report, extract the new issues in the new version, and assemble them into a new XML report, which is the new defect introduced in this submission.

[0074] The python library of xml.etree.ElementTree loads the error nodes of the old and new versions, and traverses the error problem nodes in the new report. If the error node already exists in the old version of the XML report node, it means that it is an existing problem and it is filtered out. If the error node does not exist in the old version of the XML report node, it means that it is a newly introduced problem and needs to be retained. After the traversal is completed, a new XML scan report is assembled, which is the final Cppcheck scan report with the submitted code added. In the final report, if there is an error node problem, the submission will be intercepted.

[0075] The beneficial effects of the present invention are that compared with the prior art, the present invention provides a Cppcheck incremental static code scanning method and system, which scans based on the entire newly added and changed code files, which greatly shortens the time consumption compared to scanning all code files and has high efficiency; other code context background information except diff code can be obtained, including the intermediate process of variable definition and assignment, etc., which has higher accuracy than directly scanning diff code; after scanning, the code diff file is parsed to obtain the code line number changes between the new and old codes, and the old xml report is compared with the new xml report after line number proofreading, which can remove historical code problems irrelevant to the current submission, making the report more targeted and directly obtaining the defects newly introduced by the code submitted this time.

[0076] The present invention may be a system, a method and / or a computer program product. The present invention also discloses a Cppcheck incremental static code scanning system based on the aforementioned Cppcheck incremental static code scanning method, comprising:

[0077] The submission information acquisition module is used to obtain the submission information of a code submission, wherein the submission information includes a list of code changed files and a list of newly added files, all code files of code changes, all newly added code files, and a file of differences between the new and old versions of the code;

[0078] An old version XML report generation module is used to perform Cppcheck code scanning on the code files in the code change file list to generate an old version XML report;

[0079] The new version XML report generation module is used to rename all code files that have been changed and all newly added code files while generating the old version XML report. If the file included in the changed or newly added code file is a renamed file, the file name of the included code line is changed, and the new version XML report is generated after scanning;

[0080] The line number change acquisition module is used to parse the code difference files between the new and old versions to obtain the line number change information of the same code file of all changes between the new and old versions, so as to analyze the same problems in the new and old XML reports;

[0081] A proofreading module is used to proofread the new version of the XML report based on the naming change information of the code file; proofread the old version of the XML report based on the line number change information, and after the proofreading is completed, the same problems in the new and old versions of the XML report are consistent;

[0082] The scanning report generation module is used to analyze the new and old versions of XML reports based on the Python XML related library, extract the code defects and problems introduced by the new code and the changed code in the new version, and generate the final XML incremental scanning report.

[0083] Based on the spirit of the present invention, those skilled in the art can easily think that a computer program product can be obtained based on the aforementioned Cppcheck incremental static code scanning method. The computer program product may include a computer-readable storage medium, which carries computer-readable program instructions for enabling a processor to implement various aspects of the present disclosure. That is, the present application also includes a terminal, including a processor and a storage medium; the storage medium is used to store instructions; the processor is used to operate according to the instructions to perform the steps according to the aforementioned Cppcheck incremental static code scanning method.

[0084] Computer readable storage medium can be a tangible device that can keep and store the instructions used by the instruction execution device. Computer readable storage medium can be, for example, - but not limited to - electrical storage device, magnetic storage device, optical storage device, electromagnetic storage device, semiconductor storage device or any suitable combination of the above. More specific examples (non-exhaustive list) of computer readable storage medium include: portable computer disk, hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD), memory stick, floppy disk, mechanical encoding device, for example, punch card or groove protrusion structure with instructions stored thereon and any suitable combination of the above. Computer readable storage medium used here is not interpreted as instantaneous signal itself, such as radio wave or other free propagating electromagnetic wave, electromagnetic wave propagated by waveguide or other transmission medium (for example, light pulse by optical fiber cable) or electrical signal transmitted by wire.

[0085] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0086] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages-such as Smalltalk, C++, etc., and conventional procedural programming languages-such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network-including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA) may be personalized by utilizing the state information of a computer-readable program instruction, and the electronic circuit may execute a computer-readable program instruction, thereby realizing various aspects of the present disclosure.

[0087] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A Cppcheck incremental static code scanning method, characterized in that: The following steps are involved: Step 1: Obtain the submission information of a code submission, which includes a list of code change files and a list of newly added files, all code files of code changes, all newly added code files, and a file of differences between the new and old versions of the code; Step 2: Perform Cppcheck code scanning on the code files in the code change file list to generate an old version xml report; Step 3: While generating the old version of the XML report, rename all code files with code changes and all newly added code files to generate a new version of the XML report; Step 4: Analyze the difference files between the new and old versions of the code to obtain the line number change information of the same code files of all changes between the new and old versions, so as to analyze the same problems in the new and old XML reports; Step 5: Based on the naming change information of the code file, the new version of the XML report is proofread; based on the line number change information, the old version of the XML report is proofread. After the proofreading is completed, the same problems in the new and old versions of the XML report are consistent; Step 6: Analyze the new and old version XML reports based on the Python XML related library, extract the code defects and problems introduced by the new code and the changed code in the new version, and generate the final XML incremental scanning report.

2. The Cppcheck incremental static code scanning method according to claim 1, characterized in that: The step of obtaining submission information of a code submission further includes: Use the svnlook changed command of the svnpre-commit hook to obtain the commit information of this code commit, where: Use the svnlook cat command to obtain the newly added or changed code files, named ${line}_${name}, where line is the line number of the code file in change.txt, and name is the file name of the code file; change.txt is a list of code changed files and a list of newly added files, with one code file per line; Use the svnlook diff command to obtain the code diff file and the diff of the baseline version.

3. The Cppcheck incremental static code scanning method according to claim 2, characterized in that: The performing Cppcheck code scanning on the code files in the code change file list to generate an old version xml report further includes: For the changed code file list oldchecklist in change.txt to be scanned, start the Cppcheck code scanning tool in the Cppcheck command line mode, and set the scanning parameters to cppcheck --file-list=oldchecklist--xml--output-file=oldoutput, scans the old version of the code. After the scan is completed, the command execution ends.

4. The Cppcheck incremental static code scanning method according to claim 3, characterized in that: The method further comprises: renaming all code files of code changes and all newly added code files, if the files included in the changed or newly added code files are renamed files, renaming the file names of the included code lines, and generating a new version of the XML report; Prepare to scan the new or changed code files in the change.txt checklist, and name it as a list of ${line}_${name} codes, and start scanning of both versions at the same time; copy the new code file ${line}_${name} to the corresponding directory, start the Cppcheck code scanning tool in the Cppcheck command line mode, and set the scanning parameter to cppcheck--file-list=checklist--xml --output-file=newoutput, scan the new version of the code, and the command execution ends after the scan is completed.

5. The Cppcheck incremental static code scanning method according to claim 4, characterized in that: The step of parsing the code difference file between the new and old versions to obtain line number change information of the same code file of all changes between the new and old versions further includes: Read the diff file line by line until the reading is completed. When encountering the Modified mark, record the line number change of the next changed code file. When encountering content that indicates a new line or a deleted line starting with a + or - mark, calculate and record the line number change. After traversing line by line, obtain the line number change record of all changed codes, that is, the line number of a line in the old code after the change in the new code.

6. The Cppcheck incremental static code scanning method according to claim 5, characterized in that: The method of proofreading the new version of the XML report based on the naming change information of the code file and proofreading the old version of the XML report based on the line number change information further includes: For the new version of the XML report obtained by scanning, change the naming method of ${line}_${name} to ${name} and perform this proofreading to make the naming of each code file consistent with the old version of the XML report so that the content of the same problem node remains consistent; For the scanned old version XML report, the line number change information of each problem is proofread and modified to the line number of the new version code, so that for the same problem, the problem description is consistent with that of the new version XML report.

7. The Cppcheck incremental static code scanning method according to claim 6, characterized in that: The analysis of the new and old version XML reports based on the Python XML related library, extraction of code defects and problems introduced by the newly added code and the changed code in the new version, and generation of the final XML incremental scanning report further includes: Use the xml.etree.ElementTree python library to load the error nodes of the old and new versions, and traverse the error problem nodes in the new report. If they already exist in the old version of the xml report node, it means that they are existing problems and they are filtered out; if they do not exist in the old version of the xml report node, it means that they are newly introduced problems and need to be retained; after the traversal is completed, assemble a new xml scan report, which is the final Cppcheck scan report with the submitted code added.

8. A Cppcheck incremental static code scanning system, characterized in that: include: The submission information acquisition module is used to obtain the submission information of a code submission, wherein the submission information includes a list of code changed files and a list of newly added files, all code files of code changes, all newly added code files, and a file of differences between the new and old versions of the code; An old version XML report generation module is used to perform Cppcheck code scanning on the code files in the code change file list to generate an old version XML report; The new version XML report generation module is used to rename all code files with code changes and all newly added code files while generating the old version XML report to generate a new version XML report; The line number change acquisition module is used to parse the code difference files between the new and old versions to obtain the line number change information of the same code file of all changes between the new and old versions, so as to analyze the same problems in the new and old XML reports; A proofreading module is used to proofread the new version of the XML report based on the naming change information of the code file; proofread the old version of the XML report based on the line number change information, and after the proofreading is completed, the same problems in the new and old versions of the XML report are consistent; The scanning report generation module is used to analyze the new and old versions of XML reports based on the Python XML related library, extract the code defects and problems introduced by the new code and the changed code in the new version, and generate the final XML incremental scanning report.

9. A terminal comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is used to operate according to the instructions to execute the steps of the Cppcheck incremental static code scanning method according to any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the Cppcheck incremental static code scanning method described in any one of claims 1 to 7 are implemented.