[go: up one dir, main page]

CN116893960A - Code quality detection methods, devices, computer equipment and storage media - Google Patents

Code quality detection methods, devices, computer equipment and storage media Download PDF

Info

Publication number
CN116893960A
CN116893960A CN202310784106.4A CN202310784106A CN116893960A CN 116893960 A CN116893960 A CN 116893960A CN 202310784106 A CN202310784106 A CN 202310784106A CN 116893960 A CN116893960 A CN 116893960A
Authority
CN
China
Prior art keywords
code
detected
test case
static analysis
log information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310784106.4A
Other languages
Chinese (zh)
Inventor
林楠
林维城
郭享
陈容
宋冰蕊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial Bank Co Ltd
CIB Fintech Services Shanghai Co Ltd
Original Assignee
Industrial Bank Co Ltd
CIB Fintech Services Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial Bank Co Ltd, CIB Fintech Services Shanghai Co Ltd filed Critical Industrial Bank Co Ltd
Priority to CN202310784106.4A priority Critical patent/CN116893960A/en
Publication of CN116893960A publication Critical patent/CN116893960A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3604Analysis of software for verifying properties of programs
    • G06F11/3616Analysis of software for verifying properties of programs using software metrics
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present application relates to a code quality detection method, apparatus, computer device, storage medium and computer program product. The method comprises the steps of carrying out static analysis on a code to be detected through a pre-configured static analysis tool to obtain a static analysis result, generating a test case according to the code to be detected, further operating the test case, obtaining dynamic log information in the operation process of the test case, and finally generating a quality detection result of the code to be detected according to the static analysis result and the dynamic log information. By combining static analysis with dynamic analysis, the automatic code quality detection can be realized, the code detection efficiency can be improved, and the labor cost can be reduced.

Description

代码质量检测方法、装置、计算机设备和存储介质Code quality detection methods, devices, computer equipment and storage media

技术领域Technical field

本申请涉及软件测试技术领域,特别是涉及一种代码质量检测方法、装置、计算机设备、存储介质和计算机程序产品。This application relates to the technical field of software testing, and in particular to a code quality detection method, device, computer equipment, storage medium and computer program product.

背景技术Background technique

在软件开发过程中,软件测试是不可或缺的重要环节。当软件编码完成一个版本后,进入软件测试环节,首先需要做代码的单元静态测试即静态分析。代码静态分析后,测试人员把编码规则问题反馈给软件编码人员。由软件编码人员对测试问题进行确认、更改。In the software development process, software testing is an indispensable and important link. After a version of software coding is completed, the software testing process begins. First, static unit testing of the code, that is, static analysis, needs to be done. After static analysis of the code, the testers feedback coding rule issues to the software coders. Test issues are confirmed and changed by software coders.

然而,目前的测试方式依赖于测试人员与编码人员的充分衔接和沟通,不仅耗费较大的人力成本,且测试效率低。However, the current testing method relies on sufficient connection and communication between testers and coders, which not only consumes large labor costs, but also has low testing efficiency.

发明内容Contents of the invention

基于此,有必要针对上述技术问题,提供一种能够提高代码检测效率的代码质量检测方法、装置、计算机设备、计算机可读存储介质和计算机程序产品。Based on this, it is necessary to address the above technical problems and provide a code quality detection method, device, computer equipment, computer readable storage medium and computer program product that can improve code detection efficiency.

第一方面,本申请提供了一种代码质量检测方法。所述方法包括:In the first aspect, this application provides a code quality detection method. The methods include:

通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果;Perform static analysis on the code to be detected through pre-configured static analysis tools to obtain static analysis results;

根据所述待检测代码生成测试用例;Generate test cases based on the code to be tested;

运行所述测试用例,获取所述测试用例运行过程中的动态日志信息;Run the test case and obtain dynamic log information during the execution of the test case;

根据所述静态分析结果和所述动态日志信息,生成所述待检测代码的质量检测结果。According to the static analysis results and the dynamic log information, a quality detection result of the code to be detected is generated.

在其中一个实施例中,所述根据所述待检测代码生成测试用例,包括:基于目标检测需求,通过自动测试生成工具为所述待检测代码生成测试用例。In one embodiment, generating test cases according to the code to be detected includes: based on target detection requirements, using an automatic test generation tool to generate test cases for the code to be detected.

在其中一个实施例中,所述运行所述测试用例,获取所述测试用例运行过程中的动态日志信息,包括:加载底层虚拟机LLVM编译器,通过所述LLVM编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,获取运行过程中的动态日志信息。In one embodiment, running the test case and obtaining dynamic log information during the execution of the test case includes: loading the underlying virtual machine LLVM compiler, and compiling the code to be detected through the LLVM compiler. ; Run the compiled code to be tested based on the test case, and obtain dynamic log information during the running process.

在其中一个实施例中,所述运行所述测试用例,获取所述测试用例运行过程中的动态日志信息,包括:采用目标编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,当所述待检测代码运行完成后,生成剖析数据文件;通过预设的性能分析工具分析所述剖析数据文件,得到对应的日志动态信息。In one embodiment, running the test case and obtaining dynamic log information during the running process of the test case includes: using a target compiler to compile the code to be detected; and running all the compiled code based on the test case. Describe the code to be detected, and when the code to be detected is completed, a profiling data file is generated; the profiling data file is analyzed through a preset performance analysis tool to obtain corresponding log dynamic information.

在其中一个实施例中,所述目标编译器为具有-pg编译选项的编译器。In one embodiment, the target compiler is a compiler with a -pg compilation option.

