Methods and devices for detecting code changes
By reading annotations from modified code and analyzing method call chains, the rationality of the modified code can be determined, thus resolving the adverse effects caused by developers making unauthorized changes to the code and improving the efficiency and accuracy of code review.
Patent Information
- Application Number
- CN202211145640.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-20
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2042-09-20
AI Technical Summary
In existing technologies, when developers modify code without authorization, it is impossible to effectively ensure that the changes do not affect the functionality, leading to increased production problems. Relying on manual verification is risky and the review process is inefficient.
By reading annotations from the modified code, analyzing the classes and method call relationships involved in the code, determining whether the modified code is in the application's method call chain, and outputting the detection results to control adverse effects and improve review efficiency.
It effectively controls developers' arbitrary code modifications, improves the efficiency of code modification review, ensures that code modifications are relevant to requirements, and reduces adverse effects.
Smart Images

Figure CN115481029B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of code detection technology, and in particular to a method and apparatus for detecting code modifications. Background Technology
[0002] In software development, it's common for developers to modify code without authorization. These modifications may contain errors or negatively impact other modules. Currently, code changes are controlled through code reviews, relying on individual responsibility. Manual verification still carries risks, making it impossible to guarantee that changes won't affect functionality and increasing the risk of production issues upon deployment. Summary of the Invention
[0003] This invention provides a method and device for detecting code modifications, which greatly controls the adverse effects of developers arbitrarily modifying code on the entire program and improves the efficiency of code review.
[0004] In a first aspect, embodiments of the present invention provide a method for detecting code modifications, the method comprising:
[0005] Read annotations from the modified code;
[0006] The classes involved in the modified code were analyzed from the annotations;
[0007] By analyzing the method call relationships of the classes in the application corresponding to the modified code, the method call chain of the classes is obtained, and the method call chain includes the methods called by the classes;
[0008] Read the methods called by the class from the modified code;
[0009] The determination result is obtained by determining whether the method called by the class is included in the method call chain;
[0010] The corresponding detection result is obtained based on the judgment result, which includes either detection failure or detection success.
[0011] Secondly, embodiments of the present invention provide a code detection device, the code detection device comprising:
[0012] The get unit is used to read annotations from the modified code;
[0013] The first analysis unit is used to analyze the classes involved in the modified code from the annotations;
[0014] The second analysis unit is used to analyze the method call relationship of the class in the corresponding application to obtain the method call chain of the class, and the call chain includes the methods called by the class;
[0015] A reading unit is used to read the methods called by the class from the modified code;
[0016] The judgment unit is used to determine whether the called method is included in the method call chain and obtain a judgment result;
[0017] The detection unit is used to obtain corresponding detection results based on the judgment result, including detection failure and detection success.
[0018] Thirdly, embodiments of the present invention provide a computer device, the computer device comprising:
[0019] Memory, used to store computer programs;
[0020] A processor for executing the computer program to implement the code modification detection method according to any one of claims 1 to 6.
[0021] Fourthly, embodiments of the present invention provide a software development management platform, the software development management platform comprising:
[0022] The requirement task management device is used to create corresponding requirement tasks in response to user operations;
[0023] Application management device, used for users to upload application code and related information; and
[0024] The code detection device is the code detection device provided in the second aspect above.
[0025] The aforementioned code modification detection method and device obtain the modified code submitted by developers through the application management device. The code detection device then compiles and analyzes the modified code to obtain annotations. Based on these annotations, the classes within the modified code are identified. Next, all methods called by each class are traversed. Finally, it is determined whether the method calls in the modified code are within the method call chain of the corresponding class in the application. If they are, the code can be modified; otherwise, a prompt dialog box is displayed to inform the developer. This solution significantly controls the adverse effects of developers arbitrarily modifying code on the entire program and improves the efficiency of code modification review. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0027] Figure 1 A flowchart of a code modification detection method provided in the first embodiment of the present invention.
[0028] Figure 2 This is a partial flowchart of the code modification detection method provided in the second embodiment of the present invention.
[0029] Figure 3 This is a partial flowchart of the code modification detection method provided in the third embodiment of the present invention.
[0030] Figure 4 This is a schematic diagram of the code detection device provided in an embodiment of the present invention.
[0031] Figure 5 A schematic diagram of the structure of the application matching unit further included in the code detection device provided in the embodiments of the present invention.
[0032] Figure 6 This is a schematic diagram of the software development management platform structure provided in an embodiment of the present invention.
[0033] Figure 7 A schematic diagram of the computer device structure for the code modification detection method provided in this embodiment of the invention.
[0034] Figure 8 This is a schematic diagram of a prompt dialog box provided in an embodiment of the present invention.
[0035] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention.
[0037] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar planned objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data are interchangeable where appropriate; in other words, the described embodiments are implemented according to a sequence other than that illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, may also include other content; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0038] It should be noted that the descriptions involving "first," "second," etc., in this invention are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined with "first" or "second" may explicitly or implicitly include one or more of that feature. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by this invention.
[0039] The method for detecting code changes is executed by the software development management platform, such as... Figure 6 As shown, the software development management platform 20 includes a requirement task management device 201, an application management device 202, and a code inspection device 203. The requirement task management device 201 is used to create corresponding requirement tasks in response to user operations. The application management device 202 is used to process the code and related information of applications uploaded by users. The code inspection device 203 is used to receive and analyze the code sent by the requirement task management device 201 and the application management device 202, and display the inspection results. The code modification detection method provided in the first embodiment specifically includes the following steps:
[0040] Step S101: Read the annotations from the modified code.
[0041] In this embodiment, the annotation is a special marker in the code, indicated by @. It is used to replace configuration files. With annotations, developers can tell the classes in the code how to run. Meta-annotations are used to define (decorate) custom annotations and define the required functionality. Annotations can be placed on packages, classes, properties, method parameters, and local variables, and multiple annotations can be placed in the same place. This saves developers a lot of repetitive and complex code.
[0042] Specifically, the application management device 202 receives modified code uploaded by developers or maintenance personnel, and the code detection device 203 compiles and analyzes the modified code to obtain annotations for the modified code.
[0043] For example, if a "face recognition" login option needs to be added to the homepage of the China Merchants Bank APP, the developers will edit the relevant code for the "face recognition" login option and publish it to the software development management platform 20 through the application management device 202. Since the annotation is marked with @, the code detection device 203 will detect the new code and then traverse all the code with the @ symbol and obtain all the code with the @ symbol, which is the code annotation.
[0044] Step S102: Analyze the classes involved in the modified code from the annotations.
[0045] Specifically, annotations are used to annotate methods and classes. Based on the code annotations obtained from step S101, the corresponding classes for those annotations can be obtained. In this embodiment, the code detection device 203 will traverse all annotations of the modified code to obtain all class names of the modified code.
[0046] For example, according to step S101, the code detection device 203 analyzes the homepage code of the China Merchants Bank APP, which contains the @TestAnnotation annotation, and a class Test is defined on the @TestAnnotation annotation. Therefore, when the @TestAnnotation annotation is obtained, the class name Test can be obtained.
[0047] Step S103: Analyze the method call relationship of the class in the application corresponding to the modified code to obtain the method call chain of the class.
[0048] In this embodiment, the modified code corresponds to an application and is stored in an application database. The code contains multiple annotations, multiple class names, and multiple method names. One annotation matches one class name, and one class name matches multiple method names. The code detection device 203 will traverse all method names under the class and connect the corresponding annotations, class names, and method names. Finally, one annotation corresponds to one class, and multiple methods corresponding to one class are combined to form a method call chain of the class.
[0049] For example, code inspection device 203 acquires an annotation @OverrIDe, locates the corresponding class name BuySubmitService through the annotation @OverrIDe, and traverses the methods called by class BuySubmitService, finding the chkParam() method and the getTransJson() method in the TransDTO class. Finally, code inspection device 203 combines the annotation @Conditional, class name BuySubmitService, chkParam() method, and getTransJson() method into a method call chain for the class. In other words, this step determines the method call chain of the class in the corresponding application's source code by identifying the annotated classes in the modified code. Understandably, if code under a class is modified, the methods called by that class are also modified. Therefore, when the methods called by this class are modified, it indicates that the modification made to the required task is related to the required task, rather than being an incidental modification; that is, the modified code is not incidental code. Conversely, if the modification is not an incidental modification, then the modified code is incidental code. Included code can negatively impact other code.
[0050] Step S104: Read the methods called by the class from the modified code.
[0051] Understandably, for the modified code, the method called by the class to be obtained is the same as in step S103. The modified code is compiled by the code detection device 203 and the code annotation is obtained. Then, the class name is obtained according to the annotation, and the method name is obtained by traversing the methods according to the class name.
[0052] Step S105: Determine whether the method called by the class is included in the method call chain to obtain the determination result. Understandably, if the method called by the class is not included in the method call chain, it indicates that the modified code is embedded code; if the method called by the class is included in the method call chain, it indicates that the modified code is a modification made according to requirements.
[0053] In this embodiment, based on steps S103 and S104, the method call chain of the class in the application corresponding to the modified code and the method called by the class of the modified code are obtained, and it is determined whether the method called by the class of the modified code is in the method call chain of the class in the application.
[0054] For example, if the code detection device obtains that the methods called by the class TransDTO in the method call chain of a class in the application are chkParam() and getTransJson(), and the application management device 202 receives the modified code, it sends the modified code to the code detection device 203. The code detection device 203 compiles and analyzes the modified code and finds that there is a class with the same name TransDTO, but the modified code finds that the method called by the class TransDTO is getMonth(). Therefore, it is determined that the method called by the modified code is not in the method call chain of the class in the application. The code detection device 203 will traverse the methods called by the TransDTO class in turn until the last method is reached. This ensures that no method is missed when determining whether the method called by the modified code is in the method call chain of the class in the application.
[0055] Step S106: Obtain the corresponding detection result based on the judgment result, wherein the detection result includes either detection failure or detection success.
[0056] Specifically, according to the matching result obtained in step S105, if one of the methods called by the class in the modified code belongs to the method call chain of the class in the application, the detection result is successful and the detection success result is output. If one of the methods called by the class in the modified code does not belong to the method call chain of the class in the application, the detection result is determined to be a failure and the detection failure result is output.
[0057] Please refer to Figure 8 In some feasible embodiments, if the detection result is a failure, it can be determined that the modified code is an implicit modification. In this case, the code detection device 203 can pop up a prompt dialog box to inform the developer that the modification has failed. If the detection result is a success, it can be determined that the modified code is a requirement modification. In this case, the code detection device can pop up a prompt dialog box to inform the developer that the modification is successful and whether the code needs to be updated. When the developer selects the "OK" option, the software development management platform 20 automatically updates the code to complete the requirement modification for software development.
[0058] As described above, the application management device 202 obtains the modified code submitted by the developers, and the code inspection device 203 compiles and analyzes the modified code to obtain annotations. Based on the annotations, the class in the modified code is located, and then all methods called by the class are traversed. Finally, it is determined whether the method calls in the modified code are in the method call chain of the class in the corresponding application. If they are, the code can be modified; otherwise, a prompt dialog box notifies the developers. This solution greatly controls the adverse effects of developers arbitrarily modifying code on the entire program and improves the efficiency of code modification review.
[0059] Please refer to Figure 2 This is a partial flowchart of the code modification detection method provided in the second embodiment of the present invention. The code modification detection method provided in the second embodiment differs from the code modification detection method provided in the first embodiment in that, before the step of reading annotations from the modified code, the code modification detection method provided in the second embodiment further includes the following steps.
[0060] Step S201: Obtain the requirement task, wherein the requirement task includes the application ID corresponding to the requirement.
[0061] In this embodiment, requirement tasks are obtained through the requirement task management device 201. The requirement task refers to the function that needs to be added, which is uploaded by the developers to the requirement database. Each requirement task corresponds to an application, and each application contains a unique application ID.
[0062] For example, the China Merchants Bank APP has a requirement task that "customers can make an appointment to purchase funds on a working day within the next 30 days". This requirement task needs to be added to the homepage of the China Merchants Bank APP as a financial management option. After the code detection device 203 obtains this requirement task from the requirement task management device 201, it analyzes the application corresponding to this requirement task and finds that the application corresponding to the requirement task is China Merchants Bank, thereby knowing the ID of the China Merchants Bank APP. Suppose the ID of the China Merchants Bank APP is 123.
[0063] Step S202: Determine whether the application ID of the modified code exists in the application ID of the requirement task.
[0064] In this embodiment, the modified code comes from the corresponding application, and the requirement task also comes from the corresponding application. By obtaining the application ID corresponding to the modified code and comparing it with the application ID corresponding to the requirement task, it is determined whether the two applications are the same application. That is to say, the modified code and the requirement code must refer to the same application.
[0065] For example, according to step S201, the requirement task management device 201 obtains the requirement task of China Merchants Bank APP, and the code detection device 203 analyzes and obtains the ID of China Merchants Bank APP as 123. Then, the code detection device 203 compiles the modified code and analyzes it to obtain the ID of the modified code as 456. Since the two IDs do not match, it is determined that the application ID of the modified code does not exist in the application ID of the requirement task.
[0066] Step S203: When the application ID of the modified code exists in the application ID of the requirement task, execute the reading of annotations from the modified code.
[0067] Specifically, the application ID of the modified code obtained in step S202 is compared with the corresponding application ID in the requirement task. If the application ID of the modified code is consistent with the application ID in the requirement task, the code detection device 203 reads the annotations in the modified code.
[0068] Step S204: If the application ID of the modified code does not exist in the required task, output a detection result indicating detection failure and prompt manual code detection.
[0069] According to step S203, if the application ID of the modified code does not match the application ID of the obtained task, a detection result indicating failure is output. In some feasible embodiments, a prompt dialog box can pop up to indicate "This code modification failed, and the code update cannot be performed."
[0070] In the above embodiments, by matching the application ID corresponding to the requirement task with the application ID corresponding to the modified code, it can be quickly determined whether the modified code is related to the requirement. In this way, it can quickly detect whether there is a problem with the modified code, which greatly saves detection time.
[0071] Please refer to Figure 3 This is a partial flowchart of the code modification detection method provided in the third embodiment of the present invention. The code modification detection method provided in the third embodiment differs from the code modification detection method provided in the second embodiment in that, before the step of reading annotations from the modified code, the code modification detection method provided in the third embodiment further includes the following step.
[0072] Step S301: Obtain the keywords of the required task.
[0073] Specifically, the keywords are the business descriptions of the requirement tasks, which are uploaded to the requirement database by developers. The code inspection device 203 obtains the requirement tasks and parses them to obtain the keywords of the requirement tasks.
[0074] For example, China Merchants Bank has a requirement that "customers can make an appointment to purchase funds on a working day within the next 30 days". The code detection device 203 obtains this requirement and parses it to find that the keywords of this requirement are "fund" and "purchase".
[0075] Step S302: Obtain the keywords of the annotation.
[0076] Specifically, obtaining the keywords of the annotation refers to obtaining the keywords of the annotation that modified the code.
[0077] For example, if the code is modified to @Business(value="123", name="single fund purchase handling"), the code detection device 203 will obtain the keywords "single fund purchase handling" and "123".
[0078] Step S303: Match the keywords of the annotation with the keywords of the required task.
[0079] Specifically, by matching the keywords "fund" and "purchase" in the demand task obtained in step S301 with the keywords "single fund purchase handling" and "123" in the modified code obtained in step S302, it can be found that the keyword "fund" in the demand task matches the keyword "fund single purchase handling" in the annotation, and the keyword "purchase" in the demand task matches the keyword "purchase" in the annotation.
[0080] Step S304: When the keyword of the annotation matches the keyword of the requirement task, the class involved in the modified code is analyzed from the annotation.
[0081] Specifically, according to the matching result obtained in step S303, if the match is consistent, the code detection device 203 will traverse all classes in the modified code to obtain all class names in the modified code.
[0082] Step S305: When the keywords in the annotation do not match the keywords in the required task, output a detection result indicating detection failure.
[0083] Specifically, according to step S303, if the matching result is inconsistent, a dialog box indicating that the detection failed will pop up.
[0084] The above process involves obtaining the required task and the modified code through the application management device 202, and then obtaining the keywords of the modified code and the keywords of the required task through the code detection device 203 and matching the two keywords. If the match is consistent, the class name of the modified code is obtained. If the match is inconsistent, a detection failure prompt dialog box is popped up. The above process further determines whether the code modification is reasonable by matching the keywords of the two codes.
[0085] Please refer to Figure 4 The above is a schematic diagram of the structure of the code detection device provided in the embodiment of the present invention. The code detection device 10 includes an acquisition unit 101, a first analysis unit 102, a second analysis unit 103, a reading unit 104, a judgment unit 105, and a detection unit 106.
[0086] Get unit 101, used to read annotations from the modified code.
[0087] The first analysis unit 102 is used to analyze the classes involved in the modified code from the annotations.
[0088] The second analysis unit 103 is used to analyze the method call relationship of the class in the corresponding application to obtain the method call chain of the class.
[0089] The reading unit 104 is used to read the methods called by the class from the modified code.
[0090] The judgment unit 105 is used to determine whether the called method is included in the method call chain and obtain a judgment result.
[0091] The detection unit 106 is used to obtain the corresponding detection result based on the judgment result, and the detection result includes detection failure and detection success.
[0092] Please refer to Figure 5 The code detection device provided in this embodiment of the invention also includes an application matching unit, which includes a requirement collection unit 1071, a monitoring unit 1072, and an execution unit 1073.
[0093] The requirement collection unit 1071 is used to obtain requirement tasks, wherein the requirement task contains the application ID corresponding to the requirement.
[0094] The monitoring unit 1072 is used to determine whether the application ID of the modified code exists in the application ID of the requirement task.
[0095] The execution unit 1073 is configured to read annotations from the modified code when the application ID of the modified code exists in the application ID of the requirement task; and to output a detection result indicating detection failure when the application ID of the modified code exists in the application ID of the requirement task.
[0096] Please refer to Figure 6 This is a schematic diagram of the software development management platform structure provided in an embodiment of the present invention. The software development management platform 20 includes a requirement task management device 201, an application management device 202, and a code inspection device 203.
[0097] The requirement task management device 201 is used to create corresponding requirement tasks in response to user operations.
[0098] Application management device 202 is used for users to upload application code and related information.
[0099] The code inspection device 203 is used to analyze the requirements and modified code to obtain code information.
[0100] Please refer to Figure 7This is a schematic diagram of the computer device structure for the code modification detection method provided in the embodiments of the present invention. The computer device 200 includes a processor 201 and a memory 202. The processor 201 is used to execute an executable program to implement the code modification detection method provided in the above embodiments, and the memory 202 is used to store the computer executable program and the code modification detection method provided in the above embodiments.
[0101] In some embodiments, the processor 201 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip, used to run a computer-executable program stored in the memory 202. Specifically, the processor 201 executes the executable program to implement the code modification detection method provided in the above embodiments.
[0102] The memory 202 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 202 can be an internal storage unit of the computer device 200, such as the hard disk of the computer device 200. In other embodiments, the memory 202 can also be an external storage device of the computer device 200, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 200. Furthermore, the memory 202 can include both internal storage units and external storage devices of the computer device 200. The memory 202 can be used not only to store application software and various types of data installed on the computer device 200, such as code implementing methods for detecting code modifications, but also to temporarily store data that has been output or will be output.
[0103] Computer device 200 also includes bus 203. Bus 203 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0104] Furthermore, the computer device 200 may also include a display component 204. The display component 204 may be an LED display, a liquid crystal display, a touch-screen liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display component 204 may also be appropriately referred to as a display device or display unit, used to display information processed in the computer device 200 and to display a visual user interface.
[0105] Furthermore, the computer device 200 may also include a communication component 205. The communication component 205 may optionally include a wired communication component and / or a wireless communication component (such as a Wi-Fi communication component, a Bluetooth communication component, etc.), which is typically used to establish a communication connection between the computer device 200 and other computer devices.
[0106] Figure 7 Only a computer device 200 with some components and a method for detecting code modifications is shown; those skilled in the art will understand that... Figure 7 The structure shown does not constitute a limitation on the computer device 200 and may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0107] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0108] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to embodiments of the present invention is generated. The computer device may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a Solid State Disk (SSD)).
[0109] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0110] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or units through some interfaces, and may be electrical, mechanical, or other forms.
[0111] The unit described as a separate component may or may not be physically separate. The component shown as a unit may or may not be a physical unit; that is, it may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0112] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0113] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard disks, read-only storage media (ROM), random access storage media (RAM), magnetic disks, or optical disks.
[0114] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
[0115] The above-listed embodiments are merely preferred embodiments of the present invention and should not be construed as limiting the scope of the present invention. Therefore, any equivalent variations made in accordance with the claims of the present invention are still within the scope of the present invention.
Claims
1. A method of detecting a code change, characterized by, The code change detection method comprises: reading an annotation from the changed code; analyzing the class involved in the changed code from the annotation; analyzing the method call relationship of the class in the application corresponding to the changed code to obtain a method call chain of the class, the method call chain comprising the method called by the class; reading the method called by the class from the changed code; judging whether the method called by the class is contained in the method call chain to obtain a judgment result; obtaining a corresponding detection result according to the judgment result, the detection result comprising one of detection failure and detection success; wherein the changed code comprises an application ID, before reading the annotation from the changed code, the code change detection method further comprises: obtaining a requirement task, the requirement task containing an application ID corresponding to a requirement; judging whether the application ID of the changed code exists in the application ID in the requirement task; when the application ID of the changed code exists in the application ID in the requirement task, reading the annotation from the changed code; when the application ID of the changed code does not exist in the application ID in the requirement task, outputting a detection result indicating detection failure; wherein, before analyzing the class involved in the changed code from the annotation, the code change detection method further comprises: obtaining a keyword of the requirement task; obtaining a keyword of the annotation; matching the keyword of the annotation with the keyword of the requirement task; when the keyword of the annotation matches the keyword of the requirement task, analyzing the class involved in the changed code from the annotation; when the keyword of the annotation does not match the keyword of the requirement task, outputting a detection result indicating detection failure.
2. The method of detecting code modifications of claim 1, wherein, Further comprising: when the detection result is detection failure, outputting an artificial inspection prompt information.
3. The method of detecting code modifications of claim 1, wherein, The requirement task is uploaded in a requirement database by a developer.
4. The method of detecting code modifications of claim 1, wherein, The application corresponding to the changed code is stored in an application database.
5. A code detection apparatus characterized by comprising: The code detection device comprises: an obtaining unit configured to read an annotation from the changed code; a first analyzing unit configured to analyze the class involved in the changed code from the annotation; a second analyzing unit configured to analyze the method call relationship of the class in the application corresponding to the changed code to obtain a method call chain of the class, the method call chain comprising the method called by the class; a reading unit configured to read the method called by the class from the changed code; a judging unit configured to judge whether the called method is contained in the method call chain to obtain a judgment result; a detection unit configured to obtain a corresponding detection result according to the judgment result, the detection result comprising one of detection failure and detection success; wherein the code detection device further comprises an application matching unit, the application matching unit comprising: a requirement collecting unit configured to obtain a requirement task, the requirement task containing an application ID corresponding to a requirement; a monitoring unit configured to judge whether the application ID of the changed code exists in the application ID in the requirement task; and The execution unit is configured to read the annotation from the modified code when the application ID of the modified code exists in the application ID of the requirement task, and is further configured to output a detection result indicating a detection failure when the application ID of the modified code exists in the application ID of the requirement task. The code detection apparatus is further configured to: obtain a keyword of the requirement task; obtain a keyword of the annotation; match the keyword of the annotation with the keyword of the requirement task; when the keyword of the annotation matches the keyword of the requirement task, analyze a class involved in the modified code from the annotation; when the keyword of the annotation does not match the keyword of the requirement task, output a detection result indicating a detection failure.
6. A computer device, comprising: The code detection apparatus comprises: a memory configured to store a computer program; a processor configured to execute the computer program to implement the code modification detection method according to any one of claims 1 to 4.
7. A software development management platform, characterized by, The software development management platform comprises: a requirement task management apparatus configured to create a corresponding requirement task in response to a user operation; an application management apparatus configured to allow a user to upload a code and related information of an application; and the code detection apparatus is the code detection apparatus according to any one of claims 5. The code detection apparatus comprises: a memory configured to store a computer program; a processor configured to execute the computer program to implement the code modification detection method according to any one of claims 1 to 4. The software development management platform comprises: a requirement task management apparatus configured to create a corresponding requirement task in response to a user operation; an application management apparatus configured to allow a user to upload a code and related information of an application; and the code detection apparatus is the code detection apparatus according to any one of claims 5.
Citation Information
Patent Citations
Code change analysis method
CN112379888A
Service call chain implementation method based on self-research framework
CN112559212A