Redundancy detection method and device, equipment, storage medium and program product
By setting the configuration parameters of the detection tool, it has the redundant detection function of various versions of the project program to be detected, which solves the problem of difficulty in cross-version redundant code detection in the existing technology, and achieves comprehensive redundant detection and efficient detection efficiency of front-end development projects.
Patent Information
- Application Number
- CN202411830293.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-05-06
AI Technical Summary
It is difficult for the existing technology to conduct comprehensive redundant code detection on different versions of front-end development projects, and it is impossible to achieve cross-version redundant code detection.
By setting the configuration parameters of the detection tool, it has the redundant detection function of various versions of the project program to be detected. The specific steps include detecting and configuring the detection tool according to preset configuration parameters, analyzing the relationship between each code segment in the project to be detected, generating the first and second file directories, and comparing them to determine the redundant code segment.
A comprehensive redundant detection of the inspection project program is realized, without modifying the redundant detection program according to specific scenarios, significantly improving the redundant detection efficiency in different scenarios.
Smart Images

Figure CN119938053A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer equipment, and in particular to a redundancy detection method, apparatus, device, storage medium and program product. Background Art
[0002] Front-end development, also known as client-side development, refers to the process of using technologies such as HTML, CSS, and JavaScript to display content and interfaces to users through web browsers. Front-end development not only focuses on user experience, but also involves responsive design, performance optimization, front-end security and other aspects.
[0003] In the related technologies, in front-end development, the problem of code redundancy is often encountered. As time goes by and the project is constantly updated and iterated, the project becomes more and more bloated, and there are many useless files and dependencies, which not only increases the amount of code, but also affects the maintainability and development efficiency of the project. At present, code identification tools (for example, useless-files-webpack-plugin and depcheck tools) are mainly used to detect redundant code. However, code identification tools can only detect redundant code of the corresponding version, and cannot detect redundant code of other versions.
[0004] Therefore, how to comprehensively detect redundant codes is an urgent problem to be solved. Summary of the invention
[0005] Based on this, it is necessary to provide a redundancy detection method, device, equipment, storage medium and program product that can comprehensively detect redundant codes in response to the above technical problems.
[0006] In a first aspect, the present application provides a redundancy detection method, the method comprising:
[0007] Performing detection configuration on the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, the detection environment, the detection method, the detection result output format, and the detection result output path;
[0008] The detection tool after detection configuration performs redundant detection on the program of the item to be detected and outputs the detection results.
[0009] The above method sets the configuration parameters of the detection tool so that the detection tool has the function of redundant detection of various versions of the project programs to be detected, thereby realizing comprehensive redundant detection of the projects to be detected; in addition, there is no need to modify the redundant detection program according to the specific scenario, which greatly improves the efficiency of redundant detection of the program projects to be detected in different scenarios.
[0010] In one embodiment, the detection tool after the detection configuration performs redundancy detection on the program of the item to be detected and outputs the detection result, including:
[0011] Analyze the relationship between the code segments in the program of the project to be tested according to the detection tool after the detection configuration, and generate a first file directory corresponding to the program of the project to be tested;
[0012] Traverse the file path corresponding to the program of the project to be detected, and generate a second file directory corresponding to the program of the project to be detected;
[0013] According to the first file directory and the second file directory, a redundancy check is performed on the program of the project to be checked, and the check result is output.
[0014] The redundant detection method provided in the embodiment of the present application performs redundant detection on the program to be detected by determining the first file directory determined by the relationship between the code segments in the program to be detected and the second file directory corresponding to the file path of the program to be detected, and obtains the detection result, thereby providing an implementation method for redundant detection of the program to be detected.
[0015] In one embodiment, the detection tool includes a resource processing module, which analyzes the relationship between the code segments in the program of the project to be detected and generates a first file directory corresponding to the program of the project to be detected, including:
[0016] Start the resource processing module to analyze the relationship between the code segments in the program of the project to be tested, and generate the resource reference relationship between the code segments;
[0017] Generate a first file directory according to the resource reference relationship.
[0018] The method for obtaining the first file directory provided in the embodiment of the present application provides a certain data basis for subsequent redundant detection of the program of the project to be detected based on the first file directory.
[0019] In one embodiment, the method further comprises:
[0020] If the preset configuration parameters include detection option parameters, and the detection option parameters are used to filter development reference items or to skip detection target directories, filtering the first file directory and the second file directory to obtain a processed first file directory and a processed second file directory;
[0021] According to the first file directory and the second file directory, redundancy detection is performed on the program of the project to be detected, and the detection results are output, including:
[0022] According to the processed first file directory and the processed second file directory, a redundancy check is performed on the program of the project to be checked, and a check result is output.
[0023] The redundant detection method provided in the embodiment of the present application realizes filtering of the ignored items in the program of the project to be detected by setting the detection option parameters, so that when the redundant detection is performed on the filtered program of the project to be detected, there is no need to pay attention to the ignored items, thereby improving the efficiency of redundant detection.
[0024] In one embodiment, the redundancy detection of the program of the project to be detected is performed according to the first file directory and the second file directory, and the detection result is output, including:
[0025] Compare the first file directory and the second file directory to determine the difference file directories;
[0026] Determine the redundant code segments in the program of the project to be tested based on the difference file directory and obtain the test results.
[0027] The redundant code segment detection method provided in the embodiment of the present application realizes the detection of redundant code by comparing the first file directory constructed by the code segment with the second file directory constructed by the file path, thereby providing a data basis for subsequently obtaining the detection result based on the redundant code segment.
[0028] In one embodiment, the above-mentioned detection configuration of the detection tool according to the preset configuration parameters includes:
[0029] Displaying a configuration page on the startup interface of the detection tool; the configuration page includes a parameter editing window or a command window;
[0030] In response to a first input operation on the parameter editing window, a preset configuration parameter corresponding to the first input operation is obtained; or, in response to a second input operation on the command window, a preset configuration parameter corresponding to the second input operation is obtained.
[0031] The configuration method of the detection tool provided in the embodiment of the present application realizes the parameter configuration of the detection tool through the parameter editing window and the command window, so that the detection tool has the redundant detection function of the redundant codes of various versions of the project program to be detected, thereby improving the redundant detection efficiency of the detection tool.
[0032] In a second aspect, the present application further provides a redundancy detection device, the device comprising:
[0033] A configuration module, used to configure the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, detection environment, detection method, detection result output format, and detection result output path;
[0034] The detection module is used to perform redundancy detection on the program of the detection project according to the detection tool after the detection configuration, and output the detection result.
[0035] In a third aspect, the present application further provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the following steps when executing the computer program:
[0036] Performing detection configuration on the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, the detection environment, the detection method, the detection result output format, and the detection result output path;
[0037] The detection tool after detection configuration performs redundant detection on the program of the item to be detected and outputs the detection results.
[0038] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0039] Performing detection configuration on the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, the detection environment, the detection method, the detection result output format, and the detection result output path;
[0040] The detection tool after detection configuration performs redundant detection on the program of the item to be detected and outputs the detection results.
[0041] In a fifth aspect, the present application further provides a computer program product, the computer program product comprising a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0042] Performing detection configuration on the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, the detection environment, the detection method, the detection result output format, and the detection result output path;
[0043] The detection tool after detection configuration performs redundant detection on the program of the item to be detected and outputs the detection results.
[0044] The above-mentioned redundancy detection method, device, equipment, storage medium and program product, the method sets the configuration parameters of the detection tool so that the detection tool has the redundancy detection function of various versions of the program of the project to be detected, thereby realizing comprehensive redundancy detection of the project to be detected; in addition, there is no need to modify the redundancy detection program according to the specific scenario, which greatly improves the efficiency of redundancy detection of the program projects to be detected in different scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is an application environment diagram of a redundancy detection method in an embodiment;
[0046] Figure 2 is a schematic flow chart of a redundancy detection method in one embodiment;
[0047] Figure 3 is a flow chart of a redundancy detection method in another embodiment;
[0048] Figure 4 is a flow chart of a redundancy detection method in another embodiment;
[0049] Figure 5 is a flow chart of a redundancy detection method in another embodiment;
[0050] Figure 6 is a flow chart of a redundancy detection method in another embodiment;
[0051] Figure 7 is a flow chart of a redundancy detection method in another embodiment;
[0052] Figure 8 is a flow chart of a redundancy detection method in another embodiment;
[0053] Fig. 9 is a schematic flow chart of a redundancy detection method in one embodiment;
[0054] Fig.10 is a structural block diagram of a redundancy detection device in one embodiment;
[0055] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0057] Front-end development, also known as client-side development, refers to the process of using technologies such as HTML, CSS, and JavaScript to display content and interfaces to users through web browsers. Front-end development not only focuses on user experience, but also involves responsive design, performance optimization, front-end security and other aspects.
[0058] In the related art, in front-end development, the problem of code redundancy is often encountered. As time goes by and the project is constantly updated and iterated, the project becomes more and more bloated, and there are many useless files and dependencies invisibly, which not only increases the amount of code, but also affects the maintainability and development efficiency of the project. At present, code recognition tools (for example, useless-files-webpack-plugin plug-in and depcheck tool) are mainly used to detect redundant code. However, code recognition tools can only detect redundant code of the corresponding version, and cannot detect redundant code of other versions. Therefore, how to comprehensively detect redundant code is a problem that needs to be solved urgently. This application aims to solve this problem.
[0059] After introducing the background technology of the redundancy detection method provided by the embodiment of the present application, the following briefly describes the implementation environment involved in the redundancy detection method provided by the embodiment of the present application. The redundancy detection method provided by the embodiment of the present application can be applied to Figure 1 In the application environment shown, the implementation environment includes a server 104, which can be implemented as an independent server 104 or a server cluster composed of multiple servers 104, and a data storage system 102 can store data that the server 104 needs to process. The data storage system 102 can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, a redundancy detection tool can be installed on the server 104 to perform redundancy detection on the program of the project to be detected and obtain a redundancy detection result.
[0060] Those skilled in the art will understand that Figure 1 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific terminal may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0061] After introducing the application scenarios of the redundancy detection method provided in the embodiments of the present application, the following focuses on introducing the redundancy detection method described in the present application.
[0062] In one embodiment, Figure 2 As shown, a redundancy detection method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:
[0063] S201, configuring a detection tool according to preset configuration parameters.
[0064] Among them, the preset configuration parameters are used to configure at least one aspect of the detection version, the detection environment, the detection method, the output format of the detection result, and the output path of the detection result. The preset configuration parameters include file configuration parameters, and also include at least one of environment parameters, detection option parameters, output format parameters, and output path parameters. Optionally, when the preset configuration parameters are used to configure in terms of the detection version, the corresponding may be file configuration parameters; when the preset configuration parameters are used to configure in terms of the detection environment, the corresponding may be environment parameters; when the preset configuration parameters are used to configure in terms of the detection method, the corresponding may be detection option parameters; when the preset configuration parameters are used to configure in terms of the output format of the detection result, the corresponding may be output format parameters; when the preset configuration parameters are used in the detection result output, the corresponding may be output path parameters.
[0065] The file configuration parameters refer to configuration parameters that support different versions of project configuration files, for example, configuration parameters that support project configuration files in the form of webpack.config.js or vue.config.js.
[0066] Among them, environment parameters refer to configuration parameters that support different versions of environment configurations, for example, configuration parameters that support environment configurations of webpack4 or webpack5.
[0067] Among them, the detection option parameter refers to the option parameter that needs to be used to detect the project program to be detected when performing redundancy detection. For example, the withoutDev option parameter, if the withoutDev option parameter is selected, it means that the redundancy detection ignores the development dependency check. For another example, the excludeDirs option parameter, if the excludeDirs option parameter is selected, it means that the redundancy detection ignores the directory detection.
[0068] The output format parameter refers to a format parameter for outputting the detection result of the redundancy detection. For example, the embodiment of the present application supports outputting the detection result in multiple formats such as string, json, and file.
[0069] The output path parameter refers to a path parameter for outputting the detection result of the redundancy detection.
[0070] In the embodiment of the present application, when it is necessary to perform redundancy detection on the program to be detected, a new detection tool is provided to support redundancy detection of different versions of the program to be detected. When using the tool for redundancy detection, it is necessary to first configure the detection parameters of the detection tool. Optionally, the detection tool can be configured for detection according to file configuration parameters, and at least one of environment parameters, detection option parameters, output format parameters, and output path parameters.
[0071] For example, the version of the project program to be detected supported by the detection tool is detected and configured according to the file configuration parameters and the environment parameters, so that the detection tool determines the version of the project program to be detected according to the file configuration parameters and the environment parameters, and performs redundancy detection on the version of the project program to be detected.
[0072] For another example, the version of the program to be tested supported by the detection tool is configured for detection according to the file configuration parameters and the detection option parameters, so that the detection tool determines the detection items to be ignored according to the file configuration parameters and the detection option parameters, and performs redundant detection on the program to be tested after the detection items are ignored.
[0073] For another example, the version of the program to be detected supported by the detection tool is configured for detection according to the file configuration parameters and the output format parameters, so that the detection tool determines the output format of the detection result of the redundancy detection according to the file configuration parameters and the output format parameters.
[0074] For another example, the version of the program to be detected supported by the detection tool is configured for detection according to the file configuration parameters and the output path parameters, so that the detection tool determines the output path of the detection result of the redundancy detection according to the file configuration parameters and the output path parameters.
[0075] S202, performing redundancy detection on the program of the item to be detected according to the detection tool after the detection configuration, and outputting the detection result.
[0076] In the embodiment of the present application, the detection tool is configured for detection as described above to obtain the detection tool after detection configuration, and redundant detection is performed on the program of the project to be detected based on the detection tool after detection configuration to obtain redundant detection results of the program of the project to be detected, and the redundant detection results of the program of the project to be detected are output.
[0077] The redundant detection method provided in the embodiment of the present application performs detection configuration on the detection tool according to preset configuration parameters, performs redundant detection on the program of the project to be detected according to the detection tool after the detection configuration, and outputs the detection result; the preset configuration parameters are used to configure at least one aspect of the detection version, detection environment, detection method, detection result output format, and detection result output path. The above method sets the configuration parameters of the detection tool so that the detection tool has the redundant detection function of various versions of the program of the project to be detected, and realizes comprehensive redundant detection of the project to be detected; in addition, there is no need to modify the redundant detection program according to the specific scenario, which greatly improves the efficiency of redundant detection of the program projects to be detected in different scenarios.
[0078] In one embodiment, Figure 2 Based on the embodiment shown, the process of performing redundant detection on the imaging of the detected item and outputting the detection result can be described as follows: Figure 3 As shown, the above S202 "performs a redundant test on the program of the item to be tested according to the test tool after the test configuration, and outputs the test result" includes:
[0079] S301 , analyzing the relationship between the code segments in the program to be detected according to the detection tool after the detection configuration, and generating a first file directory corresponding to the program to be detected.
[0080] The relationship between the code segments refers to the reference relationship between the code segments. For example, code segment A includes code segment B and code segment C, and code segment B also includes code segment D. Then the relationship between code segments A, B, C and D can be generated based on them.
[0081] The first file directory corresponding to the project program to be detected refers to the location information of each code segment in the file.
[0082] In an embodiment of the present application, a detection tool based on the detection configuration analyzes the relationship between the code segments in the project program to be detected, obtains the association relationship between the code segments in the program to be detected, and generates a first file directory corresponding to the project program to be detected based on the association relationship between the code segments.
[0083] S302: traverse the file path corresponding to the program of the project to be detected, and generate a second file directory corresponding to the program of the project to be detected.
[0084] In the embodiment of the present application, all file paths in the project program to be detected can also be traversed, and according to the file paths corresponding to the project program to be detected, a second file directory corresponding to each file path in the project program to be detected can be generated.
[0085] S303: Perform redundancy detection on the program of the project to be detected according to the first file directory and the second file directory, and output the detection result.
[0086] In an embodiment of the present application, when the first file directory and the second file directory are obtained as mentioned above, redundant detection can be performed on the project program to be detected based on the first file directory and the second file directory to obtain redundant detection results of the project program to be detected, and output the redundant detection results of the project program to be detected.
[0087] The redundant detection method provided in the embodiment of the present application performs redundant detection on the program to be detected by determining the first file directory determined by the relationship between the code segments in the program to be detected and the second file directory corresponding to the file path of the program to be detected, and obtains the detection result, thereby providing an implementation method for redundant detection of the program to be detected.
[0088] In one embodiment, Figure 3Based on the embodiment shown, the above detection tool includes a resource processing module, which can describe the generation process of the first file directory corresponding to the program of the project to be detected, such as Figure 4 As shown, the above S301 "analyzing the relationship between the code segments in the program of the project to be detected and generating a first file directory corresponding to the program of the project to be detected" includes:
[0089] S401 , starting a resource processing module to analyze the relationship between the code segments in the program of the project to be detected, and generating a resource reference relationship between the code segments.
[0090] Among them, the resource processing module refers to the webpack packaging process.
[0091] In the embodiment of the present application, the detection tool may further include a resource processing module, which may be activated to analyze the relationship between the code segments in the program of the project to be detected to generate a resource reference relationship between the code segments.
[0092] S402: Generate a first file directory according to the resource reference relationship.
[0093] In the embodiment of the present application, after the resource reference relationship between the code segments is obtained as described above, a first file directory corresponding to the project program to be detected can be generated according to the resource reference relationship between the code segments.
[0094] The method for obtaining the first file directory provided in the embodiment of the present application provides a certain data basis for subsequent redundant detection of the program of the project to be detected based on the first file directory.
[0095] In one embodiment, Figure 3 Based on the embodiment shown, Figure 5 As shown, the above method also includes:
[0096] S304. If the preset configuration parameters include detection option parameters, and the detection option parameters are used to filter development reference items or to skip detecting a target directory, the first file directory and the second file directory are filtered to obtain a processed first file directory and a processed second file directory.
[0097] The development reference item refers to the basic code for coding during the development process.
[0098] Among them, skipping the detection target directory means ignoring the target items in the program of the project to be detected for detection.
[0099] In an embodiment of the present application, when the preset configuration parameters include detection option parameters, different items in the first file directory and the second file directory can be filtered by configuring different option parameters to obtain a filtered first file directory and a processed second file directory.
[0100] Optionally, if the detection option parameter is used to filter development reference items, the development reference items of the first file directory and the second file directory may be filtered to obtain the first file directory and the second file directory after the filtering process. Optionally, if the detection option parameter is used to skip detecting the target directory, the detection target directory of the first file directory and the second file directory may be filtered to obtain the first file directory and the second file directory after the filtering process. Optionally, if the detection option parameter is used to filter development reference items and skip detecting the target directory, the development reference items and the target directory in the first file directory and the second file directory may be filtered to obtain the filtered first file directory and the filtered second file directory.
[0101] The above S303 “performing a redundancy check on the program of the project to be checked according to the first file directory and the second file directory and outputting the check result” includes:
[0102] S303: Perform redundancy detection on the program of the project to be detected according to the processed first file directory and the processed second file directory, and output the detection result.
[0103] In an embodiment of the present application, when the processed first file directory and the processed second file directory are obtained as mentioned above, redundant detection can be performed on the project program to be detected based on the processed first file directory and the processed second file directory to obtain redundant detection results of the project program to be detected, and output the redundant detection results of the project program to be detected.
[0104] The redundant detection method provided in the embodiment of the present application realizes filtering of the ignored items in the program of the project to be detected by setting the detection option parameters, so that when the redundant detection is performed on the filtered program of the project to be detected, there is no need to pay attention to the ignored items, thereby improving the efficiency of redundant detection.
[0105] In one embodiment, Figure 3 Based on the embodiment shown, the process of performing redundant detection on the program of the detected item and obtaining the detection result can be described as follows: Figure 6 As shown, the above S303 "perform redundancy detection on the program of the project to be detected according to the first file directory and the second file directory, and output the detection result" includes:
[0106] S501: Compare the first file directory and the second file directory to determine the difference file directories.
[0107] In the embodiment of the present application, when the first file directory and the second file directory are obtained as described above, the first file directory and the second file directory can be compared to obtain a comparison result, and the file directory with differences in the comparison result can be determined as a difference file directory.
[0108] S502: Determine the redundant code segments in the program of the project to be detected according to the difference file directory, and obtain the detection result.
[0109] In an embodiment of the present application, after the difference file directory is obtained as described above, the code segment corresponding to the difference file directory can be determined as a redundant code segment in the project program to be detected, and the detection result can be obtained based on the redundant code segment in the project program to be detected.
[0110] The redundant code segment detection method provided in the embodiment of the present application realizes the detection of redundant code by comparing the first file directory constructed by the code segment with the second file directory constructed by the file path, thereby providing a data basis for subsequently obtaining the detection result based on the redundant code segment.
[0111] In one embodiment, Figure 2-Figure 6 Based on any of the embodiments shown, the process of configuring the detection tool can be described as follows: Figure 7 As shown, the above S201 "configure the detection tool according to the preset configuration parameters" includes:
[0112] S601. Display a configuration page on a startup interface of a detection tool.
[0113] The configuration page includes a parameter editing window or a command window.
[0114] In the embodiment of the present application, when the detection tool needs to be parameterized, the startup control in the startup page of the detection tool can be triggered to display the configuration page on the startup page of the detection tool in the server. Optionally, a data editing window can be displayed on the startup interface of the detection tool, or a command input window can be displayed on the startup interface.
[0115] S602: In response to a first input operation on the parameter editing window, obtain a preset configuration parameter corresponding to the first input operation; or, in response to a second input operation on the command window, obtain a preset configuration parameter corresponding to the second input operation.
[0116] In an embodiment of the present application, after the parameter editing window is displayed on the startup interface of the above-mentioned detection tool, the user can trigger the first input operation in the parameter editing window as needed, so that the detection tool obtains the preset configuration parameters corresponding to the first input operation.
[0117] Optionally, the parameter editing window displayed on the startup interface may display a file configuration parameter editing window, an environment parameter editing window, a detection option parameter editing window, an output format parameter editing window, and an output path parameter editing window. The user may edit the file configuration parameters in the file configuration parameter editing window, edit the environment parameters in the environment parameter editing window, edit the detection option parameters in the detection option parameter editing window, edit the output format parameters in the output format parameter editing window, and edit the output path parameters in the output path parameter editing window. Further, the detection tool determines the preset configuration parameters of the detection tool based on the editing parameters input in the editing window.
[0118] In the embodiment of the present application, after the command input window is displayed on the startup interface of the above-mentioned detection tool, the user can trigger the second input operation in the command input window as needed, so that the detection tool obtains the preset configuration parameters corresponding to the second input operation.
[0119] Optionally, the user can enter a second input operation in the command window displayed in the startup interface. The second input operation can input file configuration parameters, environment parameters, detection option parameters, output format parameters and output path parameters, so that the detection tool determines the preset configuration parameters of the detection tool based on the editing parameters entered in the command window.
[0120] The configuration method of the detection tool provided in the embodiment of the present application realizes the parameter configuration of the detection tool through the parameter editing window and the command window, so that the detection tool has the redundant detection function of the redundant codes of various versions of the project program to be detected, thereby improving the redundant detection efficiency of the detection tool.
[0121] In one embodiment, see Figure 8 , and also provides a redundancy detection method, comprising:
[0122] S10, displaying a parameter editing window or a command window on the startup interface of the detection tool;
[0123] S11. In response to a first input operation on the parameter editing window, obtaining a preset configuration parameter corresponding to the first input operation; or, in response to a second input operation on the command window, obtaining a preset configuration parameter corresponding to the second input operation;
[0124] S12, starting the resource processing module in the detection tool to analyze the relationship between the code segments in the program of the project to be detected, and generating the resource reference relationship between the code segments;
[0125] S13, generating a first file directory according to the resource reference relationship;
[0126] S14, traversing the file path corresponding to the program of the project to be detected, and generating a second file directory corresponding to the program of the project to be detected;
[0127] S15. If the preset configuration parameters include a detection option parameter, and the detection option parameter is used to filter the development reference item or to skip the detection target directory, filtering the first file directory and the second file directory to obtain a processed first file directory and a processed second file directory;
[0128] S16, comparing the processed first file directory with the processed second file directory to determine the difference file directories;
[0129] S17. Determine the redundant code segments in the program of the project to be detected according to the difference file directory, and obtain the detection result.
[0130] Optional, see Fig. 9 , a flowchart of redundant detection is also provided, including: first reading the pre-configuration information of the detection tool, and configuring the detection tool based on the pre-configuration information to obtain the detection tool after the detection configuration, and then starting webpack to generate a second file directory corresponding to each code segment corresponding to the project program to be detected, traversing the file path corresponding to the project program to be detected, generating a second file directory corresponding to the project program to be detected, and then deleting the directories and development dependency options specified in excludeDirs in the first file directory and the second file directory, obtaining the deleted first file directory and the deleted second file directory, and checking whether the dependency is referenced in the file, checking whether the file is referenced in the dependency tree, obtaining the inspection result, and formatting the inspection result for output, and ending the detection process.
[0131] The above method sets the configuration parameters of the detection tool so that the detection tool has the function of redundant detection of various versions of the project programs to be detected, thereby realizing comprehensive redundant detection of the projects to be detected; in addition, there is no need to modify the redundant detection program according to the specific scenario, which greatly improves the efficiency of redundant detection of the program projects to be detected in different scenarios.
[0132] The methods described in the above steps are all described in the above embodiments. Please refer to the above description for details and will not be repeated here.
[0133] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0134] Based on the same inventive concept, the embodiment of the present application also provides a redundant detection device for implementing the redundant detection method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more redundant detection device embodiments provided below can refer to the limitations of the redundant detection method above, and will not be repeated here.
[0135] In one embodiment, the above-mentioned redundancy detection device, such as Fig.10 As shown, it includes: a configuration module 10 and a detection module 11, wherein:
[0136] Configuration module 10, used to configure the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, detection environment, detection method, detection result output format, and detection result output path;
[0137] The detection module 11 is used to perform redundancy detection on the program of the detection item according to the detection tool after the detection configuration, and output the detection result.
[0138] In one embodiment, the detection module 11 includes: an analysis unit, a generation unit and a detection unit, wherein:
[0139] An analysis unit, specifically used to analyze the relationship between the code segments in the program of the project to be detected according to the detection tool after the detection configuration, and generate a first file directory corresponding to the program of the project to be detected;
[0140] A generating unit, specifically used to traverse the file path corresponding to the program of the project to be detected, and generate a second file directory corresponding to the program of the project to be detected;
[0141] The detection unit is specifically used to perform redundancy detection on the program of the project to be detected according to the first file directory and the second file directory, and output the detection result.
[0142] In one embodiment, the above-mentioned detection tool includes a resource processing module, and the above-mentioned generation unit is specifically used to start the resource processing module to analyze the relationship between each code segment in the program of the project to be detected, generate the resource reference relationship between each code segment; and generate the first file directory according to the resource reference relationship.
[0143] In one embodiment, the detection module 11 further includes: a processing unit, specifically configured to filter the first file directory and the second file directory to obtain a processed first file directory and a processed second file directory when the preset configuration parameters include a detection option parameter and the detection option parameter is used to filter the development reference item or to skip the detection target directory;
[0144] The above detection unit is specifically used to perform redundancy detection on the program of the project to be detected according to the processed first file directory and the processed second file directory, and output the detection result.
[0145] In one embodiment, the detection unit is further used to compare the first file directory and the second file directory to determine a difference file directory; determine the redundant code segments in the program of the project to be detected according to the difference file directory to obtain the detection result.
[0146] In one embodiment, the configuration module 10 includes: a display unit and a configuration unit, wherein:
[0147] A display unit, specifically used to display a configuration page on the startup interface of the detection tool; the configuration page includes a parameter editing window or a command window;
[0148] The configuration unit is specifically used to obtain the preset configuration parameters corresponding to the first input operation in response to the first input operation on the parameter editing window; or to obtain the preset configuration parameters corresponding to the second input operation in response to the second input operation on the command window.
[0149] Each module in the above-mentioned redundancy detection device can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0150] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.11As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a redundant detection method is realized. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0151] In one embodiment, a computer device is provided. The computer device may be a terminal or a server. The internal structure diagram thereof may be as follows: Fig.11As shown, the computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a redundancy detection method is realized. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0152] Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0153] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0154] Performing detection configuration on the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, the detection environment, the detection method, the detection result output format, and the detection result output path;
[0155] The detection tool after detection configuration performs redundant detection on the program of the item to be detected and outputs the detection results.
[0156] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0157] Analyze the relationship between the code segments in the program of the project to be tested according to the detection tool after the detection configuration, and generate a first file directory corresponding to the program of the project to be tested;
[0158] Traverse the file path corresponding to the program of the project to be detected, and generate a second file directory corresponding to the program of the project to be detected;
[0159] According to the first file directory and the second file directory, a redundancy check is performed on the program of the project to be checked, and the check result is output.
[0160] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0161] Start the resource processing module to analyze the relationship between the code segments in the program of the project to be tested, and generate the resource reference relationship between the code segments;
[0162] Generate a first file directory according to the resource reference relationship.
[0163] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0164] If the preset configuration parameters include detection option parameters, and the detection option parameters are used to filter development reference items or to skip detection target directories, filtering the first file directory and the second file directory to obtain a processed first file directory and a processed second file directory;
[0165] According to the first file directory and the second file directory, redundancy detection is performed on the program of the project to be detected, and the detection results are output, including:
[0166] According to the processed first file directory and the processed second file directory, a redundancy check is performed on the program of the project to be checked, and a check result is output.
[0167] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0168] Compare the first file directory with the second file directory to determine the difference file directories;
[0169] Determine the redundant code segments in the program of the project to be tested based on the difference file directory and obtain the test results.
[0170] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0171] Displaying a configuration page on the startup interface of the detection tool; the configuration page includes a parameter editing window or a command window;
[0172] In response to a first input operation on the parameter editing window, a preset configuration parameter corresponding to the first input operation is obtained; or, in response to a second input operation on the command window, a preset configuration parameter corresponding to the second input operation is obtained.
[0173] The computer device provided in the above embodiment has an implementation principle and technical effects similar to those of the above method embodiment, which will not be described in detail here.
[0174] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0175] Performing detection configuration on the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, the detection environment, the detection method, the detection result output format, and the detection result output path;
[0176] The detection tool after detection configuration performs redundant detection on the program of the item to be detected and outputs the detection results.
[0177] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0178] Analyze the relationship between the code segments in the program of the project to be tested according to the detection tool after the detection configuration, and generate a first file directory corresponding to the program of the project to be tested;
[0179] Traverse the file path corresponding to the program of the project to be detected, and generate a second file directory corresponding to the program of the project to be detected;
[0180] According to the first file directory and the second file directory, a redundancy check is performed on the program of the project to be checked, and the check result is output.
[0181] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0182] Start the resource processing module to analyze the relationship between the code segments in the program of the project to be tested, and generate the resource reference relationship between the code segments;
[0183] Generate a first file directory according to the resource reference relationship.
[0184] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0185] If the preset configuration parameters include detection option parameters, and the detection option parameters are used to filter development reference items or to skip detection target directories, filtering the first file directory and the second file directory to obtain a processed first file directory and a processed second file directory;
[0186] According to the first file directory and the second file directory, redundancy detection is performed on the program of the project to be detected, and the detection results are output, including:
[0187] According to the processed first file directory and the processed second file directory, a redundancy check is performed on the program of the project to be checked, and a check result is output.
[0188] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0189] Compare the first file directory and the second file directory to determine the difference file directories;
[0190] Determine the redundant code segments in the program of the project to be tested based on the difference file directory and obtain the test results.
[0191] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0192] Displaying a configuration page on the startup interface of the detection tool; the configuration page includes a parameter editing window or a command window;
[0193] In response to a first input operation on the parameter editing window, a preset configuration parameter corresponding to the first input operation is obtained; or, in response to a second input operation on the command window, a preset configuration parameter corresponding to the second input operation is obtained.
[0194] The above embodiment provides a computer-readable storage medium, whose implementation principle and technical effect are similar to those of the above method embodiment, and will not be repeated here.
[0195] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0196] Performing detection configuration on the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, the detection environment, the detection method, the detection result output format, and the detection result output path;
[0197] The detection tool after detection configuration performs redundant detection on the program of the item to be detected and outputs the detection results.
[0198] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0199] Analyze the relationship between the code segments in the program of the project to be tested according to the detection tool after the detection configuration, and generate a first file directory corresponding to the program of the project to be tested;
[0200] Traverse the file path corresponding to the program of the project to be detected, and generate a second file directory corresponding to the program of the project to be detected;
[0201] According to the first file directory and the second file directory, a redundancy check is performed on the program of the project to be checked, and the check result is output.
[0202] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0203] Start the resource processing module to analyze the relationship between the code segments in the program of the project to be tested, and generate the resource reference relationship between the code segments;
[0204] Generate a first file directory according to the resource reference relationship.
[0205] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0206] If the preset configuration parameters include detection option parameters, and the detection option parameters are used to filter development reference items or to skip detection target directories, filtering the first file directory and the second file directory to obtain a processed first file directory and a processed second file directory;
[0207] According to the first file directory and the second file directory, redundancy detection is performed on the program of the project to be detected, and the detection results are output, including:
[0208] According to the processed first file directory and the processed second file directory, a redundancy check is performed on the program of the project to be checked, and a check result is output.
[0209] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0210] Compare the first file directory and the second file directory to determine the difference file directories;
[0211] Determine the redundant code segments in the program of the project to be tested based on the difference file directory and obtain the test results.
[0212] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0213] Displaying a configuration page on the startup interface of the detection tool; the configuration page includes a parameter editing window or a command window;
[0214] In response to a first input operation on the parameter editing window, a preset configuration parameter corresponding to the first input operation is obtained; or, in response to a second input operation on the command window, a preset configuration parameter corresponding to the second input operation is obtained.
[0215] The above embodiment provides a computer program product, whose implementation principle and technical effect are similar to those of the above method embodiment, and will not be repeated here.
[0216] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0217] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can 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 random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0218] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, 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, they should be considered to be within the scope of this specification.
[0219] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A redundancy detection method, characterized in that: The method comprises: Performing detection configuration on the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, the detection environment, the detection method, the detection result output format, and the detection result output path; The detection tool after detection configuration performs redundant detection on the program of the item to be detected and outputs the detection results.
2. The method according to claim 1, characterized in that The detection tool after the detection configuration performs redundant detection on the program of the detection item to be detected and outputs the detection result, including: Analyze the relationship between the code segments in the program to be detected according to the detection tool after the detection configuration, and generate a first file directory corresponding to the program to be detected; Traversing the file path corresponding to the program of the project to be detected, and generating a second file directory corresponding to the program of the project to be detected; According to the first file directory and the second file directory, redundancy detection is performed on the program of the project to be detected, and the detection result is output.
3. The method according to claim 2, characterized in that The detection tool includes a resource processing module, which analyzes the relationship between the code segments in the program of the project to be detected and generates a first file directory corresponding to the program of the project to be detected, including: Starting the resource processing module to analyze the relationship between the code segments in the program to be detected, and generating resource reference relationships between the code segments; The first file directory is generated according to the resource reference relationship.
4. The method according to claim 2, characterized in that: The method further comprises: If the preset configuration parameters include the detection option parameters, and the detection option parameters are used to filter development reference items or to skip detection target directories, filtering the first file directory and the second file directory to obtain a processed first file directory and a processed second file directory; The method of performing redundancy detection on the program of the project to be detected according to the first file directory and the second file directory and outputting the detection result includes: According to the processed first file directory and the processed second file directory, redundancy detection is performed on the program of the project to be detected, and the detection result is output.
5. The method according to claim 2, characterized in that: The method of performing redundancy detection on the program of the project to be detected according to the first file directory and the second file directory and outputting the detection result includes: Compare the first file directory with the second file directory to determine different file directories; The redundant code segments in the program of the project to be detected are determined according to the difference file directory to obtain the detection result.
6. The method according to any one of claims 1 to 5, characterized in that: The step of configuring the detection tool according to the preset configuration parameters includes: Displaying a configuration page on the startup interface of the detection tool; the configuration page includes a parameter editing window or a command window; In response to a first input operation on the parameter editing window, a preset configuration parameter corresponding to the first input operation is obtained; or, in response to a second input operation on the command window, a preset configuration parameter corresponding to the second input operation is obtained.
7. A redundant detection device, characterized in that: The device comprises: A configuration module, used to configure the detection tool according to preset configuration parameters; the preset configuration parameters are used to configure at least one aspect of the detection version, detection environment, detection method, detection result output format, and detection result output path; The detection module is used to perform redundancy detection on the program of the detection project according to the detection tool after the detection configuration, and output the detection result.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Redundant file determination method, device and equipment
CN113467781A
Front-end engineering code cleaning method and device and storage medium
CN118642717A
Cited By
Redundant file deletion method and system, electronic equipment and storage medium
CN121349981A