在其中一个实施例中,所述质量检测结果中包括对所述待检测代码的改进方案;所述生成所述待检测代码的质量检测结果之后,所述方法还包括:根据所述改进方案对所述待检测代码进行更新,得到更新后的目标代码。In one embodiment, the quality inspection results include an improvement plan for the code to be inspected; after generating the quality inspection results for the code to be inspected, the method further includes: modifying the code according to the improvement plan. The code to be detected is updated to obtain the updated target code.

第二方面,本申请还提供了一种代码质量检测装置。所述装置包括:In a second aspect, this application also provides a code quality detection device. The device includes:

静态分析模块,用于通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果;The static analysis module is used to statically analyze the code to be detected through pre-configured static analysis tools and obtain static analysis results;

测试用例生成模块,用于根据所述待检测代码生成测试用例;A test case generation module, used to generate test cases based on the code to be tested;

动态分析模块,用于运行所述测试用例,获取所述测试用例运行过程中的动态日志信息;A dynamic analysis module, used to run the test case and obtain dynamic log information during the execution of the test case;

检测结果生成模块,用于根据所述静态分析结果和所述动态日志信息,生成所述待检测代码的质量检测结果。A detection result generation module is configured to generate a quality detection result of the code to be detected based on the static analysis result and the dynamic log information.

第三方面,本申请还提供了一种计算机设备。所述计算机设备包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现如上第一方面所述方法的步骤。In a third aspect, this application also provides a computer device. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the steps of the method described in the first aspect are implemented.

第四方面,本申请还提供了一种计算机可读存储介质。所述计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上第一方面所述方法的步骤。In a fourth aspect, this application also provides a computer-readable storage medium. The computer-readable storage medium has a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.

第五方面,本申请还提供了一种计算机程序产品。所述计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现如上第一方面所述方法的步骤。In a fifth aspect, this application also provides a computer program product. The computer program product includes a computer program that implements the steps of the method described in the first aspect when executed by a processor.

上述代码质量检测方法、装置、计算机设备、存储介质和计算机程序产品,通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果,并根据待检测代码生成测试用例,进而运行测试用例,获取测试用例运行过程中的动态日志信息,最后根据静态分析结果和动态日志信息,生成待检测代码的质量检测结果。其通过将静态分析与动态分析相结合,并能实现自动化的代码质量检测,不仅能够提高对代码的检测效率,且能够降低人力成本。The above-mentioned code quality detection methods, devices, computer equipment, storage media and computer program products perform static analysis on the code to be detected through pre-configured static analysis tools, obtain static analysis results, generate test cases based on the code to be detected, and then run the test cases , obtain the dynamic log information during the test case running process, and finally generate the quality detection results of the code to be detected based on the static analysis results and dynamic log information. By combining static analysis with dynamic analysis, it can realize automated code quality detection, which can not only improve the efficiency of code detection, but also reduce labor costs.

附图说明Description of the drawings

图1为一个实施例中代码质量检测方法的流程示意图;Figure 1 is a schematic flow chart of a code quality detection method in one embodiment;

图2为一个实施例中获取动态日志信息步骤的流程示意图;Figure 2 is a schematic flowchart of the steps of obtaining dynamic log information in one embodiment;

图3为另一个实施例中获取动态日志信息步骤的流程示意图;Figure 3 is a schematic flowchart of the steps of obtaining dynamic log information in another embodiment;

图4为一个实施例中代码质量检测装置的结构框图;Figure 4 is a structural block diagram of a code quality detection device in one embodiment;

图5为一个实施例中计算机设备的内部结构图。Figure 5 is an internal structure diagram of a computer device in one embodiment.

具体实施方式Detailed ways

为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions and advantages of the present application more clear, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application and are not used to limit the present application.

在一个实施例中,如图1所示,提供了一种代码质量检测方法,其方法可以应用于计算机设备,具体可以包括以下步骤:In one embodiment, as shown in Figure 1, a code quality detection method is provided, and the method can be applied to computer equipment. Specifically, it can include the following steps:

步骤102,通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果。Step 102: Perform static analysis on the code to be detected using a pre-configured static analysis tool to obtain static analysis results.

其中,待检测代码可以是待要进行质量检测的源代码。静态分析工具可以是预先设置的对源代码进行静态质量检测的相关配置或插件,例如,包括但不限于Clang-Tidy(一种基于clang的静态代码分析框架)、Cppcheck(一种C/C++代码缺陷静态检查工具)等。静态分析结果则是对源代码进行静态质量检测后得到的源代码中潜在的质量问题,如语法错误、全名规范、注释规范等。The code to be tested may be the source code to be quality tested. Static analysis tools can be preset related configurations or plug-ins for static quality inspection of source code, for example, including but not limited to Clang-Tidy (a clang-based static code analysis framework), Cppcheck (a C/C++ code Defect static inspection tools), etc. The static analysis results are potential quality problems in the source code obtained after static quality inspection of the source code, such as grammatical errors, full name specifications, comment specifications, etc.

在本实施例中,当要对待检测的源代码进行质量检测时,计算机设备则可以通过预先配置的静态分析工具对待检测代码进行静态分析,以得到静态分析结果。In this embodiment, when quality inspection is performed on the source code to be inspected, the computer device can perform static analysis on the code to be inspected through a preconfigured static analysis tool to obtain static analysis results.

步骤104,根据待检测代码生成测试用例。Step 104: Generate test cases based on the code to be detected.

其中,测试用例是指对一项特定的软件产品进行测试任务的描述,体现测试方案、方法、技术和策略。其内容包括测试目标、测试环境、输入数据、测试步骤、预期结果、测试脚本等,最终形成文档。简单地认为,测试用例是为某个特殊目标而编制的一组测试输入、执行条件以及预期结果,用于核实是否满足某个特定软件需求。Among them, test cases refer to the description of testing tasks for a specific software product, embodying testing plans, methods, technologies and strategies. Its content includes test goals, test environment, input data, test steps, expected results, test scripts, etc., and finally forms a document. Simply put, a test case is a set of test inputs, execution conditions, and expected results compiled for a special goal, used to verify whether a specific software requirement is met.

