File library configuration method and device for code quality test, equipment and storage medium
By automatically configuring the project configuration file of the Polyspace code quality testing tool, the inefficiency and error problems caused by manual configuration are solved, and efficient and accurate code quality testing is achieved to ensure the stability and reliability of software products.
Patent Information
- Application Number
- CN202510418451.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-07-22
AI Technical Summary
The configuration files that configure the Polyspace code quality testing tool in the prior art need to be manually configured item by item, resulting in cumbersome process, error-prone, inefficient, and waste of resources, affecting the accuracy of the test results and the quality of the software.
By creating a new test project, obtain compiler tool information and macro definition variables, write it to the project configuration file, and enable or disable multiple inspection configurations according to project requirements to achieve automated configuration.
Improve the accuracy and efficiency of code quality testing, reduce manual errors, ensure that the test environment is consistent with the actual compilation environment, fully cover key areas of the project, and improve the stability and reliability of software products.
Smart Images

Figure CN120353694A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical fields of software testing and automated configuration, and particularly to a method, apparatus, device, and storage medium for configuring a file library for code quality testing. Background Art
[0002] In today's digital age, the quality and reliability of software are crucial for all industries. Errors and defects in software code can lead to serious consequences, including security risks, performance degradation, and increased costs. Therefore, in order to ensure the correctness of software, major OEMs generally use code quality testing tools to uniformly test software code to discover problems that are difficult to observe by the human eye during static execution. This testing requirement has given rise to the need for automated and precise configuration of code quality testing tools.
[0003] Currently, Polyspace, as a mainstream code quality testing software, is widely used in major OEMs. When using Polyspace for code quality testing, it is usually necessary to configure the Configuration file item by item after importing the compiled code. These configuration steps are relatively fixed. For example, configurations such as Macros, Target&Compiler, etc. can be directly obtained from the settings.py file, and configurations such as Calculate Code Metrics are almost the same for all vehicle models. The current practice is to perform these configurations manually, and a large amount of repetitive content needs to be filled in each time.
[0004] There are multiple problems in the process of manually configuring the Configuration file. First, due to the cumbersome and repetitive configuration steps, this not only consumes time and effort but also is prone to errors, especially when extracting configuration information from the settings file (settings.py). Second, since the configurations for each vehicle model are almost the same, the repetitive manual operations result in a waste of resources and low efficiency. These problems not only increase the testing cost but may also affect the accuracy of the test results due to human errors, thereby affecting the final quality of the software. Therefore, how to efficiently and accurately configure the file library required for code quality testing has become an urgent problem to be solved.
[0005] The above content is only used to assist in understanding the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0006] The purpose of this application is to provide a method, apparatus, device, and storage medium for configuring a file library for code quality testing, aiming to solve the technical problem of how to efficiently and accurately configure the file library required for code quality testing.
[0007] To achieve the above object, the present application proposes a method for configuring a file library for code quality testing, the method comprising:
[0008] Create a test project and obtain the project requirements of the test project;
[0009] Obtain the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information;
[0010] Write the compiler tool information, the macro definition variables, and a preset uncompiled-stop analysis rule into the project configuration file of the test project;
[0011] Enable or disable multiple inspection configurations in the project configuration file according to the project requirements to complete the configuration of the file library.
[0012] In one embodiment, the step of obtaining the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information includes:
[0013] Obtain the path of the settings file of the test project;
[0014] Find the settings file according to the path;
[0015] Extract the compiler tool information from the settings file through a target regular expression;
[0016] Match and extract the macro definition variables from the settings file according to the compiler tool information.
[0017] In one embodiment, the step of extracting the compiler tool information from the settings file through a target regular expression includes:
[0018] Read all the content in the settings file into a string variable;
[0019] Obtain the format of the compiler tool information;
[0020] Determine the target regular expression according to the format;
[0021] Find a matching item that matches the target regular expression in the string variable through the search function in the regular expression library;
[0022] Extract the compiler tool information from the matching item through the capture group in the regular expression library.
[0023] In one embodiment, the step of matching and extracting the macro definition variables from the settings file according to the compiler tool information includes:
[0024] Read the settings file to obtain the file content;
[0025] Parse the content of the said file to obtain conditional compilation statements;
[0026] Search for the macro definition parameters in the compiler tool information in the said conditional compilation statements to obtain macro definition variables.
[0027] In one embodiment, the step of enabling or disabling multiple check configurations in the said project configuration file according to the project requirements and completing the configuration of the file library includes:
[0028] When the project requirements include following programming standards, enable or disable the programming rule check configuration in the said project configuration file;
[0029] When the project requirements include code review and maintenance history, enable or disable the code review tracking configuration in the said project configuration file;
[0030] When the project requirements include static code quality inspection, enable or disable the static code analysis configuration in the said project configuration file;
[0031] When the project requirements include test sufficiency requirements, enable or disable the code coverage check configuration in the said project configuration file to complete the configuration of the file library.
[0032] In one embodiment, the step of enabling or disabling multiple check configurations in the said project configuration file according to the project requirements and completing the configuration of the file library includes:
[0033] When the project requirements include performance optimization and resource management, enable or disable the memory leak detection configuration in the said project configuration file;
[0034] When the project requirements include concurrent and multi-threaded programming, enable or disable the thread safety check configuration in the said project configuration file;
[0035] When the project requirements include error handling and exception management, enable or disable the exception handling check configuration in the said project configuration file;
[0036] When the project requirements include software security requirements, enable or disable the security check configuration in the said project configuration file to complete the configuration of the file library.
[0037] In one embodiment, after the step of enabling or disabling multiple check configurations in the said project configuration file according to the project requirements and completing the configuration of the file library, it further includes:
[0038] Import the source code files and header files that need to be tested for code quality into the said test project;
[0039] Perform code quality testing according to the imported test project and the project configuration file.
[0040] In addition, to achieve the above object, the present application also proposes a file library configuration device for code quality testing, the device includes:
[0041] A project establishment module, configured to create a new test project and obtain the project requirements of the test project;
[0042] A data acquisition module, configured to acquire the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information;
[0043] A configuration writing module, configured to write the compiler tool information, the macro definition variables, and a preset uncompiled-stop analysis rule into the project configuration file of the test project;
[0044] A configuration start / stop module, configured to enable or disable multiple check configurations in the project configuration file according to the project requirements, and complete the configuration of the file library.
[0045] In addition, to achieve the above object, the present application also proposes a file library configuration device for code quality testing, the device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program is configured to implement the steps of the file library configuration method for code quality testing as described above.
[0046] In addition, to achieve the above object, the present application also proposes a storage medium, the storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium, and when the computer program is executed by a processor, it implements the steps of the file library configuration method for code quality testing as described above.
[0047] In addition, to achieve the above object, the present application also provides a computer program product, the computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps of the file library configuration method for code quality testing as described above.
[0048] One or more technical solutions proposed by the present application have at least the following technical effects:
[0049] Create a new test project and obtain the project requirements of the test project; obtain the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information; write the compiler tool information, the macro definition variables, and a preset uncompiled-stop analysis rule into the project configuration file of the test project; enable or disable multiple check configurations in the project configuration file according to the project requirements to complete the configuration of the file library. The file library configuration system first creates a new test project and clarifies the detailed requirements of the project, such as performance optimization and resource management, etc., which is to ensure that the test environment can be customized according to the project characteristics. Then, the system obtains the compiler tool information and macro definition variables related to the test project, and these information are crucial for ensuring the accuracy of code quality testing because they directly affect the compilation process and behavior of the code. Then, the system writes these compiler tool information, macro definitions, and preset uncompiled-stop analysis rules into the.psprj project configuration file, automating the test configuration by editing XML tags, reducing manual errors, and ensuring that the test environment is consistent with the actual compilation environment. Finally, the system enables or disables multiple check configurations in the project configuration file according to the project requirements, such as memory leak detection, thread safety check, etc., to complete the configuration of the file library, ensuring that the code quality testing can comprehensively cover all key areas concerned by the project. These steps enable the file library configuration system to efficiently and accurately configure the file library required for code quality testing, thereby improving the pertinence and accuracy of testing, reducing manual errors, enhancing development efficiency, discovering potential problems in advance, and improving code quality, ultimately leading to a more stable and reliable software product. Brief Description of the Drawings
[0050] The drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0052] Figure 1 It is a schematic flowchart provided for the first embodiment of the file library configuration method for code quality testing of the present application;
[0053] Figure 2 It is a schematic flowchart provided for the second embodiment of the file library configuration method for code quality testing of the present application;
[0054] Figure 3 It is a schematic diagram of the module structure of the file library configuration device for code quality testing of the embodiments of the present application;
[0055] Figure 4 This is a schematic diagram of the device structure of the hardware operating environment involved in the file library configuration method for code quality testing in the embodiments of the present application.
[0056] The implementation, functional features, and advantages of the present application will be further described in conjunction with embodiments and with reference to the accompanying drawings. Detailed implementation manners
[0057] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0058] For a better understanding of the technical solutions of the present application, the following will be described in detail in conjunction with the drawings in the specification and specific implementation manners.
[0059] In the digital age, software quality and reliability are crucial. Major vehicle manufacturers generally use code quality testing tools (such as Polyspace) to detect potential problems in code and ensure software correctness. However, currently, when using Polyspace, it is necessary to manually configure the Configuration file item by item, including extracting fixed configuration information from the settings.py file. This process is cumbersome, error-prone, and inefficient, especially when dealing with multiple vehicle models, wasting resources and increasing testing costs. These problems not only reduce work efficiency but may also affect the accuracy of test results due to human errors, thereby affecting software quality. Therefore, the need for automated and precise configuration of code quality testing tools is becoming increasingly urgent.
[0060] The main solution of the embodiments of the present application is as follows: First, create and clarify the detailed requirements of the new test project, such as performance optimization and resource management. Then, obtain relevant compiler tool information and macro definition variables, and write this information and preset rules into the.psprj project configuration file to achieve automated configuration by editing XML tags, ensuring consistency with the actual compilation environment and reducing manual errors. Finally, enable or disable various check configurations (such as memory leak detection, thread safety check, etc.) according to the project requirements to complete the configuration to ensure that the code quality testing comprehensively covers all key areas.
[0061] It should be noted that the execution subject of the embodiments of the present application can be a computing service device with data processing, network communication, and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a file library configuration system, etc. that can implement the above functions. Hereinafter, the file library configuration system will be taken as an example to illustrate this embodiment and the following embodiments.
[0062] Based on this, the embodiments of the present application provide a file library configuration method for code quality testing, with reference to Figure 1 ,Figure 1 This is a schematic flowchart of the first embodiment of the method for configuring a file library for code quality testing of this application.
[0063] In this embodiment, the method for configuring a file library for code quality testing includes steps S10 to S40:
[0064] Step S10, create a test project and obtain the project requirements of the test project;
[0065] It should be noted that a test project refers to a specific project or task for code quality testing using Polyspace software. This project usually refers to a software project or software component that needs to undergo code quality testing to ensure it meets certain quality standards. In Polyspace software, a test project usually corresponds to a.psprj file, which is a project file containing all the configurations and settings required for code quality testing. Creating a new test project means creating a new project in Polyspace software to establish a test environment for specific software code. Project requirements refer to a series of detailed requirements that need to be met during software development and testing. These requirements cover multiple aspects such as software function implementation, performance efficiency, reliability and stability, security, compatibility, maintainability and scalability, code quality, environment and deployment, as well as testing and quality assurance, to ensure that the software product can run efficiently, safely, and stably and meet the needs of users and the business.
[0066] It can be understood that, first of all, the file library configuration system needs to create a new test project in Polyspace software, which usually involves creating a new.psprj project file that will contain all the configuration information required for subsequent testing; secondly, the system needs to configure project parameters according to the specific requirements of the test project, which includes determining the target language, compiler version, macro definitions, etc. These parameters will directly affect the scope and depth of code quality testing. The system obtains these requirements by analyzing project files and user inputs, rather than extracting them from the settings.py file; finally, the system writes these parameters into the.psprj file to ensure that during the code quality testing process, Polyspace can correctly analyze and evaluate the code according to these configurations. This automates the configuration process of the test project, reduces manual configuration errors and repetitive labor, improves the accuracy and efficiency of testing, and also provides a stable and reliable basis for subsequent code quality analysis.
[0067] Step S20, obtain the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information;
[0068] It should be noted that the compiler tool information refers to the relevant information of the compiler used to compile the test project code. In code quality testing, it is important to know the compiler used and its version, because it determines the specific behavior during code compilation and the rules for code quality inspection. The compiler tool information refers to information such as the name, version, and target processor of the compiler. These information are usually used to configure the.psprj file in Polyspace software to ensure that the test tool can correctly understand and analyze the source code. For example, if the IAR_ARM compiler is used, this information needs to be accurately configured in the test project. Macro definition variables refer to compiler instructions used for conditional compilation or replacing predefined text during compilation. In languages such as C / C++, macro definitions usually start with '-D', followed by the macro name and an optional value. Macro definitions can change the behavior of the code during compilation or replace text in the code during compilation. In this embodiment, macro definition variables refer to those macros defined in the settings.py file and need to be imported into the.psprj file so that Polyspace can correctly perform code analysis based on these macro definitions during code quality testing. For example, if a macro definition is '-DDEBUG', then all code blocks between '#ifdef DEBUG' and '#endif' in the code will be included for debugging-related code quality testing.
[0069] It can be understood that, first, the file library configuration system identifies the compiler tool information by parsing the configuration file or project settings of the test project, which usually involves looking for parameters such as the compiler name, version, and target processor specified in the configuration file; then, the system queries the associated macro definition variables based on the identified compiler tool information, which involves accessing a macro definition database or configuration file to extract the macro definition instructions starting with '-D' and their values; finally, the system stores or passes these macro definition variables together with the compiler tool information to subsequent configuration steps for use in code quality testing. Doing so can ensure that the test environment is consistent with the actual compilation environment, thereby improving the accuracy and reliability of code quality testing.
[0070] Step S30, write the compiler tool information, the macro definition variables, and the preset uncompiled-stop analysis rules into the project configuration file of the test project;
[0071] It should be noted that the preset uncompiled-stop analysis rule means that during the code quality testing process, if it is found that a file fails to be successfully compiled, the test should automatically stop the analysis. This is a quality assurance measure to ensure that only the code that has been completely compiled successfully will be further analyzed, so as to avoid misleading results in code quality analysis. In the Polyspace software, this rule can be implemented by setting a specific configuration item. For example, add the following configuration item to the.psprj file: <option flagname="-stop-if-compile-error">true< / option> . When this option is set to true, Polyspace will stop the analysis when it encounters a compilation error. The project configuration file, that is, the.psprj file, is the file used to store the configuration of a specific test project in the Polyspace software. This file contains all the settings and parameters required for code quality testing, including compiler tool information, macro definition variables, code analysis rules, etc. The.psprj file is the key for Polyspace to recognize and execute the test configuration, and it guides Polyspace on how to analyze and evaluate code quality.
[0072] It can be understood that, first, the file library configuration system extracts the compiler tool information by reading the configuration file or project properties of the test project. The specific operation is to determine the compiler and its version used by parsing specific fields in the configuration file, such as `COMPILER_TOOL`; second, the system looks for the macro definition variables that match the extracted compiler tool information. The operation is to access the macro definition list in the configuration file, identify the macro instructions starting with `-D`, and record these macro definitions; then, the system sets the uncompiled-stop analysis rule. The specific approach is to add an XML tag, such as ` <option flagname="-stop-if-compile-error">true< / option> `, in the.psprj file. This step is to ensure that once an error is found during the code compilation process, the test can automatically stop and avoid further analysis of the error code; finally, the system writes this information into the.psprj file. This is done programmatically by using the file operation API to directly write the extracted compiler information, macro definitions, and the uncompiled-stop analysis rule to the corresponding positions in the.psprj file. This ensures that when the Polyspace tool performs code quality testing, it can perform accurate analysis according to the specific compilation environment and preset rules of the project, improving the efficiency and accuracy of the test, and at the same time reducing the problem of inaccurate test results caused by configuration errors.
[0073] Step S40, enable or disable multiple check configurations in the project configuration file according to the project requirements to complete the configuration of the file library.
[0074] It should be noted that the inspection configuration refers to the specific parameters and rules used to control code quality inspection in the Polyspace code quality testing software. These configurations determine which inspections will be performed, which code issues will be analyzed, and how these results will be reported during the code quality testing process. Specifically, the inspection configuration can include, but is not limited to, the following aspects: (1) Code standard compliance inspection: For example, whether to enable the compliance inspection of coding standards such as MISRA C:2012. (2) Compilation error inspection: Whether to stop the analysis when an error occurs during code compilation. (3) Macro definition and preprocessor directive inspection: Whether to check the correct use of macro definitions and the legality of preprocessor directives. (4) Code complexity and maintainability inspection: Analyze the complexity of the code and check whether there are overly complex functions or modules that affect the maintainability of the code. (5) Security inspection: Detect possible security vulnerabilities in the code, such as buffer overflows, improper use of unsafe APIs, etc. (6) Performance inspection: Analyze the code performance and check whether there are inefficient algorithm implementations or improper resource usage. (7) Code style and normativity inspection: Check whether the code follows specific coding styles and norms, such as naming conventions, comment specifications, etc.
[0075] It can be understood that, first, the file library configuration system will identify which code quality inspections need to be performed according to the specific requirements of the test project. This may include inspections in aspects such as code standard compliance, compilation errors, macro definitions, code complexity, security, performance, and code style. Then, the system will enter the.psprj project configuration file and enable or disable these inspections by modifying or adding corresponding XML configuration tags. For example, if it is necessary to enable the MISRA C:2012 standard inspection, tags such as ` <option flagname="-misra-agc-mode">true< / option> ` will be added or modified. Finally, the system saves the modified.psprj file to complete the configuration of the file library, ensuring that the Polyspace software can perform analysis according to these customized inspection configurations when conducting code quality testing, thereby generating test results that meet the project requirements. Doing so makes the code quality testing more in line with the actual project needs and improves the pertinence and effectiveness of the testing.
[0076] As an example, the steps of enabling or disabling multiple inspection configurations in the project profile according to the engineering requirements and completing the configuration of the file library include: when the engineering requirements include following programming standards, enabling or disabling the programming rule inspection configuration in the project profile; when the engineering requirements include code review and maintenance history, enabling or disabling the code review tracking configuration in the project profile; when the engineering requirements include static code quality inspection, enabling or disabling the static code analysis configuration in the project profile; when the engineering requirements include test sufficiency requirements, enabling or disabling the code coverage inspection configuration in the project profile to complete the configuration of the file library.
[0077] Following programming standards means following a series of predefined programming rules and best practices, such as MISRA C:2012, ISO 26262, etc. during the software development process to ensure the quality and consistency of the code. The programming rule inspection configuration refers to the settings in the project profile (.psprj file) used to control the code quality tool (such as Polyspace) to check whether the code follows specific programming standards. Enabling these configurations can ensure that the code complies with industry standards and best practices. Code review and maintenance history mean that during the software development process, the code is reviewed to ensure quality, and at the same time, the change history of the code is recorded to facilitate tracking problems and maintenance. The code review tracking configuration refers to the settings in the project profile used to track changes and history during the code review process, which helps the team understand the reasons and history of code changes and perform subsequent maintenance. Static code quality inspection means using tools to analyze the code to discover potential errors, vulnerabilities, code style issues, etc. without running the code. The static code analysis configuration refers to the settings in the project profile used to control the specific analysis types and depths performed by the static code analysis tool, such as complexity analysis, potential runtime error checking, etc. Test sufficiency requirements mean ensuring that the tests cover all important functions and scenarios to verify the quality and reliability of the software. The code coverage inspection configuration refers to the settings in the project profile used to control the code coverage tool to check whether the tests cover all parts of the code, including branch, statement, and condition coverage, etc.
[0078] First, for the requirement in the engineering needs to comply with programming standards, the file library configuration system will find the corresponding programming rule check configuration section by editing the.psprj project configuration file. For example, it will search for the `<check name="MISRA">` tag and set it to enabled (set to `<check name="MISRA" enabled="true">`) or disabled (set to `<check name="MISRA" enabled="false">`) according to the requirements. This is to ensure that the code can be automatically checked for compliance with specific programming standards during code quality testing. Second, if the engineering needs include code review and maintenance history, the system will find the code review tracking configuration section in the.psprj file, such as the `<review_tracking>` tag, and enable or disable the code review tracking function according to the requirements. This usually means that during the code quality testing process, the system will record the details of each code review and the change history for subsequent code maintenance and problem tracking. Then, for the engineering needs that require static code quality checking, the system will enable or disable the static code analysis configuration in the.psprj file, which may involve modifying the relevant settings of the `<static_analysis>` tag to ensure that code quality analysis can be automatically performed during code testing to identify potential code problems. Finally, if the engineering needs include test sufficiency requirements, the system will enable or disable the code coverage check configuration in the.psprj file, which may involve modifying the relevant settings of the `<code_coverage>` tag to ensure that the tests can cover all important code paths and verify the test sufficiency of the software. After completing these configurations, the.psprj file will be customized according to the specific requirements of the project, enabling the code quality testing to more accurately reflect the actual quality of the code, improving the efficiency and accuracy of the testing, and ensuring the reliability of the final software product.
[0079] As an example, the steps of enabling or disabling multiple check configurations in the project configuration file according to the engineering needs to complete the configuration of the file library include: when the engineering needs include performance optimization and resource management, enabling or disabling the memory leak detection configuration in the project configuration file; when the engineering needs include concurrent and multi-threaded programming, enabling or disabling the thread safety check configuration in the project configuration file; when the engineering needs include error handling and exception management, enabling or disabling the exception handling check configuration in the project configuration file; when the engineering needs include software security requirements, enabling or disabling the security check configuration in the project configuration file to complete the configuration of the file library.
[0080] Performance optimization and resource management refer to optimizing code during software development to improve its running efficiency and effectively managing resource usage, such as memory, CPU, etc., to avoid resource waste and bottlenecks. Memory leak detection configuration refers to the settings in the project configuration file used to control the code quality tool to detect memory leaks. Enabling this configuration can identify memory resources that are not properly released in the code and prevent memory leak problems during program operation. Concurrent and multi-threaded programming refer to using multi-threaded technology in software development to enable the program to execute multiple tasks simultaneously and improve the program's parallel processing ability. Thread safety check configuration refers to the settings in the project configuration file used to control the code quality tool to detect thread safety issues. Enabling this configuration can identify code segments in the code that may cause race conditions, deadlocks, and other thread safety problems. Error handling and exception management refer to correctly handling errors and exceptions that may occur during program operation in software development to ensure the robustness and stability of the program. Exception handling check configuration refers to the settings in the project configuration file used to control the code quality tool to detect the correctness of exception handling. Enabling this configuration can ensure the correctness of the exception handling logic in the code and avoid exceptions being ignored or mishandled. Software security requirements refer to the security standards and requirements that the software needs to meet, including data protection, prevention of unauthorized access, and network attacks, etc. Security check configuration refers to the settings in the project configuration file used to control the code quality tool to detect the security of the code. Enabling this configuration can identify potential security vulnerabilities and risks in the code, such as insecure API calls, sensitive information leakage, etc.
[0081] First, if performance optimization and resource management are emphasized in the engineering requirements, the file library configuration system will find the memory leak detection configuration item in the.psprj project configuration file, such as the setting marked as `<memory_leak_detection>`, and enable or disable it according to the requirements, because memory leaks can seriously affect the performance and stability of the application. Second, in the face of engineering requirements that require concurrent and multi-threaded programming, the system will find the thread safety check configuration item in the.psprj file, such as `<thread_safety_check>`, and perform corresponding enabling or disabling operations to ensure code security in a multi-threaded environment and avoid race conditions. Then, for engineering requirements that need to strengthen error handling and exception management, the system will locate the exception handling check configuration item in the.psprj file, such as `<exception_handling_check>`, and adjust its enabled state to ensure that exceptions in the code are properly handled. Finally, for projects with software security requirements, the system will find the security check configuration item in the.psprj file, such as `<security_check>`, and enable or disable it to detect security vulnerabilities and risks in the code. After completing these configurations, the.psprj file will be customized according to the specific requirements of the project, enabling the code quality test to more accurately reflect the actual quality of the code, improving the efficiency and accuracy of the test, and ensuring the reliability and security of the final software product.
[0082] As an example, after the step of enabling or disabling multiple check configurations in the project configuration file according to the engineering requirements and completing the configuration of the file library, the following steps are further included: importing the source code files and header files that need to be subjected to code quality testing into the test project; performing a code quality test according to the imported test project and the project configuration file.
[0083] Source code files refer to files that contain actual programming code. These files are usually written in specific programming languages such as C, C++, Java, etc. Source code files contain the logic and functional implementation of the program and are the direct objects processed by the compiler during the compilation process. For example, in the C language, source code files usually have the extensions.c or.cpp. Header files refer to files that declare variables, macros, function prototypes, and other type definitions used in the program. They are usually used to share program interfaces and definitions between different source code files. Header files enable different parts of the program to communicate with each other without repeating code. In C and C++, header files usually have the extensions.h or.hpp.
[0084] First, the file library configuration system will browse and select the source code files (.c,.cpp, etc.) and header files (.h,.hpp, etc.) that need to be subjected to code quality testing through the user interface or command-line tool of Polyspace software, and then add these files to the test project. This is done to ensure that all the code participating in the test is included in the analysis scope. Secondly, the system will configure Polyspace software according to the rules and standards set in the.psprj project configuration file before, such as programming rule checking, memory leak detection, thread safety checking, etc. This is done to customize the test process to meet the quality requirements of a specific project. Finally, the system executes the code quality test. Polyspace software will perform static analysis on the imported source code and header files according to the configuration in the.psprj file, identify potential code problems and risks. This can discover and fix code defects in advance, improve code quality, reduce potential runtime errors and performance problems in the future, thereby enhancing the overall stability and reliability of the software.
[0085] This embodiment provides a method for configuring a file library for code quality testing. A new test project is created, and the project requirements of the test project are obtained; the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information are obtained; the compiler tool information, the macro definition variables, and a preset uncompiled-stop analysis rule are written into the project configuration file of the test project; multiple check configurations in the project configuration file are enabled or disabled according to the project requirements to complete the configuration of the file library. The file library configuration system first creates a new test project and clarifies the detailed requirements of the project, such as performance optimization and resource management, etc. This is to ensure that the test environment can be customized according to the characteristics of the project. Then, the system obtains the compiler tool information and macro definition variables related to the test project. These information are crucial for ensuring the accuracy of code quality testing because they directly affect the compilation process and behavior of the code. Then, the system writes these compiler tool information, macro definitions, and the preset uncompiled-stop analysis rule into the.psprj project configuration file, automating the test configuration by editing XML tags, reducing manual errors, and ensuring that the test environment is consistent with the actual compilation environment. Finally, the system enables or disables multiple check configurations in the project configuration file according to the project requirements, such as memory leak detection, thread safety checking, etc., to complete the configuration of the file library, ensuring that the code quality testing can comprehensively cover all key areas concerned by the project. These steps enable the file library configuration system to efficiently and accurately configure the file library required for code quality testing, thereby improving the pertinence and accuracy of the test, reducing manual errors, enhancing development efficiency, discovering potential problems in advance, and improving code quality, ultimately resulting in a more stable and reliable software product.
[0086] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar content as that in the above-mentioned first embodiment can be referred to the above introduction and will not be repeated hereinafter. On this basis, please refer to Figure 2 , Figure 2 which is a schematic flowchart of the second embodiment of the method for configuring a file library for code quality testing according to the present application. The step S20 of the method for configuring a file library for code quality testing includes steps S21 to S24:
[0087] Step S21, obtain the path of the settings file of the test project;
[0088] It should be noted that the settings file (settings.py) refers to a Python script file that is usually used to store and manage project configuration information. Such a file contains various settings and parameters, which are used to define project-specific configurations, such as compiler tool information, macro-defined variables, and other options related to building and testing. The settings.py file is usually used in automated build and test processes because it can be read by scripts and tools to obtain the necessary configuration information. The path refers to the specific location of the settings file in the file system, which is a string representing the complete directory route from the root directory of the file system to the file. In a computer, the path is used to uniquely identify a file or directory in the file system. For example, if the settings.py file is located in the config subdirectory of the project, then its path may be / path / to / project / config / settings.py.
[0089] It can be understood that, first, the file library configuration system will prompt the user to browse and select the'settings.py' settings file included in the test project through a graphical user interface, or let the user enter the complete path of the file through a command-line interface; second, the system will verify whether the input path is correct, check whether the file exists and has read permissions. This step is to ensure the validity of the path and avoid configuration failures due to path errors or permission problems during the configuration process; finally, once the path is confirmed to be correct, the system will use this path to access the'settings.py' file and read the configuration information therein, such as compiler tool information and macro-defined variables, etc. By doing so, the system can accurately obtain all necessary project configuration information, so as to correctly automatically configure the test project and ensure that the code quality testing can be executed according to the predetermined project requirements and standards, improving the accuracy and efficiency of the testing.
[0090] Step S22, find the settings file according to the path;
[0091] It is understandable that, first, the file library configuration system will use the file operation APIs provided by the programming language, such as the `os.path` or `pathlib` modules in Python, to parse the path string provided by the user; then, the system will search level by level in the file system according to the parsed path until it finds the settings file named `settings.py`. During this process, the system may check each directory entry, match the file name, and confirm whether the file type is a Python script file; finally, once the file is found, the system will record its full path and prepare to read the file content for subsequent extraction of configuration data such as compiler tool information and macro definition variables. Doing so can ensure that the configuration system can accurately locate and access the `settings.py` file containing key project configuration information, providing the necessary input data for automated test configuration.
[0092] Step S23, extracting compiler tool information from the settings file through a target regular expression;
[0093] It should be noted that the target regular expression refers to a specific regular expression pattern, which is designed to match and identify the compiler tool information in the `settings.py` settings file. A regular expression is a tool for describing text patterns, which can be used to retrieve and replace text that conforms to a certain pattern. The target regular expression will contain patterns for finding the compiler tool name and version. For example, if the compiler tool information in the `settings.py` file is expressed as COMPILER_TOOL = 'GCC_7.3.0', then the target regular expression may be COMPILER_TOOL\s*=\s*'([^']+)'. The meaning of this expression is:
[0094] COMPILER_TOOL: Matches the literal "COMPILER_TOOL" in the text.
[0095] \s*: Matches any number of whitespace characters (including spaces, tabs, etc.).
[0096] =: Matches the equal sign.
[0097] \s*: Matches any number of whitespace characters again.
[0098] ': Matches a single quote.
[0099] ([^']+)': Matches and captures any characters within the single quotes (until the next single quote is encountered). This part is the core of the regular expression and is used to extract the specific information of the compiler tool.
[0100] In this way, the file library configuration system can extract the name and version information of the compiler tool from the settings.py file, so as to use this information to configure the test environment in subsequent code quality tests.
[0101] It can be understood that, first of all, the file library configuration system will define a target regular expression, which is specifically used to match the pattern representing the compiler tool information in the ˋsettings.pyˋ file. For example, if the compiler tool information appears in the form of ˋCOMPILER_TOOL='IAR_ARM'ˋ, then the regular expression may be ˋCOMPILER_TOOL\s*=\s*'([^']+)'ˋ; then, the system uses this regular expression to search in the text content of the ˋsettings.pyˋ file to find the line that matches this pattern; then, when a match is found, the system will extract the matching compiler tool information, that is, the part corresponding to the capture group in the regular expression, which is the compiler name and version within the single quotes; finally, the extracted compiler tool information will be used for subsequent test project configuration to ensure that the test environment can correctly simulate the actual compilation process. Doing so enables the file library configuration system to extract key information from the configuration file, reduce manual input errors, and improve the accuracy and efficiency of configuration.
[0102] As an example, the step of extracting the compiler tool information from the setting file through the target regular expression includes: reading all the content in the setting file into a string variable; obtaining the format of the compiler tool information; determining the target regular expression according to the format; using the search function in the regular expression library to find the match that matches the target regular expression in the string variable; extracting the compiler tool information from the match through the capture group in the regular expression library.
[0103] A string variable refers to a variable used to store string data in a programming language. In this embodiment, the string variable is used to temporarily store all the content read from the settings.py file. For example, in Python, a string variable content can be created using content = "", and then the file content can be read into this variable. Format refers to the representation or structure of compiler tool information in the settings.py file. For instance, the compiler tool information may appear in the form of a key-value pair like COMPILER_TOOL = 'IAR_ARM', where COMPILER_TOOL is the key and 'IAR_ARM' is the value. A regular expression library refers to a built-in library or module in a programming language for handling regular expressions. For example, in Python, the re module is a library for handling regular expressions, providing functions such as compiling regular expressions and searching for matches. A search function refers to a function in the regular expression library used to search for a match to a regular pattern in text. In the re module of Python, the search() function is used to perform such a search, which will find the first result that matches the regular expression in the given string. A match refers to the part of the text found by the regular expression search function that matches the regular pattern. For example, if the regular expression is COMPILER_TOOL\s*=\s*'([^']+)', then 'IAR_ARM' is the match because it conforms to this pattern. A capture group In a regular expression, parentheses () are used to create a capture group, which can capture a part of the matched string. In the above regular expression, ([^']+) is a capture group that captures any characters between single quotes ', i.e., the specific name and version information of the compiler tool.
[0104] First, the file library configuration system will open the'settings.py' configuration file and use the file reading operation to load all the content in the file into a string variable. For example, in Python, code like 'with open('settings.py', 'r') as file: content = file.read()' may be used to achieve this. Then, the system will identify the storage format of the compiler tool information in the file, such as determining that it is stored in the form of 'COMPILER_TOOL = 'value''. Next, according to this format, the system will construct a target regular expression, such as 'COMPILER_TOOL\s*=\s*'([^']+)' ', to match the compiler tool information. After that, the system calls the search function in the regular expression library, such as're.search()' in Python, to search for content in the previously read string variable that matches the target regular expression. Finally, if the search function finds a match, the system will use the capture group function in the regular expression library to extract the compiler tool information from the match, that is, extract the content matched by the parentheses part in the regular expression, which is the specific name and version of the compiler. This can automatically extract the compiler tool information from the'settings.py' file and provide accurate data for subsequent code quality test configuration.
[0105] Step S24, match and extract macro definition variables from the configuration file according to the compiler tool information.
[0106] It can be understood that, first, the file library configuration system will read all the content of the'settings.py' configuration file and store it in a string variable to enable programmatic processing of the file content. Second, the system will analyze the compiler tool information to find the code pattern related to the macro definition variables. For example, if the macro definition variables usually follow the 'COMPILER_DEFINES' keyword and appear in a list form, the system will locate this keyword. Then, the system will use string processing methods, such as string splitting or searching for specific delimiters, to extract the macro definition variable list. For example, if the macro definition variable list is separated by commas, the system may use commas as delimiters to split the string and extract each macro definition. Finally, the system stores the extracted macro definition variables for use in subsequent code quality tests. This can automatically extract macro definitions from the configuration file, ensure that the test environment can correctly simulate macro substitution in the actual compilation process, and thus improve the accuracy and efficiency of code quality tests.
[0107] As an example, the step of matching and extracting macro definition variables from the setting file according to the compiler tool information includes: reading the setting file to obtain the file content; parsing the file content to obtain conditional compilation statements; and searching for the macro definition parameters in the compiler tool information in the conditional compilation statements to obtain macro definition variables.
[0108] The file content refers to all the text information in the settings.py setting file. This file contains various parameters and variable definitions for project configuration. The file content is plain text independent of the programming language and may contain key configuration data such as compiler tool information and macro definition variables. Conditional compilation statements refer to preprocessor directives used in source code to control the compilation process. They can be if statements or preprocessor directives such as #if, #ifdef, #ifndef, #elif, #else, and #endif. These statements allow code segments to be included or excluded based on different conditions (such as defined macros), thus achieving conditional compilation of the code. Macro definition parameters refer to macros predefined during the compilation process, usually starting with -D followed by the macro name, and sometimes may also include the value of the macro. For example, -DDEBUG means that a macro named DEBUG is defined, and -DVERSION=1.0 means that a macro named VERSION is defined with a value of 1.0. These macro definition parameters are used to control conditional compilation and provide configuration switches or constant values in the code.
[0109] First, the file library configuration system will use the file reading function provided by the programming language. For example, in Python, code like `with open('settings.py','r') as file: content = file.readlines()` may be used to read the `settings.py` file line by line and accumulate the content of each line into a string variable. This is done to load the entire content of the file into memory for subsequent parsing. Secondly, the system will use string processing methods or regular expressions to parse this string variable to find conditional compilation statements. This may involve looking for lines starting with `if` or `#if`, and then analyzing whether these lines contain macro definition parameters related to compiler tool information. For example, the system may search for all strings containing `-D` and extract the macro name following it. Finally, the system will extract macro definition variables from these macro definition parameters, possibly through string splitting or capture groups in regular expressions. For example, if the macro definition parameter is `-DDEBUG`, the system will extract `DEBUG` as the macro definition variable. This can accurately extract the macro definitions required by specific compiler tools from the configuration file, and these macro definitions will be used in code quality testing to ensure that the test environment can simulate macro substitution during actual compilation, thereby improving the accuracy and efficiency of code testing.
[0110] This embodiment obtains the path of the configuration file of the test project; locates the configuration file according to the path; extracts compiler tool information from the configuration file through a target regular expression; matches and extracts macro definition variables from the configuration file according to the compiler tool information. First, the system specifies the path of the'settings.py' configuration file of the test project through user input or programming. This step ensures that the system can accurately locate the file containing the project configuration information, laying a foundation for subsequent extraction of configuration information. Second, the system uses the API of the file system to access and confirm the existence of the'settings.py' file according to the provided path, avoiding read errors caused by non-existent files and ensuring the smoothness of the subsequent processing flow. Then, the system writes and applies a regular expression to match the specific pattern defining the compiler tool information in'settings.py' to automatically extract the compiler tool information, reducing human errors and improving the accuracy and efficiency of the configuration. Finally, the system matches and extracts the macro definition variables associated with the compiler tool in the'settings.py' file according to the extracted compiler tool information, providing the necessary preprocessor macros for code quality testing and ensuring that the test environment can correctly simulate the actual compilation process. These steps enable the file configuration system to automate the configuration process, reduce human errors, improve the accuracy and efficiency of testing, and ensure the consistency between the test environment and the actual compilation environment, ultimately contributing to improving the quality and reliability of software products.
[0111] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the method for configuring the file library for code quality testing in this application. Based on this technical concept, more forms of simple transformations are within the protection scope of this application.
[0112] This application also provides a device for configuring a file library for code quality testing. Please refer to Figure 3 , and the device for configuring a file library for code quality testing includes:
[0113] An engineering creation module 10, configured to create a test project and obtain the engineering requirements of the test project;
[0114] A data acquisition module 20, configured to acquire the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information;
[0115] A configuration writing module 30, configured to write the compiler tool information, the macro definition variables, and a preset uncompiled-stop analysis rule into the project configuration file of the test project;
[0116] Configure a start / stop module 40 to enable or disable multiple check configurations in the project configuration file according to the engineering requirements, and complete the configuration of the file library.
[0117] In one embodiment, the data acquisition module 20 is further configured to obtain the path of the setup file of the test project; find the setup file according to the path; extract compiler tool information from the setup file through a target regular expression; match and extract macro definition variables from the setup file according to the compiler tool information.
[0118] In one embodiment, the data acquisition module 20 is further configured to read all the content in the setup file into a string variable; obtain the format of the compiler tool information; determine a target regular expression according to the format; find a matching item that matches the target regular expression in the string variable through a search function in the regular expression library; extract the compiler tool information from the matching item through a capture group in the regular expression library.
[0119] In one embodiment, the data acquisition module 20 is further configured to read the setup file to obtain file content; parse the file content to obtain conditional compilation statements; find macro definition parameters in the compiler tool information in the conditional compilation statements to obtain macro definition variables.
[0120] In one embodiment, when the engineering requirements include following programming standards, the configuration start / stop module 40 is further configured to enable or disable programming rule check configurations in the project configuration file; when the engineering requirements include code review and maintenance history, enable or disable code review tracking configurations in the project configuration file; when the engineering requirements include static code quality inspection, enable or disable static code analysis configurations in the project configuration file; when the engineering requirements include test sufficiency requirements, enable or disable code coverage check configurations in the project configuration file, and complete the configuration of the file library.
[0121] In one embodiment, when the engineering requirements include performance optimization and resource management, the configuration start / stop module 40 is further configured to enable or disable memory leak detection configurations in the project configuration file; when the engineering requirements include concurrent and multi-threaded programming, enable or disable thread safety check configurations in the project configuration file; when the engineering requirements include error handling and exception management, enable or disable exception handling check configurations in the project configuration file; when the engineering requirements include software security requirements, enable or disable security check configurations in the project configuration file, and complete the configuration of the file library.
[0122] In one embodiment, the configuration start-stop module 40 is further configured to import source code files and header files that need to be subjected to code quality testing into the test project; and perform code quality testing according to the imported test project and the project configuration file.
[0123] The file library configuration device for code quality testing provided by the present application adopts the file library configuration method for code quality testing in the above embodiment, and can solve the technical problem of how to efficiently and accurately configure the file library required for code quality testing. Compared with the prior art, the beneficial effects of the file library configuration device for code quality testing provided by the present application are the same as those of the file library configuration method for code quality testing provided by the above embodiment, and other technical features in the file library configuration device for code quality testing are the same as the features disclosed in the method of the above embodiment, and will not be elaborated herein.
[0124] The present application provides a file library configuration device for code quality testing. The file library configuration device for code quality testing includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the file library configuration method for code quality testing in the first embodiment above.
[0125] Next, refer to Figure 4 , which shows a schematic structural diagram of a file library configuration device for code quality testing suitable for implementing the embodiments of the present application. The file library configuration device for code quality testing in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The file library configuration device for code quality testing shown is merely an example and should not impose any limitation on the functions and usage scope of the embodiments of the present application.
[0126] As Figure 4As shown, the file library configuration device for code quality testing may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM: Random Access Memory) 1004. In the RAM 1004, various programs and data required for the operation of the file library configuration device for code quality testing are also stored. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems may be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the file library configuration device for code quality testing to communicate with other devices wirelessly or wiredly to exchange data. Although the figure shows a file library configuration device for code quality testing with various systems, it should be understood that it is not required to implement or have all the shown systems. More or fewer systems may be implemented or had alternatively.
[0127] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above functions defined in the methods of the embodiments disclosed in the present application are executed.
[0128] The file library configuration device for code quality testing provided by the present application adopts the file library configuration method in the above embodiments, and can solve the technical problem of how to efficiently and accurately configure the file library required for code quality testing. Compared with the prior art, the beneficial effects of the file library configuration device for code quality testing provided by the present application are the same as those of the file library configuration method provided by the above embodiments, and other technical features in the file library configuration device for code quality testing are the same as those disclosed in the method of the previous embodiment, and will not be elaborated here.
[0129] It should be understood that each part disclosed in this application can be implemented by hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in a suitable manner in any one or more embodiments or examples.
[0130] As mentioned above, it is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this application, and all of them should be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claimed rights.
[0131] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer programs) stored thereon, and the computer-readable program instructions are used to execute the file library configuration method for code quality testing in the above embodiments.
[0132] The computer-readable storage medium provided by this application can be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) or flash memory, optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this embodiment, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or combined with an instruction execution system, device, or device. The program code contained on the computer-readable storage medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0133] The above computer-readable storage medium can be included in the file library configuration device for code quality testing; it can also exist separately without being assembled into the file library configuration device for code quality testing.
[0134] The above computer-readable storage medium carries one or more programs, which, when executed by the file library configuration device for code quality testing, cause the file library configuration device for code quality testing to: create a test project and obtain the project requirements of the test project; obtain the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information; write the compiler tool information, the macro definition variables, and the preset uncompiled-stop analysis rules into the project configuration file of the test project; enable or disable multiple check configurations in the project configuration file according to the project requirements, and complete the configuration of the file library.
[0135] Computer program code for performing the operations of the present application may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partially on the user's computer, execute as a stand-alone software package, execute partially on the user's computer and partially on a remote computer, or execute entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through 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., by connecting through the Internet using an Internet service provider).
[0136] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a portion of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that, in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0137] The modules involved in the embodiments of the present application can be implemented in software or in hardware. In some cases, the name of the module does not constitute a limitation on the unit itself.
[0138] The readable storage medium provided by the present application is a computer-readable storage medium. The computer-readable storage medium stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned file library configuration method for code quality testing, and can solve the technical problem of how to efficiently and accurately configure the file library required for code quality testing. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as those of the file library configuration method for code quality testing provided by the above embodiments, and will not be elaborated here.
[0139] The present application also provides a computer program product, including a computer program, and the steps of the file library configuration method for code quality testing as described above are implemented when the computer program is executed by a processor.
[0140] The computer program product provided by the present application can solve the technical problem of how to efficiently and accurately configure the file library required for code quality testing. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as those of the file library configuration method for code quality testing provided by the above embodiments, and will not be elaborated here.
[0141] The above are only some embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structural transformation made by using the content of the specification and drawings of the present application under the technical concept of the present application, or direct / indirect application in other related technical fields, is included in the patent protection scope of the present application.
Claims
1. A method for configuring a file library for code quality testing, characterized in that The method includes: Create a new test project and obtain the project requirements of the test project; Obtain the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information; Write the compiler tool information, the macro definition variables, and a preset uncompiled-stop analysis rule into the project configuration file of the test project; Enable or disable multiple check configurations in the project configuration file according to the project requirements to complete the configuration of the file library.
2. The method according to claim 1, characterized in that, The step of obtaining the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information includes: Obtain the path of the settings file of the test project; Find the settings file according to the path; Extract the compiler tool information from the settings file through a target regular expression; Match and extract the macro definition variables from the settings file according to the compiler tool information.
3. The method according to claim 2, characterized in that, The step of extracting the compiler tool information from the settings file through a target regular expression includes: Read all the content in the settings file into a string variable; Obtain the format of the compiler tool information; Determine the target regular expression according to the format; Find a matching item in the string variable that matches the target regular expression through the search function in the regular expression library; Extract the compiler tool information from the matching item through the capture group in the regular expression library.
4. The method according to claim 2, wherein The step of matching and extracting the macro definition variables from the settings file according to the compiler tool information includes: Read the settings file to obtain the file content; Parse the file content to obtain conditional compilation statements; Find the macro definition parameters in the compiler tool information in the conditional compilation statements to obtain the macro definition variables.
5. The method according to claim 1, wherein The step of enabling or disabling multiple check configurations in the project configuration file according to the project requirements to complete the configuration of the file library includes: When the project requirements include following programming standards, enable or disable the programming rule check configuration in the project configuration file; When the project requirements include code review and maintenance history, enable or disable the code review tracking configuration in the project configuration file; When the project requirements include static code quality inspection, enable or disable the static code analysis configuration in the project configuration file; When the project requirements include test sufficiency requirements, enable or disable the code coverage check configuration in the project configuration file to complete the configuration of the file library.
6. The method according to claim 1, characterized in that, The step of enabling or disabling multiple check configurations in the project configuration file according to the project requirements to complete the configuration of the file library includes: When the project requirements include performance optimization and resource management, enable or disable the memory leak detection configuration in the project configuration file; When the project requirements include concurrent and multi-threaded programming, enable or disable the thread safety check configuration in the project configuration file; When the project requirements include error handling and exception management, enable or disable the exception handling check configuration in the project configuration file; When the engineering requirements include software security requirements, enable or disable the security check configuration in the project profile to complete the configuration of the file library.
7. The method according to any one of claims 1 to 6, characterized in that, After the step of enabling or disabling multiple check configurations in the project profile according to the engineering requirements to complete the configuration of the file library, it further includes: Import the source code files and header files that need to be subjected to code quality testing into the test project; Execute code quality testing according to the imported test project and the project profile.
8. A file library configuration device for code quality testing, characterized in that The device includes: An engineering creation module, configured to create a test project and obtain the engineering requirements of the test project; A data acquisition module, configured to acquire the compiler tool information of the test project and the macro definition variables corresponding to the compiler tool information; A configuration writing module, configured to write the compiler tool information, the macro definition variables, and the preset uncompiled-stop analysis rules into the project profile of the test project; A configuration start / stop module, configured to enable or disable multiple check configurations in the project profile according to the engineering requirements to complete the configuration of the file library.
9. A file library configuration device for code quality testing, characterized in that The device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the file library configuration method for code quality testing as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium, and when the computer program is executed by a processor, it implements the steps of the file library configuration method for code quality testing as described in any one of claims 1 to 7.