Assembly line detection method and system for software codes, storage medium and program product
Through the automated pipeline detection method, static standard detection of software code, input interface detection and redundant code detection are realized, solving the problem of time-consuming and labor-intensive manual detection and inconsistent results, and significantly improving the efficiency of software development and code quality.
Patent Information
- Application Number
- CN202411890134.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-15
AI Technical Summary
The existing software code detection relies on manual operations, which leads to time-consuming and labor-intensive, inconsistent detection results, inefficient efficiency, and difficult to meet the needs of rapid development.
Through pipeline configuration, static specification detection of code, input interface detection and redundant code detection are automatically implemented to ensure the consistency of code quality and automatically merge the code after the detection is completed.
It significantly improves the efficiency of software development, reduces errors caused by human operations, ensures the standardization, consistency and integrity of the submitted code, thereby improving the quality and reliability of the overall software.
Smart Images

Figure CN119829403A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software development, and in particular to a pipeline detection method, system, storage medium and program product for software codes. Background Art
[0002] With the continuous development of information technology and software development technology, the scale and complexity of software systems are increasing, and the software development process is becoming more complicated. In modern software development, agile development and CI / CD (Continuous Integration / Continuous Delivery) have gradually become mainstream, which requires that code quality detection and automated processes become particularly important during the development process. Especially in large-scale projects or multi-person collaborative development environments, code submission and integration occur frequently. How to effectively ensure code quality and improve detection efficiency has become a key issue in the field of software engineering.
[0003] At present, the software code detection process mainly relies on manual work. Developers usually ensure code quality and consistency by manually checking code specifications, verifying the consistency of data interfaces, and cleaning up redundant code after each code submission or merge. However, manual operations are not only time-consuming and labor-intensive, but also easily affected by human factors, making it difficult to ensure the reliability of the detection results. For projects that require frequent delivery and continuous integration, manual detection and integration can no longer meet the needs of rapid development. Therefore, there is an urgent need for a method that can automatically perform various tests, effectively integrate detection and reporting functions to improve development efficiency, reduce errors caused by human operations, and improve code quality. Summary of the invention
[0004] The purpose of the present invention is to solve the problems of time-consuming and labor-intensive manual operation, inconsistent detection results and low efficiency in the existing software code detection process. The present invention provides a pipeline detection method, system, storage medium and program product for software code, which can automatically realize static specification detection, input interface detection and redundant code detection of code through pipeline configuration, ensure the consistency of code quality, and automatically merge the code after the detection is completed, so as to realize an efficient and reliable code detection process, which can significantly improve the efficiency of software development, reduce errors caused by human operation, ensure the standardization, consistency and integrity of the submitted code, and thus improve the quality and reliability of the overall software.
[0005] In order to solve the above technical problems, the embodiment of the present invention discloses a pipeline detection method for software code.
[0006] First, build a Git repository, which includes the first code resource file and configuration file;
[0007] Secondly, obtain a second code resource file for merging with the first code resource file;
[0008] The pipeline detection method includes the following steps:
[0009] S101, the configuration file includes a static specification template, a static specification detection is performed on the second code resource file based on the static specification template, and the detection result is recorded in the pipeline report;
[0010] S102, perform input interface detection on the second code resource file, extract the input interface and output interface of the first code resource file and the second code resource file, respectively establish an input interface library and an output interface library in the Git repository, compare the input interface and the output interface library of the second code resource file, mark the input interface of the second code resource file that does not have a corresponding item in the output interface library as an unmatched interface, and record the detection result in the pipeline report;
[0011] S103, performing redundant code detection on the second code resource file, comparing the input interface library and the output interface library, marking the output interface in the output interface library that is not referenced by the input interface of the input interface library as a redundant interface, and recording the detection result in the pipeline report;
[0012] S104: Perform a merging operation on the second code resource file, merge the second code resource file that has completed static specification detection, input interface detection, and redundant code detection into the first code resource file, and generate a third code resource file.
[0013] The above technical solution can realize the pipeline operation of the code detection process, reduce the time and operation cost of manual detection, and ensure the consistency and reliability of code quality. Through static specification detection, input interface detection and redundant code detection, it can systematically identify the normative problems, mismatched interfaces and redundant code modules in the code, thereby ensuring the integrity and compatibility of the code before the code is merged, effectively shortening the development cycle and improving the efficiency and quality of software detection.
[0014] Optionally, step S101 includes: the static specification template includes descriptive information of the code specification requirements, the code specification requirements include at least one of the code format, naming rules and comment specifications, a static specification rule file is generated based on the static specification template, the static specification rule file is a structured data file, and includes configuration rules for the code specification requirements, the second code resource file is checked against the static specification rule file item by item, and non-conforming items are detected. The checking is implemented by an automated static code analysis tool, the automated static code analysis tool identifies the code specification requirements in the second code resource file, generates detection results, and records non-conforming items found during the checking process in the pipeline report.
[0015] Optionally, step S102 further includes: recording at least one of the name, location, description and repair suggestion of the unmatched interface in the pipeline report.
[0016] Optionally, step S103 further includes: deleting redundant interfaces, and recording at least one of the names, locations, reasons for not being referenced, and cleanup suggestions of the redundant interfaces in the pipeline report.
[0017] Optionally, step S104 further includes: compiling the third code resource file to generate a target code and storing the target code in a delivery file.
[0018] Optionally, the configuration file also includes a YML configuration file. When the second code resource file is obtained and is ready to be merged, the pipeline detection is started through the YML configuration file.
[0019] Optionally, the Git repository also includes a script file, and the script file is used to automatically execute steps S101, S102, S103 and S104.
[0020] The embodiment of the present invention further discloses a computer system, including a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the above pipeline detection method.
[0021] The embodiment of the present invention further discloses a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above pipeline detection method are implemented.
[0022] The embodiment of the present invention further discloses a computer program product, including a computer program, which implements the steps of the above pipeline detection method when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A schematic flow chart of a pipeline detection method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0024] The following specific embodiments illustrate the implementation of the present invention, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Although the description of the present invention will be introduced in conjunction with the preferred embodiment, this does not mean that the features of this invention are limited to this implementation. On the contrary, the purpose of introducing the invention in conjunction with the implementation is to cover other options or modifications that may extend based on the claims of the present invention. In order to provide a deep understanding of the present invention, the following description will include many specific details. The present invention can also be implemented without using these details. In addition, in order to avoid confusion or blurring the focus of the present invention, some specific details will be omitted in the description. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
[0025] It should be noted that in this specification, similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0026] The terms “first”, “second”, etc. are only used for distinguishing descriptions and should not be understood as indicating or implying relative importance.
[0027] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0028] In view of the problem that manual operation in the software code detection process leads to inconsistent detection quality and low efficiency, and it is difficult to meet the needs of rapid development, an embodiment of the present invention application discloses a pipeline detection method, system, storage medium and program product for software code. By completing the detection and merging of codes in an automated pipeline manner, rapid team development can be achieved, the time for manual operation and problem troubleshooting can be reduced, the software quality and reliability can be improved, and the team's collaboration and innovation capabilities can be enhanced.
[0029] The embodiment of the present application discloses a pipeline detection method for software code. First, a Git repository is constructed, and the Git repository includes a first code resource file and a configuration file. Second, a second code resource file is obtained for merging with the first code resource file.
[0030] like Figure 1 As shown, the pipeline detection method includes the following steps:
[0031] S101: Performing static specification detection on the second code resource file based on the static specification template, and recording the detection result in the pipeline report;
[0032] S102: extracting the input interface and output interface of the first code resource file and the second code resource file, establishing an input interface library and an output interface library, performing input interface detection on the second code resource file, and recording the detection result in a pipeline report;
[0033] S103: Perform redundant code detection on the second code resource file, compare the input interface library and the output interface library, mark the output interface in the output interface library that is not referenced by the input interface of the input interface library as a redundant interface, and record the detection result in the pipeline report;
[0034] S104: Merge the second code resource file that has completed static specification detection, input interface detection, and redundant code detection into the first code resource file to generate a third code resource file.
[0035] The above technical solutions can effectively realize the automation and efficiency of code quality detection. The Git repository provides unified data support for subsequent code detection and merging; through static specification detection, input interface detection and redundant code detection, it can systematically identify normative problems, mismatched interfaces and redundant code modules in the code, thereby ensuring the integrity and compatibility of the code before the code is merged; through automated code merging, the development cycle can be effectively shortened, and the efficiency and quality of software development can be improved. The pipeline report records the detection status of each step in detail, which is convenient for tracking and review, thereby further improving the reliability of software development.
[0036] Before entering the pipeline test, first use the Git tool to establish a Git repository. The Git repository may include a first code resource file and a configuration file, wherein the first code resource file may include the source code and dependency library of the Git repository. The source code, dependency library, and configuration file are respectively stored in multiple key folders such as the source code folder, dependency library folder, and configuration folder. Among them, the source code folder is used to store the core code modules of the software, and is divided into multiple subfolders according to the functional modules. Each module corresponds to a separate directory to ensure the modularity and readability of the code; the dependency library folder contains all external dependent library files, such as third-party libraries and common code modules, to support the operation of the software; the configuration folder is used to store the configuration files required for the system operation, such as environment variables, static specification templates, database connection parameters, and test configuration files, etc., to ensure the consistency of the development and testing environments.
[0037] Secondly, obtain a second code resource file for merging with the first code resource file. The second code resource file includes the code to be detected. The code to be detected is the code created and modified based on the source code. The code to be detected depends on the source code. The source code is used to compare with the code to be detected. The code to be detected can become a part of the source code after detection and merging. The source code can be understood as the code in the main branch or core branch, and the code to be detected can also be understood as the code in the functional branch or development branch.
[0038] The Git repository may also include script files, which are stored in a script folder. The script files may include a static specification detection script, an input interface detection script, a redundant code detection script, and an automation script, which are respectively used to automatically execute steps S101 to S104.
[0039] Further, the configuration file may include a static specification template, which is used for static specification detection. The configuration file may also include a YML configuration file for defining the execution order, conditions and dependencies of the pipeline detection. When the second code resource file is obtained and prepared for merging, the pipeline detection is started through the YML configuration file. The YML configuration file is written in YAML format, divides the pipeline detection into multiple stages, and constructs the tasks (jobs) of each detection step. The dependency order is set by the dependency (needs) keyword, and the relevant configuration file is loaded when the corresponding detection script is called at each stage.
[0040] Furthermore, the configuration file may also include an error mechanism configuration file, which is used to define the processing logic when non-conformance items or abnormal items are encountered during the detection process. The error mechanism configuration file can set whether the pipeline continues to execute subsequent steps or stops immediately when a problem is found during the detection process. At the same time, the error mechanism configuration file can also define different levels of errors such as warning errors or blocking errors, and configure the notification method when an error is detected.
[0041] In the pipeline detection application example, pipeline detection can be triggered when the code to be detected is submitted to the functional branch. At this time, the YML configuration file will be loaded to initialize the pipeline steps and dependencies. After that, each detection step will be executed according to the order, conditions and dependencies defined in the YML configuration file, and the detection results will be recorded in the pipeline report. If an error is found during the detection, it will be decided whether to terminate the pipeline based on the error mechanism configuration.
[0042] Hereinafter, according to the embodiments of the present application, the above steps S101 to S104 are described in detail.
[0043] It should be noted in advance that static specification detection is a method of analyzing code to verify whether the code conforms to predefined coding standards and style requirements. It uses automated scripts to scan code files line by line, check against static specification templates, record non-conformities and their locations, and output detection reports to improve code readability and maintainability and reduce potential code defects, such as inconsistent naming and formatting issues. Input interface detection is a verification method for code input and output interfaces to ensure the correctness and consistency of interface calls, and to verify whether the input interface in the code to be detected has a match in the output interface of the existing code. The existing code includes source code and dependent libraries, which are compared through automated scripts to ensure that the code to be detected correctly calls the existing interface to prevent runtime errors caused by interface call mismatches. Redundant code detection is used to identify parts of the code that are not called or referenced. By comparing the input interface and the output interface, the unreferenced output interface is identified, marked as redundant, and unused code is cleaned up to reduce code size and improve code quality.
[0044] In step S101, the static specification template includes high-level description information for the code specification requirements. The code specification requirements may include at least one of the code format, naming rules and comment specifications. The static specification template cannot be executed directly and needs to be converted into an executable rule file. Exemplarily, the static specification template may include descriptive code specification requirements such as "code format", "variable naming rules" and "unused imports", which cannot be directly used to perform static specification detection. It is necessary to further formulate detection standards through rule files for execution by automated static code analysis tools.
[0045] Since there are some differences in the choice of programming language and code specification requirements during the project development process, in the static specification detection step, it is necessary to generate a static specification rule file based on the static specification template according to the actual needs of the project and the standard specification requirements in this field. The static specification rule file is a structured data file, including the configuration rules required by the code specification. For example, in actual detection, the variable name is required to use camel case, and the "variable naming rule" in the static specification template needs to be converted into "^[az][A-Za-z0-9]*$" and other configuration rule contents.
[0046] The second code resource file is checked against the static specification rule file item by item to detect non-conformities. The check is implemented through an automated static code analysis tool. The automated static code analysis tool identifies the code specification requirements in the second code resource file, generates detection results, and records the non-conformities found during the check process in the pipeline report.
[0047] Specifically, in the embodiment of the present application, static specification detection is performed based on the simulink tool to detect whether there is array overflow, division by zero, dead logic, etc.
[0048] In step S102, for the input interface detection process, the embodiment of the present application further refines the detection process of input interface detection on the second code resource file. First, the input interface detection script is used to automatically extract the input interface and output interface of the first code resource file and the second code resource file, respectively establish the input interface library and the output interface library in the Git warehouse, compare the input interface and the output interface library of the second code resource file, and detect whether the input interface of the second code resource file has a corresponding item in the output interface library to ensure that the input interface is correctly matched. The matching judgment rules may include: whether the interface name is consistent, whether the number and type of parameters are consistent, and whether the data structure is consistent. When the input interface of the second code resource file does not have a corresponding item in the output interface library, the input interface is marked as an unmatched interface, and the unmatched interface is recorded in the pipeline report. At least one of the name, location, description and repair suggestion of the unmatched interface is recorded in the pipeline report. In this embodiment, the input interface detection script uses a Python script. The extraction and comparison of the data interface is performed through an automated process, while improving efficiency and reducing errors caused by manual operation.
[0049] In step S103, a redundant code detection script is used to perform redundant code detection on the second code resource file, and the input interface library and the output interface library are compared. For each interface in the output interface library, it is checked whether there is a matching input interface in the input interface library to identify redundant output interfaces in the output interface library that are not referenced by the input interface in the input interface library. The matching judgment rules may include: whether the interface names are consistent, whether the number and type of parameters are consistent, and whether the data structure is consistent. Once it is detected that the output interface lacks a matching input interface, these output interfaces that do not meet the matching rules will be marked as redundant output interfaces. For these redundant output interfaces, the system will perform a cleanup operation to remove them from the code to improve code efficiency and maintainability. The cleanup results will be recorded in the pipeline report, and the pipeline report can record at least one of the name, location, reason for not being referenced, and cleanup suggestions of the redundant output interface.
[0050] In step S104, after the above-mentioned detection is passed, the second code resource file will be merged into the first code resource file to generate a third code resource file, that is, the code to be detected that has successfully passed the above-mentioned detection will be merged from the functional branch or development branch to the main branch or core branch to generate updated code. After the merger is completed, the code to be detected becomes part of the main branch code.
[0051] Furthermore, the third code resource file, i.e., the code in the main branch, is compiled through an automated script to generate target code, which is then stored in the delivery file to provide direct support for subsequent integration and deployment. The target code is the code product generated after compilation. In different languages and scenarios, the target code may be in different forms, such as executable files or bytecode files.
[0052] In summary, the technical solution of the embodiment of the present application can meet the project's needs for rapid development, especially projects that require frequent delivery and continuous integration, by integrating the code detection and merging process in the software development process into the pipeline in an automated manner, significantly improving software development efficiency, effectively ensuring code quality and consistency, and improving development efficiency.
[0053] It should be noted that although the embodiments of the present application are based on Figure 1 Steps S101 to S104 are described in sequence, but this does not mean that steps S101 to S104 must be performed in a strict order. Figure 1 The order shown in the figure is to introduce and explain step S101 to step S104 in sequence, in order to facilitate those skilled in the art to understand the technical solution of the embodiment of the present application. In other words, in the embodiment of the present application, the order between step S101 to step S104 can be appropriately adjusted according to actual needs.
[0054] Based on the same concept, another embodiment of the present application further provides a computer system, including a memory, a processor, and a computer program stored in the memory, and the processor executes the computer program to implement the steps of the above-mentioned pipeline detection method.
[0055] Based on the same concept, another embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned pipeline detection method are implemented.
[0056] Based on the same concept, another embodiment of the present application further provides a computer program product, including a computer program, which implements the steps of the above-mentioned pipeline detection method when executed by a processor.
[0057] Although the present invention has been illustrated and described with reference to certain preferred embodiments of the present invention, it should be understood by those skilled in the art that the above is a further detailed description of the present invention in conjunction with specific embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. Those skilled in the art may make various changes in form and details, including making several simple deductions or substitutions, without departing from the spirit and scope of the present invention.
Claims
1. A pipeline detection method for software code, First, a Git repository is constructed, wherein the Git repository includes a first code resource file and a configuration file; Secondly, obtaining a second code resource file for merging with the first code resource file; The pipeline detection method is characterized in that it comprises the following steps: S101, the configuration file includes a static specification template, static specification detection is performed on the second code resource file based on the static specification template, and the detection result is recorded in a pipeline report; S102: Perform input interface detection on the second code resource file, extract the input interface and output interface of the first code resource file and the second code resource file, respectively establish an input interface library and an output interface library in the Git repository, compare the input interface of the second code resource file with the output interface library, mark the input interface of the second code resource file that has no corresponding item in the output interface library as an unmatched interface, and record the detection result in the pipeline report; S103, performing redundant code detection on the second code resource file, comparing the input interface library and the output interface library, marking the output interface in the output interface library that is not referenced by the input interface of the input interface library as a redundant interface, and recording the detection result in the pipeline report; S104: Perform a merging operation on the second code resource file, merge the second code resource file that has completed the static specification detection, the input interface detection, and the redundant code detection into the first code resource file, and generate a third code resource file.
2. The pipeline detection method according to claim 1, characterized in that: Step S101 includes: the static specification template includes description information of the code specification requirements, the code specification requirements include at least one of the code format, naming rules and comment specifications, a static specification rule file is generated based on the static specification template, the static specification rule file is a structured data file, including the configuration rules of the code specification requirements, the second code resource file is checked against the static specification rule file item by item to detect non-compliant items, the checking is implemented by an automated static code analysis tool, the automated static code analysis tool identifies the code specification requirements in the second code resource file, generates detection results, and records the non-compliant items found during the checking process in the pipeline report.
3. The pipeline detection method according to claim 1, characterized in that: Step S102 also includes: recording at least one of the name, location, description and repair suggestion of the unmatched interface in the pipeline report.
4. The pipeline detection method according to claim 1, characterized in that: Step S103 also includes: deleting the redundant interface, and recording at least one of the name, location, reason for not being referenced, and cleaning suggestion of the redundant interface in the pipeline report.
5. The pipeline detection method according to claim 1, characterized in that: Step S104 also includes: compiling the third code resource file to generate a target code and storing the target code in a delivery file.
6. The pipeline detection method according to any one of claims 1 to 5, characterized in that: The configuration file also includes a YML configuration file. When preparing to merge after acquiring the second code resource file, the pipeline detection is started through the YML configuration file.
7. The pipeline detection method according to any one of claims 1 to 5, characterized in that: The Git repository also includes a script file, and the script file is used to automatically execute steps S101, S102, S103 and S104.
8. A computer system comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.