在本实施例中,计算机设备可以根据待检测代码的目标检测需求而生成对应的测试用例。In this embodiment, the computer device can generate corresponding test cases according to the target detection requirements of the code to be detected.

步骤106,运行测试用例,获取测试用例运行过程中的动态日志信息。Step 106: Run the test case and obtain dynamic log information during the execution of the test case.

其中,动态日志信息是测试用例运行过程中收集的用于表征待检测代码动态检测过程的相关信息,例如,包括执行时间、内存占用、函数调用次数等信息。Among them, dynamic log information is relevant information collected during the running of test cases to characterize the dynamic detection process of the code to be detected, including, for example, execution time, memory usage, number of function calls, and other information.

在本实施例中,当计算机设备基于上述步骤生成对应的测试用例后,则可以运行测试用例,并获取测试用例运行过程中的动态日志信息。In this embodiment, after the computer device generates the corresponding test case based on the above steps, it can run the test case and obtain dynamic log information during the running process of the test case.

步骤108,根据静态分析结果和动态日志信息,生成待检测代码的质量检测结果。Step 108: Generate quality detection results of the code to be detected based on the static analysis results and dynamic log information.

由于静态分析结果是对源代码进行静态质量检测后得到的源代码中潜在的质量问题的结果,动态日志信息是测试用例运行过程中收集的用于表征待检测代码动态检测过程的相关信息,因此,计算机设备通过对静态分析结果和动态日志信息进行分析整合,从而得到待检测代码的质量检测结果。具体地,该质量检测结果可以通过可视化报告的方式展示相应的代码质量评分以及对代码的改进方案。Since the static analysis results are the results of potential quality problems in the source code obtained after static quality inspection of the source code, the dynamic log information is the relevant information collected during the running of the test case to characterize the dynamic detection process of the code to be detected. Therefore , the computer equipment analyzes and integrates the static analysis results and dynamic log information to obtain the quality detection results of the code to be detected. Specifically, the quality inspection results can display the corresponding code quality scores and code improvement plans in the form of visual reports.

上述代码质量检测方法中,通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果,并根据待检测代码生成测试用例,进而运行测试用例,获取测试用例运行过程中的动态日志信息,最后根据静态分析结果和动态日志信息,生成待检测代码的质量检测结果。其通过将静态分析与动态分析相结合,并能实现自动化的代码质量检测,不仅能够提高对代码的检测效率,且能够降低人力成本。In the above code quality detection method, the pre-configured static analysis tool is used to statically analyze the code to be detected, obtain the static analysis results, generate test cases based on the code to be detected, and then run the test cases to obtain dynamic log information during the running of the test cases. , Finally, based on the static analysis results and dynamic log information, the quality detection results of the code to be detected are generated. By combining static analysis with dynamic analysis, it can realize automated code quality detection, which can not only improve the efficiency of code detection, but also reduce labor costs.

在一个实施例中,在步骤104中,根据待检测代码生成测试用例,具体可以包括:基于目标检测需求,通过自动测试生成工具为待检测代码生成测试用例。其中,目标检测需求包括但不限于代码覆盖率、具体的项目需求(即待检测代码所应用的项目)等。在本实施例中,生成测试用例时,还可以基于自动测试生成工具自动生成。In one embodiment, in step 104, generating test cases according to the code to be detected may specifically include: based on target detection requirements, using an automatic test generation tool to generate test cases for the code to be detected. Among them, target detection requirements include but are not limited to code coverage, specific project requirements (that is, the projects to which the code to be detected is applied), etc. In this embodiment, when generating test cases, they can also be automatically generated based on the automatic test generation tool.

在一种场景下,以自动测试生成工具为Google Test(谷歌C++单元测试框架)为例,进一步说明测试用例的生成过程。在本实施例中,可以通过克隆Google Test的GitHub(一个面向开源及私有软件项目的托管平台)仓库并构建库,或通过包管理器(如apt、yum等)安装Google Test。然后,在项目根目录下,创建一个名为“tests”的文件夹,并在其中创建用于存放待检测代码的源文件,例如test_example.cpp。接着在test_example.cpp中,引入Google Test头文件并定义测试用例,从而得到待检测代码的测试用例。本实施例通过借助自动测试生成工具为待检测代码生成测试用例,从而能够降低通过人工生成测试用例的工作量,提高整体的测试效率。In one scenario, the automatic test generation tool is Google Test (Google C++ unit testing framework) as an example to further illustrate the test case generation process. In this embodiment, you can clone Google Test's GitHub (a hosting platform for open source and private software projects) repository and build a library, or install Google Test through a package manager (such as apt, yum, etc.). Then, in the project root directory, create a folder named "tests" and create a source file there to store the code to be tested, such as test_example.cpp. Then, in test_example.cpp, introduce the Google Test header file and define test cases to obtain test cases for the code to be tested. This embodiment uses an automatic test generation tool to generate test cases for the code to be detected, thereby reducing the workload of manually generating test cases and improving overall testing efficiency.

在一个实施例中,如图2所示,在步骤106中,运行测试用例,获取测试用例运行过程中的动态日志信息,具体可以包括以下步骤:In one embodiment, as shown in Figure 2, in step 106, the test case is run to obtain dynamic log information during the running of the test case, which may include the following steps:

步骤202,加载底层虚拟机LLVM编译器,通过LLVM编译器编译待检测代码。Step 202: Load the underlying virtual machine LLVM compiler, and compile the code to be detected through the LLVM compiler.

