Data detection method and device
By merging and comparing multiple code branch data, identifying variable data and method data, and performing effectiveness detection, the problem of inability to comprehensively detect code data in the prior art is solved, and the accuracy and efficiency of code detection are improved.
Patent Information
- Application Number
- CN202411774235.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-03-21
AI Technical Summary
The existing technology cannot conduct comprehensive inspection of code data during the code development process, resulting in difficult to guarantee code quality and data validity.
By merging multiple code branch data, the combined code data and the original code data are compared to determine the modified data, identify variable data and method data, and validity detection is performed using preset detection methods.
Improve the accuracy of code detection, ensure the accuracy of code data in code development scenarios, reduce the code error rate, and avoid errors or other abnormal problems caused by empty data.
Smart Images

Figure CN119668620A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for data detection. Background Art
[0002] With the rapid development of Internet technology, code plays a vital role as the basic data of Internet technology. In various scenarios, the development of code data is often difficult. Therefore, improving the accuracy and effectiveness of the code can effectively reduce the time consumed in the development process and improve the efficiency of code development. At present, in the process of code development, the detection of code content mainly relies on the self-inspection of developers, which cannot guarantee the quality of code and the effectiveness of data.
[0003] However, the existing technology for detecting codes only has verification based on the code writing format, lacks detection of the validity of code data, and cannot perform comprehensive detection of the code. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a method and device for data detection, which can improve the accuracy of code detection.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a data detection method is provided, comprising:
[0006] Merging the acquired multiple code branch data to obtain merged code data, and comparing the merged code data with the original code data corresponding to the merged code data to obtain modified data;
[0007] Identify variable data and corresponding method data in the modification data, where the variable data is a set of multiple variables defined in the code, and the corresponding method data is a set of methods for calling the variables;
[0008] Based on the preset detection method, the variable data and method data are tested for validity to obtain the test results.
[0009] Optionally, before merging the acquired multiple code branch data to obtain merged code data and comparing the merged code data with original code data corresponding to the merged code data to obtain the modified data, the method further includes:
[0010] Identify initial variable data and corresponding initial method data in each code branch data;
[0011] The initial variable data and the corresponding initial method data are tested for validity based on a preset test method.
[0012] Optionally, the variable data and the method data are tested for validity based on a preset test method to obtain a test result, including:
[0013] Perform a bottom-up detection on the variable data based on a first preset detection method to obtain a first detection result;
[0014] Performing validity detection on the variable data based on a second preset detection method to obtain a second detection result;
[0015] Performing validity detection on the method data based on a third preset detection method to obtain a third detection result;
[0016] A detection result is generated based on the first detection result, the second detection result, and the third detection result.
[0017] Optionally, identifying variable data and corresponding method data in the modification data includes:
[0018] Based on a preset variable statement, variable data in the modified data is identified, the preset variable statement being a declaration statement containing a variable;
[0019] Corresponding method data is identified based on the variable data.
[0020] Optionally, performing a bottom-up detection on the variable data based on a first preset detection method to obtain a first detection result includes:
[0021] Determine the context statement corresponding to the variable data;
[0022] Based on the context statement, it is detected whether a preset catch-all statement is included to obtain a first detection result.
[0023] Optionally, performing validity detection on the variable data based on a second preset detection method to obtain a second detection result includes:
[0024] Determine the statement corresponding to the variable data;
[0025] Whether the statement corresponding to the variable data is a preset valid statement is detected to obtain a second detection result.
[0026] Optionally, performing validity detection on the method data based on a third preset detection method to obtain a third detection result includes:
[0027] Determine the target calling method corresponding to the variable data based on the correspondence between the variable data and the preset variable type and the calling method;
[0028] The method data is tested for validity based on the target calling method to obtain a third test result.
[0029] According to another aspect of an embodiment of the present invention, there is provided a data detection device, comprising:
[0030] A comparison module is used to merge the acquired multiple code branch data to obtain merged code data, and compare it with the original code data corresponding to the merged code data to obtain modified data;
[0031] An identification module, used to identify variable data and corresponding method data in the modification data, wherein the variable data is a set of multiple variables defined in the code, and the corresponding method data is a set of methods for calling the variables;
[0032] The detection module is used to perform validity detection on variable data and method data based on a preset detection method to obtain a detection result.
[0033] According to another aspect of an embodiment of the present invention, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the data detection method provided by an embodiment of the present invention.
[0034] According to another aspect of an embodiment of the present invention, a computer readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the data detection method provided by an embodiment of the present invention is implemented.
[0035] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the data detection method provided by an embodiment of the present invention is implemented.
[0036] An embodiment of the above invention has the following advantages or beneficial effects: it can merge multiple code branch data in a scenario where multiple people collaborate to modify the code, and determine the modified data by comparing it with the corresponding original code data, identify variable data and method data based on the modified data, and use a preset detection method to perform validity detection, thereby ensuring the accuracy of code data in the code development scenario, facilitating comprehensive detection of code data, and reducing code error rates.
[0037] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0039] Figure 1 is a schematic diagram of main steps of a method for data detection according to an embodiment of the present invention;
[0040] Figure 2 This is a flowchart of code data validity detection in a single branch scenario;
[0041] Figure 3 It is a flowchart of code data validity detection in multiple branch scenarios;
[0042] Figure 4 is a schematic diagram of main modules of a data detection device according to an embodiment of the present invention;
[0043] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0044] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0045] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0046] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution disclosed in the present invention are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.
[0047] It should be noted that in the technical solution of the present invention, the collection, use, storage, sharing and transfer of user personal information involved are in compliance with the provisions of relevant laws and regulations, and it is necessary to inform the user and obtain the user's consent or authorization. When applicable, the user's personal information is de-identified and / or anonymized and / or encrypted.
[0048] Figure 1 is a schematic diagram of the main process of the data detection method according to an embodiment of the present invention, such as Figure 1 As shown, including:
[0049] Step S101 , merging the acquired multiple code branch data to obtain merged code data, and comparing the merged code data with the original code data corresponding to the merged code data to obtain modified data.
[0050] The multiple code branch data obtained based on the same business are merged to obtain merged code data. The same business may be a code development task for the same page, and the multiple code branch data obtained may be multiple data obtained after multiple people collaborate to modify the development code data of the page. For the merged code data, the original code data corresponding to the multiple code branch data is obtained, that is, the unmodified code data based on the same business in the code library, and the merged code data is compared with the original code data to obtain the modified data in the merged code data. In actual applications, the multiple code branch data are data deployed in pre-release branches or online branches.
[0051] Optionally, after multiple code branch data are submitted, a code detection process will be triggered, and the data will be merged first. The detection process is based on the plug-in deployed on the server.
[0052] Step S102, identifying variable data and corresponding method data in the modification data, where the variable data is a set of multiple variables defined in the code, and the corresponding method data is a set of methods for calling the variables.
[0053] For the obtained modification data, the variable data and the method data corresponding to the variable data are identified. Specifically, the variable data in the modification data is identified according to a preset identification method, and the corresponding calling method data is identified based on the identified variable data. The identification of the variable data can be completed, for example, according to a preset identification statement; the variable data is a collection of multiple variables defined in the code, specifically, variables declared by variable declaration statements such as let, const, var, etc., and the corresponding method data is a collection of methods for calling the variables.
[0054] Step S103, performing validity detection on the variable data and method data based on a preset detection method to obtain a detection result.
[0055] According to the preset data validity detection method, the identified variable data and the corresponding method data are tested for validity to obtain the test results. The validity detection includes code data specification detection, whether there is non-empty detection logic, whether there is a fallback logic, etc.
[0056] According to the data detection method provided in the embodiment of the present invention, in the scenario where multiple people collaborate to modify the code, it is possible to merge multiple code branch data, determine the modified data by comparing with the corresponding original code data, identify variable data and method data based on the modified data, and use a preset detection method to perform validity detection, thereby ensuring the accuracy of code data in the code development scenario, facilitating comprehensive detection of code data, and reducing code error rates.
[0057] Optionally, before merging the acquired multiple code branch data to obtain merged code data and comparing it with the original code data corresponding to the merged code data to obtain the modified data, the method also includes: identifying the initial variable data and the corresponding initial method data in each code branch data; and performing a validity check on the initial variable data and the corresponding initial method data based on a preset detection method. Before merging the multiple code branch data, each code branch also needs to be tested for validity. Specifically, the initial variable data in the code data of each branch and the initial method data corresponding to the initial variable data are identified, and the validity check of the variable data and the method data is performed based on the identified data. Among them, the validity check of the data of a single branch can adopt the same detection method as that of multiple code branch data.
[0058] Optionally, the variable data and method data are tested for validity based on a preset test method to obtain a test result, including: performing a bottom-up test on the variable data based on a first preset test method to obtain a first test result; performing a validity test on the variable data based on a second preset test method to obtain a second test result; performing a validity test on the method data based on a third preset test method to obtain a third test result; and generating a test result based on the first test result, the second test result, and the third test result. When performing a validity test on data, three tests can be performed: a bottom-up test, a variable data validity test, and a method data validity test, and the results of the three tests can be combined to generate a final test result.
[0059] Optionally, the final detection result may be generated in combination with detection results in other aspects, for example, detection of code writing specifications.
[0060] Optionally, identifying the variable data and the corresponding method data in the modified data includes: identifying the variable data in the modified data based on a preset variable statement, the preset variable statement is a declaration statement containing a variable; identifying the corresponding method data based on the variable data. It should be known that the use of variable data needs to be declared in advance before the variable data can be used later, so it can be identified by a preset variable declaration statement. If the declaration statement in the modified data is identified as a preset variable declaration statement, the data declared by the statement is the identified variable data. For example, the detection of the front-end es6+vue (a front-end JavaScript framework of the JavaScript language standard) can include the data variable in vue (a front-end JavaScript framework) (traversing the variables under vm.$data (an instance attribute)), and the temporary variables declared using let, const, and var (three keywords used to declare variables). After identifying the variable data, the method data can be identified by identifying the method that calls the variable data.
[0061] When performing identification, it is also necessary to detect whether there is an error message about data anomalies. Specifically, determine whether there is an [.] operator in the modified data, and whether there are const and let deconstruction assignment operations. When there is an operator in the code that modifies the data, verify whether there is non-empty detection logic in the code. For the [.] operator, is there a [?.] to perform non-empty detection. For example, since a key of an empty object is called, the method for data validity verification in this scenario is to perform non-empty detection through [?.]. When verifying whether there is non-empty detection logic in the code, it can be determined whether there is a direct call to the object, such as a.key. For such calls, if the a returned by the background is undefined, a data anomaly error will occur.
[0062] Optionally, a first detection result is obtained by performing a bottom-up detection on the variable data based on a first preset detection method, including: determining the context statement corresponding to the variable data; based on the context statement, detecting whether a preset bottom-up statement is included to obtain the first detection result. The detection of the variable data includes a bottom-up detection, and the bottom-up logic can effectively avoid the occurrence of abnormal values such as undefined (undefined value) or null (invalid value) when the code data is running. Specifically, the context statement where the variable data is located is identified, and whether the context statement contains a bottom-up statement for the variable data is identified to obtain the corresponding detection result. The specific detection process is illustrated by an example: for deconstructed variables such as const and let, it is detected whether the context statement has a data validity bottom-up for the deconstructed variables. Example of a statement with data validity check problem: const {a} = b; Example of a statement that passes data validity check: const {a} = b || {}. The [||] operator is used to provide a default value to implement a bottom-up strategy to prevent b from being an abnormal value such as undefined or null.
[0063] Optionally, the variable data is tested for validity based on a second preset detection method to obtain a second test result, including: determining the statement corresponding to the variable data; detecting whether the statement corresponding to the variable data is a preset valid statement, and obtaining a second test result. The variable data is tested for validity, including testing the validity of the array data, and determining whether the statement corresponding to the array data is a preset valid statement. Example: Determine whether the statement corresponding to the array in the modified data may cause data anomalies. The judgment method is: 1) Determine whether there is a direct reference to the [n] subscript. An example of a statement with a data validity check problem is: arr[0]; an example of a statement that passes the data validity check is: arr?.[0] or arr && arr.length &&arr[0].
[0064] 2) Determine whether to use special array methods directly, such as taking the value of length. An example of a statement that fails data validity verification is: arr.length; an example of a statement that passes data validity verification is: arr?.length or arr && arr.length.
[0065] Optionally, the method data is tested for validity based on a third preset detection method to obtain a third test result, including: determining the target calling method corresponding to the variable data based on the correspondence between the variable data and the preset variable type and the calling method; and testing the method data for validity based on the target calling method to obtain the third test result. The method data corresponding to the variable data, that is, the calling method of the variable data, is judged to determine whether it is a valid method. Specifically, a type judgment is performed: the prototype (implementing an object-oriented mechanism) or Object.getPrototypeOf (a method for obtaining the prototype object of a specified object) method is used to judge and verify whether the calling method of the variable exists. For example: const a ={}; a is an Object; type judgment a instanceof Object ===true. Example of statement passing the method validity check: a.toString(); because the toString method exists in Object.getPrototypeOf(a). Example of statement failing the method validity check: a.slice(); because the slice method does not exist in Object.getPrototypeOf(a).
[0066] Optionally, the detection tool in the plug-in detects the possible data anomaly scenarios described above, and assigns obj1 to abnormal values such as undefined, null, '', etc. by mocking the data for testing. If an abnormality exists, it will be marked in red in the console, and the line and file where the code is located will be marked.
[0067] According to the data detection method provided by the embodiment of the present invention, in the scenario where multiple people collaborate to modify the code, it is possible to merge multiple code branch data, identify the modified data by comparison with the corresponding original code data, identify the variable data and method data in the modified data, and use a preset detection method to perform validity detection on the two data, thereby ensuring the accuracy of the code data in the code development scenario, avoiding the omission of code detection problems, and facilitating comprehensive detection of code data, reducing the code error rate, and avoiding errors or other abnormal problems caused by empty data when the page corresponding to the code data is generated. For the code data that affect each other in each branch, visual detection result data is formed through detection.
[0068] like Figure 2The figure shows the flow chart of code data validity detection in a single branch scenario. After submitting the code, the plug-in is triggered to run for verification, detect the front-end variables, that is, the variable data, and detect the variable calling methods, the number of which is n. Perform validity checks on each variable, including determining whether there is a fallback strategy and whether an error is caused. If an error is reported, it means that there is an unfallback scenario, the number of exceptions +1, and the unfallback code segment is recorded. If there is no error, determine whether the detected variable is the last variable. If not, continue to detect the next variable; if so, generate a test report and the test ends.
[0069] like Figure 3 The figure shows the flow chart of code data validity detection in multiple branch scenarios. After submitting the code, the plug-in is triggered to run for verification, code data comparison is performed, variable detection is performed on the modified data, and the method of variable calling is detected, the number is n. The validity test is performed on each variable, including judging whether there is a fallback strategy and whether it causes an error. If an error is reported, it means that there is an unfallback scenario, the number of exceptions +1, and the unfallback code segment is recorded. If there is no error, it is judged whether the detected variable is the last variable. If not, continue to detect the next variable. If so, a test report is generated and the test ends.
[0070] Figure 4 is a schematic diagram of a data detection device 400 provided in an embodiment of the present invention, such as Figure 4 As shown, including:
[0071] The comparison module 401 is used to merge the acquired multiple code branch data to obtain merged code data, and compare it with the original code data corresponding to the merged code data to obtain modified data;
[0072] Identification module 402, used to identify variable data and corresponding method data in the modification data, the variable data is a set of multiple variables defined in the code, and the corresponding method data is a set of methods for calling the variables;
[0073] The detection module 403 is used to perform validity detection on the variable data and the method data based on a preset detection method to obtain a detection result.
[0074] The data detection device provided in accordance with the embodiment of the present invention can merge multiple code branch data in a scenario where multiple people collaborate to modify the code, determine the modified data by comparing it with the corresponding original code data, identify variable data and method data based on the modified data, and use a preset detection method to perform validity detection, thereby ensuring the accuracy of code data in code development scenarios, facilitating comprehensive detection of code data, and reducing code error rates.
[0075] Optionally, the device also includes: an identification module 402, which is also used to identify the initial variable data and the corresponding initial method data in each code branch data; a detection module 403, which is also used to perform validity detection on the initial variable data and the corresponding initial method data based on a preset detection method.
[0076] Optionally, the detection module 403 is also used to: perform a bottom-up detection on the variable data based on a first preset detection method to obtain a first detection result; perform a validity test on the variable data based on a second preset detection method to obtain a second detection result; perform a validity test on the method data based on a third preset detection method to obtain a third detection result; and generate a detection result based on the first detection result, the second detection result and the third detection result.
[0077] Optionally, the identification module 402 is further used to: identify variable data in the modification data based on a preset variable statement, where the preset variable statement is a declaration statement containing a variable; and identify corresponding method data based on the variable data.
[0078] Optionally, the detection module 403 is further used to: determine the context statement corresponding to the variable data; based on the context statement, detect whether a preset fallback statement is included to obtain a first detection result.
[0079] Optionally, the detection module 403 is further used to: determine the statement corresponding to the variable data; and detect whether the statement corresponding to the variable data is a preset valid statement to obtain a second detection result.
[0080] Optionally, the detection module 403 is further used to: determine the target calling method corresponding to the variable data based on the correspondence between the variable data and the preset variable type and the calling method; and perform validity detection on the method data based on the target calling method to obtain a third detection result.
[0081] According to the data detection device provided by the embodiment of the present invention, in the scenario where multiple people collaborate to modify the code, it is possible to merge multiple code branch data, identify the modified data by comparison with the corresponding original code data, identify the variable data and method data in the modified data, and use a preset detection method to perform validity detection on the two data, thereby ensuring the accuracy of the code data in the code development scenario, avoiding the omission of code detection problems, facilitating comprehensive detection of code data, reducing the code error rate, and avoiding errors or other abnormal problems caused by empty data when the page corresponding to the code data is generated. For the code data that affect each other in each branch, visual detection result data is formed through detection.
[0082] Figure 5 An exemplary system architecture 500 is shown to which the method or apparatus for data detection according to the embodiment of the present invention may be applied.
[0083] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0084] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0085] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0086] The server 505 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 501, 502, and 503. The backend management server may analyze and process the received detection request and other data, and feed back the processing results (such as the detection results - only an example) to the terminal device.
[0087] It should be noted that the data detection method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the data detection device is generally set in the server 505 .
[0088] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0089] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 6 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0090] like Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0091] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0092] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0093] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0094] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0095] The units or modules involved in the embodiments of the present invention may be implemented in software or hardware. The units or modules described may also be arranged in a processor. For example, they may be described as: a processor includes a comparison module, an identification module, and a detection module. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves. For example, the identification module may also be described as a "module for identifying variable data and corresponding method data in modification data."
[0096] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0097] Merging the acquired multiple code branch data to obtain merged code data, and comparing the merged code data with the original code data corresponding to the merged code data to obtain modified data;
[0098] Identify variable data and corresponding method data in the modification data, where the variable data is a set of multiple variables defined in the code, and the corresponding method data is a set of methods for calling the variables;
[0099] Based on the preset detection method, the variable data and method data are tested for validity to obtain the test results.
[0100] According to the technical solution of the embodiments of the present invention, in a scenario where multiple people collaborate to modify the code, multiple code branch data can be merged, and the modified data can be determined by comparison with the corresponding original code data, and variable data and method data can be obtained by identification based on the modified data, and a preset detection method can be used to perform validity detection, thereby ensuring the accuracy of code data in code development scenarios, facilitating comprehensive detection of code data, and reducing code error rates.
[0101] As another aspect, the present invention further provides a computer program product, including a computer program, which implements the method of the embodiment of the present invention when the computer program is executed by a processor.
[0102] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for data detection, characterized in that: include: Merging the acquired multiple code branch data to obtain merged code data, and comparing the merged code data with the original code data corresponding to the merged code data to obtain modified data; Identify variable data and corresponding method data in the modification data, wherein the variable data is a set of multiple variables defined in the code, and the corresponding method data is a set of methods for calling the variables; The variable data and the method data are tested for validity based on a preset testing method to obtain a testing result.
2. The method according to claim 1, characterized in that Before merging the acquired multiple code branch data to obtain merged code data and comparing the merged code data with the original code data corresponding to the merged code data to obtain the modified data, the method further includes: Identifying initial variable data and corresponding initial method data in each code branch data; The initial variable data and the corresponding initial method data are tested for validity based on a preset testing method.
3. The method according to claim 1, characterized in that The performing validity detection on the variable data and the method data based on a preset detection method to obtain a detection result includes: Performing a bottom-up detection on the variable data based on a first preset detection method to obtain a first detection result; Performing validity detection on the variable data based on a second preset detection method to obtain a second detection result; Performing a validity test on the method data based on a third preset test method to obtain a third test result; A detection result is generated based on the first detection result, the second detection result, and the third detection result.
4. The method according to claim 1, characterized in that: The identifying the variable data and the corresponding method data in the modification data includes: Based on a preset variable statement, identifying variable data in the modification data, the preset variable statement being a declaration statement containing a variable; Corresponding method data is identified based on the variable data.
5. The method according to claim 2, characterized in that: The performing a bottom-up detection on the variable data based on the first preset detection method to obtain a first detection result includes: Determine a context statement corresponding to the variable data; Based on the context statement, it is detected whether a preset catch-all statement is included to obtain a first detection result.
6. The method according to any one of claims 1 to 3, characterized in that: The performing validity detection on the variable data based on the second preset detection method to obtain a second detection result includes: Determine the statement corresponding to the variable data; Detect whether the statement corresponding to the variable data is a preset valid statement to obtain a second detection result.
7. The method according to any one of claims 1 to 3, characterized in that: The performing validity detection on the method data based on the third preset detection method to obtain a third detection result includes: Determine the target calling method corresponding to the variable data based on the correspondence between the variable data and the preset variable type and the calling method; The method data is tested for validity based on the target calling method to obtain a third test result.
8. A data detection device, characterized in that: include: A comparison module, used to merge the acquired multiple code branch data to obtain merged code data, and compare it with the original code data corresponding to the merged code data to obtain modified data; An identification module, used to identify variable data and corresponding method data in the modification data, wherein the variable data is a set of multiple variables defined in the code, and the corresponding method data is a set of methods for calling the variables; The detection module is used to perform validity detection on the variable data and the method data based on a preset detection method to obtain a detection result.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.