LLVM(Low Level Virtual Machine,底层虚拟机)编译器是以C++编写而成,用于优化以任意程序语言编写的程序的编译时间(compile-time)、链接时间(link-time)、运行时间(run-time)以及空闲时间(idle-time),对开发者保持开放,并兼容已有脚本。The LLVM (Low Level Virtual Machine) compiler is written in C++ and is used to optimize the compile-time (compile-time), link-time (link-time), and run-time ( run-time) and idle time (idle-time), remain open to developers and compatible with existing scripts.

在本实施例中,可以通过在计算机设备上安装加载LLVM编译器,并通过LLVM编译器编译待检测代码。具体地,LLVM编译器可以包括clang(是一个C语言、C++、Objective-C语言的轻量级编译器)、clang++(C++编译器)等工具。进而可以使用带有Sanitizer Coverage选项的clang编译器编译待检测代码,得到编译后的代码。In this embodiment, the LLVM compiler can be installed and loaded on the computer device, and the code to be detected can be compiled through the LLVM compiler. Specifically, the LLVM compiler can include clang (a lightweight compiler for C, C++, and Objective-C languages), clang++ (C++ compiler), and other tools. Then you can use the clang compiler with the Sanitizer Coverage option to compile the code to be detected and obtain the compiled code.

步骤204,基于测试用例运行编译的待检测代码,获取运行过程中的动态日志信息。Step 204: Run the compiled code to be tested based on the test case, and obtain dynamic log information during the running process.

具体地,计算机设备可以基于测试用例运行上述步骤编译的待检测代码,从而获取运行过程中的动态日志信息。从而实现通过代码插桩的方式收集代码动态分析过程中的动态日志信息,进一步提高代码的检测效率。Specifically, the computer device can run the code to be tested compiled in the above steps based on the test case, thereby obtaining dynamic log information during the running process. This enables the collection of dynamic log information during code dynamic analysis through code instrumentation, further improving code detection efficiency.

在一个实施例中,如图3所示,在步骤106中,运行测试用例,获取测试用例运行过程中的动态日志信息,具体可以包括以下步骤:In one embodiment, as shown in Figure 3, in step 106, run the test case and obtain dynamic log information during the running of the test case, which may include the following steps:

步骤302,采用目标编译器编译待检测代码。Step 302: Use the target compiler to compile the code to be detected.

其中,目标编译器可以是具有-pg编译选项的编译器。在本实施例中,计算机设备可以采用具有-pg编译选项的目标编译器编译待检测代码,从而得到编译后的代码。Among them, the target compiler can be a compiler with the -pg compilation option. In this embodiment, the computer device can use a target compiler with the -pg compilation option to compile the code to be detected, thereby obtaining the compiled code.

步骤304,基于测试用例运行编译的待检测代码,当待检测代码运行完成后,生成剖析数据文件。Step 304: Run the compiled code to be tested based on the test case. After the code to be tested is completed, a profiling data file is generated.

其中,剖析数据文件可以是收集的代码运行时数据。具体地,计算机设备可以基于测试用例运行上述步骤编译的待检测代码,当待检测代码运行完成后,则生成剖析数据文件。在本实施例中,该剖析数据文件可以具有对应的文件名,例如“gmon.out”。Among them, the profiling data file can be collected code runtime data. Specifically, the computer device can run the code to be tested compiled in the above steps based on the test case, and when the code to be tested is completed, the profiling data file is generated. In this embodiment, the profiling data file may have a corresponding file name, such as “gmon.out”.

步骤306,通过预设的性能分析工具分析剖析数据文件,得到对应的日志动态信息。Step 306: Analyze the data file through a preset performance analysis tool to obtain corresponding log dynamic information.

其中,预设的性能分析工具可以是gprof,其是GNU(一种由自由软件构成的类Unix操作系统)提供的程序时间监测工具,可以统计出各个函数的调用次数、时间、以及函数调用图等。Among them, the preset performance analysis tool can be gprof, which is a program time monitoring tool provided by GNU (a Unix-like operating system composed of free software), which can count the number of calls, time, and function call graph of each function. wait.

在本实施例中,计算机设备可以通过预设的性能分析工具分析上述步骤生成的剖析数据文件,从而得到对应的日志动态信息。从而实现通过性能剖析的方式收集代码动态分析过程中的动态日志信息,以提高代码的检测效率。In this embodiment, the computer device can analyze the profiling data file generated in the above steps through a preset performance analysis tool, thereby obtaining corresponding log dynamic information. This enables the collection of dynamic log information during code dynamic analysis through performance analysis to improve code detection efficiency.

在一个实施例中,在步骤102中,通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果,具体可以包括:In one embodiment, in step 102, the code to be detected is statically analyzed using a preconfigured static analysis tool to obtain static analysis results, which may include:

首先可以根据项目需求和编码规范配置相应的静态分析工具,本实施例以静态分析工具为Clang-Tidy为例进行说明。则进一步创建一个名为“.clang-tidy”的配置文件,并将此文件存放在项目根目录下,以便Clang-Tidy在执行时自动读取配置。并在“.clang-tidy”文件中添加需要启用的检查规则,如clang-analyzer-*(一种基于clang开发的官方静态代码分析工具,用于在编译阶段提前发现代码问题)、cppcoreguidelines-*(C++核心准则)、google-*等。进而根据需要自定义检查规则,并基于自定义的检查规则对待检测代码进行静态分析,以检查潜在的代码质量问题,如语法错误、命名规范、注释规范等,从而得到静态分析结果。以实现对待检测代码的自动静态分析,节省检测成本。First, the corresponding static analysis tool can be configured according to the project requirements and coding specifications. In this embodiment, the static analysis tool Clang-Tidy is used as an example for explanation. Then further create a configuration file named ".clang-tidy" and store this file in the project root directory so that Clang-Tidy can automatically read the configuration during execution. And add the checking rules that need to be enabled in the ".clang-tidy" file, such as clang-analyzer-* (an official static code analysis tool developed based on clang, used to detect code problems in advance during the compilation phase), cppcoreguidelines-* (C++ Core Guidelines), google-*, etc. Then customize the inspection rules as needed, and perform static analysis on the code to be detected based on the customized inspection rules to check for potential code quality issues, such as syntax errors, naming specifications, annotation specifications, etc., to obtain static analysis results. To achieve automatic static analysis of the code to be detected and save detection costs.

在一个实施例中,质量检测结果中还可以包括对待检测代码的改进方案;则在步骤108中,生成待检测代码的质量检测结果之后,上述方法还可以包括:根据改进方案对待检测代码进行更新,得到更新后的目标代码。其中,改进方案可以是基于静态分析结果和动态日志信息进一步分析后确定的,其可能存在的性能瓶颈,以及可能存在问题的代码部分。计算机设备则可以根据改进方案对待检测代码进行更新,从而得到更新后的目标代码。从而实现修复源代码中的问题,提高代码质量。In one embodiment, the quality inspection results may also include an improvement plan for the code to be inspected; then in step 108, after generating the quality inspection results for the code to be inspected, the above method may further include: updating the code to be inspected according to the improvement plan. , get the updated object code. Among them, the improvement plan can be determined based on further analysis of static analysis results and dynamic log information, possible performance bottlenecks, and possible problematic code parts. The computer equipment can update the code to be detected according to the improvement plan, thereby obtaining the updated target code. In this way, problems in the source code can be fixed and the code quality can be improved.

在一个实施例中,上述代码质量检测方法和相关工具还可以集成到集成开发环境(IDE,Integrated Development Environment)和持续集成(CI,Continuous integration)流程中,从而实现自动化的源代码质量评估和优化,使得代码开发团队能够在整个软件开发周期中持续监控和提高代码质量。In one embodiment, the above code quality detection method and related tools can also be integrated into the integrated development environment (IDE, Integrated Development Environment) and continuous integration (CI, Continuous integration) process to achieve automated source code quality assessment and optimization. , enabling code development teams to continuously monitor and improve code quality throughout the software development cycle.

应该理解的是,虽然如上所述的各实施例所涉及的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,如上所述的各实施例所涉及的流程图中的至少一部分步骤可以包括多个步骤或者多个阶段,这些步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤中的步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the steps in the flowcharts involved in the above-mentioned embodiments are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts involved in the above embodiments may include multiple steps or stages. These steps or stages are not necessarily executed at the same time, but may be completed at different times. The execution order of these steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

基于同样的发明构思,本申请实施例还提供了一种用于实现上述所涉及的代码质量检测方法的代码质量检测装置。该装置所提供的解决问题的实现方案与上述方法中所记载的实现方案相似,故下面所提供的一个或多个代码质量检测装置实施例中的具体限定可以参见上文中对于代码质量检测方法的限定,在此不再赘述。Based on the same inventive concept, embodiments of the present application also provide a code quality detection device for implementing the above-mentioned code quality detection method. The solution to the problem provided by this device is similar to the solution recorded in the above method. Therefore, the specific limitations in the one or more code quality detection device embodiments provided below can be found in the code quality detection method mentioned above. Limitations will not be repeated here.

在一个实施例中,如图4所示,提供了一种代码质量检测装置,包括:静态分析模块402、测试用例生成模块404、动态分析模块406和检测结果生成模块408,其中:In one embodiment, as shown in Figure 4, a code quality detection device is provided, including: a static analysis module 402, a test case generation module 404, a dynamic analysis module 406 and a detection result generation module 408, wherein:

静态分析模块402,用于通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果;The static analysis module 402 is used to statically analyze the code to be detected through pre-configured static analysis tools to obtain static analysis results;

测试用例生成模块404,用于根据所述待检测代码生成测试用例;Test case generation module 404, used to generate test cases according to the code to be detected;

动态分析模块406,用于运行所述测试用例,获取所述测试用例运行过程中的动态日志信息;The dynamic analysis module 406 is used to run the test case and obtain dynamic log information during the execution of the test case;

检测结果生成模块408,用于根据所述静态分析结果和所述动态日志信息,生成所述待检测代码的质量检测结果。The detection result generation module 408 is configured to generate a quality detection result of the code to be detected according to the static analysis result and the dynamic log information.

在一个实施例中,测试用例生成模块具体用于:基于目标检测需求,通过自动测试生成工具为所述待检测代码生成测试用例。In one embodiment, the test case generation module is specifically configured to: based on target detection requirements, use an automatic test generation tool to generate test cases for the code to be detected.

在一个实施例中,动态分析模块具体用于:加载底层虚拟机LLVM编译器,通过所述LLVM编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,获取运行过程中的动态日志信息。In one embodiment, the dynamic analysis module is specifically used to: load the underlying virtual machine LLVM compiler, compile the code to be detected through the LLVM compiler; run the compiled code to be detected based on the test case, and obtain the execution Dynamic log information during the process.

在一个实施例中,动态分析模块具体还用于:采用目标编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,当所述待检测代码运行完成后,生成剖析数据文件;通过预设的性能分析工具分析所述剖析数据文件,得到对应的日志动态信息。In one embodiment, the dynamic analysis module is further configured to: use a target compiler to compile the code to be detected; run the compiled code to be detected based on the test case, and after the code to be detected is completed, generate Analyze the data file; analyze the profiling data file through a preset performance analysis tool to obtain corresponding log dynamic information.

在一个实施例中,所述目标编译器为具有-pg编译选项的编译器。In one embodiment, the target compiler is a compiler with a -pg compilation option.

在一个实施例中,所述质量检测结果中包括对所述待检测代码的改进方案;则所述装置还包括代码更新模块,用于根据所述改进方案对所述待检测代码进行更新,得到更新后的目标代码。In one embodiment, the quality inspection results include an improvement plan for the code to be detected; then the device further includes a code update module for updating the code to be detected according to the improvement plan, to obtain Updated object code.

上述代码质量检测装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。Each module in the above code quality detection device can be implemented in whole or in part by software, hardware and combinations thereof. Each of the above modules may be embedded in or independent of the processor of the computer device in the form of hardware, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

在一个实施例中,提供了一种计算机设备,该计算机设备可以是终端,其内部结构图可以如图5所示。该计算机设备包括处理器、存储器、输入/输出接口、通信接口、显示单元和输入装置。其中,处理器、存储器和输入/输出接口通过系统总线连接,通信接口、显示单元和输入装置通过输入/输出接口连接到系统总线。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质和内存储器。该非易失性存储介质存储有操作系统和计算机程序。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的输入/输出接口用于处理器与外部设备之间交换信息。该计算机设备的通信接口用于与外部的终端进行有线或无线方式的通信,无线方式可通过WIFI、移动蜂窝网络、NFC(近场通信)或其他技术实现。该计算机程序被处理器执行时以实现一种代码质量检测方法。该计算机设备的显示单元用于形成视觉可见的画面,可以是显示屏、投影装置或虚拟现实成像装置。显示屏可以是液晶显示屏或者电子墨水显示屏,该计算机设备的输入装置可以是显示屏上覆盖的触摸层,也可以是计算机设备外壳上设置的按键、轨迹球或触控板,还可以是外接的键盘、触控板或鼠标等。In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be shown in Figure 5 . The computer device includes a processor, memory, input/output interface, communication interface, display unit and input device. Among them, the processor, memory and input/output interface are connected through the system bus, and the communication interface, display unit and input device are connected to the system bus through the input/output interface. Wherein, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes non-volatile storage media and internal memory. The non-volatile storage medium stores operating systems and computer programs. This internal memory provides an environment for the execution of operating systems and computer programs in non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used for wired or wireless communication with external terminals. The wireless mode can be implemented through WIFI, mobile cellular network, NFC (Near Field Communication) or other technologies. The computer program implements a code quality detection method when executed by a processor. The display unit of the computer equipment is used to form a visually visible picture, and may be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display or an electronic ink display. The input device of the computer device can be a touch layer covered on the display screen, or it can be a button, trackball or touch pad provided on the computer device casing, or it can be External keyboard, trackpad or mouse, etc.

本领域技术人员可以理解,图5中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structure shown in Figure 5 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied. The specific computer equipment can May include more or fewer parts than shown, or combine certain parts, or have a different arrangement of parts.

在一个实施例中,提供了一种计算机设备,包括存储器和处理器,存储器中存储有计算机程序,该处理器执行计算机程序时实现以下步骤:In one embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, it implements the following steps:

通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果;Perform static analysis on the code to be detected through pre-configured static analysis tools to obtain static analysis results;

根据所述待检测代码生成测试用例;Generate test cases based on the code to be tested;

运行所述测试用例,获取所述测试用例运行过程中的动态日志信息;Run the test case and obtain dynamic log information during the execution of the test case;

根据所述静态分析结果和所述动态日志信息,生成所述待检测代码的质量检测结果。According to the static analysis results and the dynamic log information, a quality detection result of the code to be detected is generated.

在一个实施例中,处理器执行计算机程序时还实现以下步骤:基于目标检测需求,通过自动测试生成工具为所述待检测代码生成测试用例。In one embodiment, when the processor executes the computer program, it also implements the following steps: based on the target detection requirements, using an automatic test generation tool to generate test cases for the code to be detected.

在一个实施例中,处理器执行计算机程序时还实现以下步骤:加载底层虚拟机LLVM编译器,通过所述LLVM编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,获取运行过程中的动态日志信息。In one embodiment, when the processor executes the computer program, the following steps are also implemented: loading the underlying virtual machine LLVM compiler, compiling the code to be detected through the LLVM compiler; running the compiled code to be detected based on the test case Code to obtain dynamic log information during operation.

在一个实施例中,处理器执行计算机程序时还实现以下步骤:采用目标编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,当所述待检测代码运行完成后,生成剖析数据文件;通过预设的性能分析工具分析所述剖析数据文件,得到对应的日志动态信息。In one embodiment, when the processor executes the computer program, the processor also implements the following steps: using a target compiler to compile the code to be tested; and running the compiled code to be tested based on the test case. When the code to be tested is completed. Finally, a profiling data file is generated; the profiling data file is analyzed through a preset performance analysis tool to obtain corresponding log dynamic information.

在一个实施例中,所述质量检测结果中包括对所述待检测代码的改进方案;处理器执行计算机程序时还实现以下步骤:根据所述改进方案对所述待检测代码进行更新,得到更新后的目标代码。In one embodiment, the quality inspection results include an improvement plan for the code to be detected; when the processor executes the computer program, the following steps are also implemented: update the code to be detected according to the improvement plan to obtain an update the target code after.

在一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以下步骤:In one embodiment, a computer-readable storage medium is provided with a computer program stored thereon. When the computer program is executed by a processor, the following steps are implemented:

通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果;Perform static analysis on the code to be detected through pre-configured static analysis tools to obtain static analysis results;

根据所述待检测代码生成测试用例;Generate test cases based on the code to be tested;

运行所述测试用例,获取所述测试用例运行过程中的动态日志信息;Run the test case and obtain dynamic log information during the execution of the test case;

根据所述静态分析结果和所述动态日志信息,生成所述待检测代码的质量检测结果。According to the static analysis results and the dynamic log information, a quality detection result of the code to be detected is generated.

在一个实施例中,计算机程序被处理器执行时还实现以下步骤:基于目标检测需求,通过自动测试生成工具为所述待检测代码生成测试用例。In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: based on the target detection requirements, an automatic test generation tool is used to generate test cases for the code to be detected.

在一个实施例中,计算机程序被处理器执行时还实现以下步骤:加载底层虚拟机LLVM编译器,通过所述LLVM编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,获取运行过程中的动态日志信息。In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: loading the underlying virtual machine LLVM compiler, compiling the code to be detected through the LLVM compiler; running the compiled code to be tested based on the test case Detect the code and obtain dynamic log information during operation.

在一个实施例中,计算机程序被处理器执行时还实现以下步骤:采用目标编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,当所述待检测代码运行完成后,生成剖析数据文件;通过预设的性能分析工具分析所述剖析数据文件,得到对应的日志动态信息。In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: using a target compiler to compile the code to be tested; and running the compiled code to be tested based on the test case. When the code to be tested is run After completion, a profiling data file is generated; the profiling data file is analyzed through a preset performance analysis tool to obtain corresponding log dynamic information.

在一个实施例中,所述质量检测结果中包括对所述待检测代码的改进方案;计算机程序被处理器执行时还实现以下步骤:根据所述改进方案对所述待检测代码进行更新,得到更新后的目标代码。In one embodiment, the quality inspection results include an improvement plan for the code to be detected; when the computer program is executed by the processor, the following steps are also implemented: updating the code to be detected according to the improvement plan, to obtain Updated object code.

在一个实施例中,提供了一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现以下步骤:In one embodiment, a computer program product is provided, comprising a computer program that when executed by a processor implements the following steps:

通过预先配置的静态分析工具对待检测代码进行静态分析,得到静态分析结果;Perform static analysis on the code to be detected through pre-configured static analysis tools to obtain static analysis results;

根据所述待检测代码生成测试用例;Generate test cases based on the code to be tested;

运行所述测试用例,获取所述测试用例运行过程中的动态日志信息;Run the test case and obtain dynamic log information during the execution of the test case;

根据所述静态分析结果和所述动态日志信息,生成所述待检测代码的质量检测结果。According to the static analysis results and the dynamic log information, a quality detection result of the code to be detected is generated.

在一个实施例中,计算机程序被处理器执行时还实现以下步骤:基于目标检测需求,通过自动测试生成工具为所述待检测代码生成测试用例。In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: based on the target detection requirements, an automatic test generation tool is used to generate test cases for the code to be detected.

在一个实施例中,计算机程序被处理器执行时还实现以下步骤:加载底层虚拟机LLVM编译器,通过所述LLVM编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,获取运行过程中的动态日志信息。In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: loading the underlying virtual machine LLVM compiler, compiling the code to be detected through the LLVM compiler; running the compiled code to be tested based on the test case Detect the code and obtain dynamic log information during operation.

在一个实施例中,计算机程序被处理器执行时还实现以下步骤:采用目标编译器编译所述待检测代码;基于所述测试用例运行编译的所述待检测代码,当所述待检测代码运行完成后,生成剖析数据文件;通过预设的性能分析工具分析所述剖析数据文件,得到对应的日志动态信息。In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: using a target compiler to compile the code to be tested; and running the compiled code to be tested based on the test case. When the code to be tested is run After completion, a profiling data file is generated; the profiling data file is analyzed through a preset performance analysis tool to obtain corresponding log dynamic information.

在一个实施例中,所述质量检测结果中包括对所述待检测代码的改进方案;计算机程序被处理器执行时还实现以下步骤:根据所述改进方案对所述待检测代码进行更新,得到更新后的目标代码。In one embodiment, the quality inspection results include an improvement plan for the code to be detected; when the computer program is executed by the processor, the following steps are also implemented: updating the code to be detected according to the improvement plan, to obtain Updated object code.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、数据库或其它介质的任何引用,均可包括非易失性和易失性存储器中的至少一种。非易失性存储器可包括只读存储器(Read-OnlyMemory,ROM)、磁带、软盘、闪存、光存储器、高密度嵌入式非易失性存储器、阻变存储器(ReRAM)、磁变存储器(Magnetoresistive Random Access Memory,MRAM)、铁电存储器(Ferroelectric Random Access Memory,FRAM)、相变存储器(Phase Change Memory,PCM)、石墨烯存储器等。易失性存储器可包括随机存取存储器(Random Access Memory,RAM)或外部高速缓冲存储器等。作为说明而非局限,RAM可以是多种形式,比如静态随机存取存储器(Static Random Access Memory,SRAM)或动态随机存取存储器(Dynamic RandomAccess Memory,DRAM)等。本申请所提供的各实施例中所涉及的数据库可包括关系型数据库和非关系型数据库中至少一种。非关系型数据库可包括基于区块链的分布式数据库等,不限于此。本申请所提供的各实施例中所涉及的处理器可为通用处理器、中央处理器、图形处理器、数字信号处理器、可编程逻辑器、基于量子计算的数据处理逻辑器等,不限于此。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage. In the media, when executed, the computer program may include the processes of the above method embodiments. Any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetic variable memory (Magnetoresistive Random) Access Memory (MRAM), Ferroelectric Random Access Memory (FRAM), Phase Change Memory (PCM), graphene memory, etc. Volatile memory may include random access memory (Random Access Memory, RAM) or external cache memory. By way of illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM). The databases involved in the various embodiments provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include blockchain-based distributed databases, etc., but are not limited thereto. The processors involved in the various embodiments provided in this application may be general-purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to this.

以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined in any way. To simplify the description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, all possible combinations should be used. It is considered to be within the scope of this manual.

以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请的保护范围应以所附权利要求为准。The above-described embodiments only express several implementation modes of the present application, and their descriptions are relatively specific and detailed, but should not be construed as limiting the patent scope of the present application. It should be noted that, for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all fall within the protection scope of the present application. Therefore, the scope of protection of this application should be determined by the appended claims.

Claims (10)

1. A method for detecting code quality, the method comprising:
performing static analysis on the code to be detected through a pre-configured static analysis tool to obtain a static analysis result;
generating a test case according to the code to be detected;
running the test case and acquiring dynamic log information in the running process of the test case;
and generating a quality detection result of the code to be detected according to the static analysis result and the dynamic log information.
2. The method of claim 1, wherein the generating test cases from the code to be detected comprises:
and generating a test case for the code to be detected through an automatic test generation tool based on the target detection requirement.
3. The method of claim 1, wherein the running the test case, obtaining dynamic log information during the running of the test case, comprises:
loading an LLVM compiler of a bottom virtual machine, and compiling the code to be detected through the LLVM compiler;
and running the compiled code to be detected based on the test case, and acquiring dynamic log information in the running process.
4. The method of claim 1, wherein the running the test case, obtaining dynamic log information during the running of the test case, comprises:
compiling the code to be detected by adopting a target compiler;
running the compiled code to be detected based on the test case, and generating a profiling data file after the code to be detected is run;
analyzing the analysis data file through a preset performance analysis tool to obtain corresponding log dynamic information.
5. The method of claim 4, wherein the target compiler is a compiler with a-pg compilation option.
6. The method according to any one of claims 1 to 5, wherein the quality detection result comprises an improvement to the code to be detected; after the quality detection result of the code to be detected is generated, the method further comprises:
and updating the code to be detected according to the improved scheme to obtain updated target code.
7. A code quality detection apparatus, the apparatus comprising:
the static analysis module is used for carrying out static analysis on the code to be detected through a pre-configured static analysis tool to obtain a static analysis result;
the test case generation module is used for generating a test case according to the code to be detected;
the dynamic analysis module is used for running the test case and acquiring dynamic log information in the running process of the test case;
and the detection result generation module is used for generating a quality detection result of the code to be detected according to the static analysis result and the dynamic log information.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202310784106.4A 2023-06-29 2023-06-29 Code quality detection methods, devices, computer equipment and storage media Pending CN116893960A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310784106.4A CN116893960A (en) 2023-06-29 2023-06-29 Code quality detection methods, devices, computer equipment and storage media

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310784106.4A CN116893960A (en) 2023-06-29 2023-06-29 Code quality detection methods, devices, computer equipment and storage media

Publications (1)

Publication Number Publication Date
CN116893960A true CN116893960A (en) 2023-10-17

Family

ID=88314290

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310784106.4A Pending CN116893960A (en) 2023-06-29 2023-06-29 Code quality detection methods, devices, computer equipment and storage media

Country Status (1)

Country Link
CN (1) CN116893960A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117707987A (en) * 2024-02-06 2024-03-15 暗物智能科技(广州)有限公司 Test case detection method and device, electronic equipment and storage medium
CN119322733A (en) * 2024-11-19 2025-01-17 霖久智慧(广东)科技有限公司 Code analysis method, device, equipment and storage medium based on artificial intelligence

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117707987A (en) * 2024-02-06 2024-03-15 暗物智能科技(广州)有限公司 Test case detection method and device, electronic equipment and storage medium
CN117707987B (en) * 2024-02-06 2024-06-11 暗物智能科技(广州)有限公司 Test case detection method and device, electronic equipment and storage medium
CN119322733A (en) * 2024-11-19 2025-01-17 霖久智慧(广东)科技有限公司 Code analysis method, device, equipment and storage medium based on artificial intelligence
CN119322733B (en) * 2024-11-19 2025-04-08 霖久智慧(广东)科技有限公司 Code analysis method, device, equipment, and storage medium based on artificial intelligence

Similar Documents

Publication Publication Date Title
CN113742119B (en) Call stack backtracing method, device and computer equipment for embedded system
Costa et al. What's wrong with my benchmark results? Studying bad practices in JMH benchmarks
US9898387B2 (en) Development tools for logging and analyzing software bugs
Xu et al. Go with the flow: Profiling copies to find runtime bloat
WO2021098148A1 (en) Software compiling method and apparatus, and electronic device and storage medium
US9202005B2 (en) Development and debug environment in a constrained random verification
US8832125B2 (en) Extensible event-driven log analysis framework
CN116893960A (en) Code quality detection methods, devices, computer equipment and storage media
US8370807B2 (en) Debugging for runtime type systems
US20070011669A1 (en) Software migration
US9336128B2 (en) Method and system for code analysis using symbolic types
US8924437B2 (en) Memory usage data collection and analysis for dynamic objects
CN111897727A (en) Software testing method, device, computer equipment and storage medium
JP6303749B2 (en) Method and system for analyzing a software program and non-transitory computer readable medium
US9141351B2 (en) Indicators for resources with idempotent close methods in software programs
CN114579452A (en) Interface influence detection method and related equipment
CN103186463B (en) Determine the method and system of the test specification of software
CN119668576B (en) Low-code software development system
US9582397B2 (en) Method and system for obtaining run-time information associated with executing an executable
CN115794254A (en) Cloud Computing-Based Component R&D Management Platform and Method
CN118378719B (en) A method for building a machine learning workflow
US20130111432A1 (en) Validation of a system model including an activity diagram
US9710360B2 (en) Optimizing error parsing in an integrated development environment
CN116820915A (en) A code detection method, device and electronic equipment
Leroy et al. Monilogging for executable domain-specific languages

Legal Events

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