Evolutionary coupling relationship extraction method and system, computer device and storage medium
By acquiring and repairing reconstruction information from the history of method changes, and combining time thresholds and rule support to calculate evolutionary coupling relationships, the problem of not considering reconstruction information and time attributes in existing technologies is solved. This achieves more complete and accurate extraction of evolutionary coupling relationships, improving development quality and efficiency.
Patent Information
- Application Number
- CN202210843237.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-18
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2042-07-18
AI Technical Summary
Existing technologies do not consider reconstructed information and temporal attributes when extracting evolutionary coupling relationships, resulting in low accuracy and completeness.
By obtaining the revision history of the project to be extracted, the method change history and method refactoring information are obtained. The method change history is repaired, the refactoring operation is considered, and the method refactoring information is obtained using the abstract syntax tree and the refactoring detection tool PyRef. The evolutionary coupling relationship is calculated by combining the time threshold and rule support.
It improves the completeness and accuracy of evolutionary coupling relationship extraction, enabling it to be better used for defect detection and software modularity measurement, thereby improving development quality and efficiency.
Smart Images

Figure CN115113920B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of software evolution and refactoring, and relates to an evolution coupling relationship extraction method and system, a computer device and a storage medium. BACKGROUND
[0002] Evolution coupling, also known as logical coupling, is a phenomenon of periodic common change correlation between entities in the evolution or change history of software. Therefore, the evolution coupling of any two entities is based on their evolution history, and the evolution coupling is also a measure of the observation that the two entities always change together.
[0003] Evolution coupling has been widely used in change impact analysis to estimate the completeness of proposed changes in source code (for example, due to new features or bug reports), that is, if a source code entity is changed, which other entities also need to be changed. Evolution coupling analysis is also used for defect prediction and positioning, and the performance of defect prediction models based on software metrics can be improved using evolution coupling relationships, and defect metrics are also related to evolution coupling. Evolution coupling is also used to reveal the architectural relationship between files, and evolution coupling clusters can evaluate the modularization of a software system, help detect implicit architectural relationships between files, and the mismatch between evolution coupling clusters and package decomposition may indicate new directions for package hierarchy.
[0004] At present, the extraction of evolution coupling relationships still has the following shortcomings and deficiencies: first, refactoring information is not considered. Code refactoring is necessary during the evolution of a project, such as move method (method movement), rename method (method renaming) or Inline method (method inlining), etc. If these refactorings are not considered in the mining of method evolution coupling, the change history of the entity will be broken, thereby reducing the accuracy of the mined evolution coupling relationships. For example, renaming method1 to method2, i.e. renaming method1 to method2, since method2 is obtained by renaming method1, when mining the evolution coupling of method2, the modification of method1 should be considered, otherwise the change history of method2 will be broken. Second, the time attribute is not considered. At present, the extraction of evolution coupling relationships is a measure of the observation that two entities change together, and the calculation of evolution coupling relationships considers the common change of two entities, without considering the following relationship of the change of two entities, which will lead to incomplete evolution coupling relationships. SUMMARY
[0005] The present application aims to overcome the shortcomings of low accuracy and completeness in extracting evolutionary coupling relationships in the prior art, and provides an evolutionary coupling relationship extraction method, system, computer device and storage medium.
[0006] To achieve the above-mentioned purpose, the present application adopts the following technical solutions:
[0007] In a first aspect, the present application provides an evolutionary coupling relationship extraction method, comprising:
[0008] Obtaining the revision history of the project to be extracted;
[0009] According to the revision history, obtaining the method change history and the method refactoring information of the project to be extracted;
[0010] According to the method refactoring information, repairing the method change history;
[0011] According to the repaired method change history, obtaining the evolutionary coupling relationship between the methods in the project to be extracted.
[0012] Optionally, according to the revision history, the method change history of the project to be extracted comprises:
[0013] Converting the source code corresponding to each revision instruction in the revision history into an abstract syntax tree, and using the abstract syntax tree to extract the line number information of the methods in the source code of the project to be extracted;
[0014] Obtaining the information of the modified line in each revision instruction in the revision history, and according to the line number information of the methods in the source code of the project to be extracted and the information of the modified line in each revision instruction in the revision history, obtaining the modified method in each revision instruction in the revision history, and obtaining the method change history of the project to be extracted.
[0015] Optionally, according to the revision history, the method refactoring information of the project to be extracted comprises:
[0016] Using the refactoring detection tool PyRef to obtain the method inlining refactoring operation information, the method moving refactoring operation information, the method up-moving refactoring operation information, the method down-moving refactoring operation information, the class renaming refactoring operation information and the method renaming refactoring operation information in each revision instruction in the revision history of the project to be extracted, and obtaining the method refactoring information of the project to be extracted.
[0017] Optionally, according to the method refactoring information, the method change history is repaired, comprising:
[0018] When there is a method inlining refactoring operation, obtaining the change history of the source method in the method inlining refactoring operation, and adding the change history of the source method in the method inlining refactoring operation to the change history of the target method in the method inlining refactoring operation.
[0019] When the method move refactoring operation exists, the change history of the source method in the method move refactoring operation is acquired, and the change history of the source method in the method move refactoring operation is added to the change history of the target method in the method move refactoring operation;
[0020] When the method up move refactoring operation exists, the change history of the source method in the method up move refactoring operation is acquired, and the change history of the source method in the method up move refactoring operation is added to the change history of the target method in the method up move refactoring operation;
[0021] When the method down move refactoring operation exists, the change history of the source method in the method down move refactoring operation is acquired, and the change history of the source method in the method down move refactoring operation is added to the change history of the target method in the method down move refactoring operation;
[0022] When the class rename refactoring operation exists, the common method in the source class and the target class in the class rename refactoring operation is acquired, the change history of the common method in the source class is acquired, and the change history of the common method in the source class is added to the change history of the common method in the target class;
[0023] When the method rename refactoring operation exists, the change history of the source method in the method rename refactoring operation is acquired, and the change history of the source method in the method rename refactoring operation is added to the change history of the target method in the method rename refactoring operation.
[0024] Optionally, the method according to the repaired method change history to obtain the evolution coupling relationship between the methods in the to-be-extracted project comprises:
[0025] According to the repaired method change history, the rule support degree of the method X and the method Y is obtained by the following formula:
[0026] support(X=>Y)=support(X,Y)
[0027] Wherein, support(X=>Y) is the rule support degree of the method X and the method Y, support(X,Y) is the number of times that the method Y is changed after the method X in the repaired method change history, and the number of times that the revision instruction of the method X and the revision instruction of the method Y satisfy the following formula in the repaired method change history is obtained by statistics:
[0028] commit2_index>commit1_index
[0029] commit2_index-commit1_index<=Index_Threshold
[0030] commit2_time-commit1_time<=Time_threshold
[0031] Wherein, the commit1_index is the time order of the current revision instruction of the method X, the commit2_index is the time order of the current revision instruction of the method Y, the Index_Threshold is the preset time order threshold, the commit1_time is the occurrence time of the current revision instruction of the method X, the commit2_time is the occurrence time of the current revision instruction of the method Y, and the Time_threshold is the preset time threshold;
[0032] The change following probability of the method X and the method Y is obtained by the following formula:
[0033] confidence(X=>Y)=support(X=>Y) / support(X)
[0034] Wherein, the confidence(X=>Y) is the change following probability of the method X and the method Y, and the support(X) is the number of the method X change in the repaired method change history;
[0035] When the rule support degree of the method X and the method Y is greater than the preset rule support degree threshold, and the change following probability of the method X and the method Y is greater than the preset change following probability threshold, the evolution coupling relationship exists between the method X and the method Y.
[0036] Optionally, the preset time order threshold is obtained by the following formula:
[0037] Index_Threshold=CommitNum / DayNum
[0038] Wherein, the CommitNum is the total number of the revision instructions in the repaired method change history, and the DayNum is the total number of the days with revision instructions in the repaired method change history;
[0039] The preset time threshold is the time interval of the third quartile among the time intervals between all adjacent revision instructions in the repaired method change history.
[0040] Optionally, the to-be-extracted project is a software project written in a dynamic type language Python.
[0041] The second aspect of the application provides an evolution coupling relationship extraction system, comprising:
[0042] A data acquisition module is configured to acquire the revision history of the to-be-extracted project.
[0043] An information extraction module is configured to obtain method change history and method refactoring information of the project to be extracted according to the revision history.
[0044] A repair module is configured to repair the method change history according to the method refactoring information.
[0045] An evolution coupling relationship extraction module is configured to obtain evolution coupling relationships between methods in the project to be extracted according to the repaired method change history.
[0046] In a third aspect, the present application provides a computer device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the evolution coupling relationship extraction method when executing the computer program.
[0047] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program implements the steps of the evolution coupling relationship extraction method when executed by a processor.
[0048] Compared with the prior art, the present application has the following beneficial effects:
[0049] The evolution coupling relationship extraction method of the present application firstly obtains method change history and method refactoring information of the project to be extracted based on the revision history of the project to be extracted, then repairs the method change history based on the method refactoring information, considers refactoring operations in the revision history, so as to ensure that the change history of each method will not be broken, obtain more complete change history of each method, and finally obtains evolution coupling relationships between methods in the project to be extracted according to the repaired method change history, effectively improves the completeness and accuracy of evolution coupling relationship extraction, and obtains complete and accurate evolution coupling relationships between methods in the project to be extracted, which can be further used for defect detection or software modularization measurement research work, and improves development quality and efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0050] Figure 1 The evolution coupling relationship extraction method flowchart of the present application embodiment;
[0051] Figure 2 The evolution coupling relationship extraction system structure block diagram of the present application embodiment. DETAILED DESCRIPTION
[0052] In the following, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of embodiments of the present application, rather than all embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work should fall within the protection scope of the present application.
[0053] It should be noted that the terms "first", "second", and the like in the description and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to include only those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to the process, method, product or device.
[0054] The present application will be described in further detail below with reference to the drawings:
[0055] Referring to Figure 1 In an embodiment of the present application, an evolution coupling relationship extraction method is provided, which can extract more complete and accurate evolution coupling relationships compared with existing methods.
[0056] Specifically, the evolution coupling relationship extraction method includes the following steps:
[0057] S1: obtaining a revision history of a project to be extracted;
[0058] S2: obtaining a method change history and method refactoring information of the project to be extracted according to the revision history;
[0059] S3: repairing the method change history according to the method refactoring information;
[0060] S4: obtaining evolution coupling relationships between methods in the project to be extracted according to the repaired method change history.
[0061] Specifically, the evolution coupling relationship extraction method first obtains the method change history and the method refactoring information of the to-be-extracted project based on the revision history of the to-be-extracted project, then repairs the method change history based on the method refactoring information, considers the refactoring operation in the revision history, so as to ensure that the change history of each method does not break, obtain a more complete change history of each method, and finally obtain the evolution coupling relationship between each method in the to-be-extracted project according to the repaired method change history, effectively improving the completeness and accuracy of the evolution coupling relationship extraction, obtaining complete and accurate evolution coupling relationship between each method in the to-be-extracted project, which can be further used in defect detection or software modularization measurement research work, and improving the development quality and efficiency.
[0062] In a possible implementation, the method change history of the to-be-extracted project is obtained according to the revision history, including: converting the source code corresponding to each revision instruction in the revision history into an abstract syntax tree (AST), and using the AST to extract the line number information of the method in the source code of the to-be-extracted project; obtaining the information of the modified line in each revision instruction in the revision history, and obtaining the modified method in each revision instruction in the revision history according to the line number information of the method in the source code of the to-be-extracted project and the information of the modified line in each revision instruction in the revision history, to obtain the method change history of the to-be-extracted project.
[0063] Specifically, the revision history of the to-be-extracted project is obtained by using an open source distributed version control system Git, and the source code corresponding to each commit (modification instruction) in the revision history is converted into an AST (abstract syntax tree). The line number information of the method in the source code is extracted using the AST. The information of the modified line in each commit is obtained using the git diff command, and the addition and deletion of empty lines and comment lines are ignored because these changes have no effect on the source code. The modified method in each commit is obtained by combining the line number information of the method and the information of the modified line, thereby obtaining the method change history of the to-be-extracted project. For example: method (commit1, commit2, commit3) indicates that the method has changed in commit1, commit2 and commit3. Wherein, method represents the method name, and commit1, commit2 and commit3 are commitId.
[0064] In a possible implementation, the method refactoring information of the to-be-extracted project is obtained according to the revision history, including: using a refactoring detection tool PyRef to obtain the method inlining refactoring operation information, the method moving refactoring operation information, the method up-moving refactoring operation information, the method down-moving refactoring operation information, the class renaming refactoring operation information and the method renaming refactoring operation information in each revision instruction in the revision history of the to-be-extracted project, to obtain the method refactoring information of the to-be-extracted project.
[0065] Specifically, the refactoring detection tool PyRef is used to obtain refactoring information, and the Git of the project to be extracted is taken as input to identify the refactoring operation in each commit. Since the final purpose is to mine the evolution coupling of methods, only part of the refactoring operation information needs to be detected, including method inlining refactoring operation, method moving refactoring operation, method up-moving refactoring operation, method down-moving refactoring operation, class renaming refactoring operation, and method renaming refactoring operation.
[0066] Among them, the method inlining refactoring operation is to inline the source method into the target method, the method moving refactoring operation is to move the source method to the target method, the method up-moving refactoring operation is to move the source method to the target method, the method down-moving refactoring operation is to move the source method to the target method, the class renaming refactoring operation is to rename the source class to the target class, and the method renaming refactoring operation is to rename the source method to the target method.
[0067] In a possible implementation, the method of repairing the method change history according to the method refactoring information comprises: when there is a method inlining refactoring operation, obtaining the change history of the source method in the method inlining refactoring operation, and adding the change history of the source method in the method inlining refactoring operation to the change history of the target method in the method inlining refactoring operation; when there is a method moving refactoring operation, obtaining the change history of the source method in the method moving refactoring operation, and adding the change history of the source method in the method moving refactoring operation to the change history of the target method in the method moving refactoring operation; when there is a method up-moving refactoring operation, obtaining the change history of the source method in the method up-moving refactoring operation, and adding the change history of the source method in the method up-moving refactoring operation to the change history of the target method in the method up-moving refactoring operation; when there is a method down-moving refactoring operation, obtaining the change history of the source method in the method down-moving refactoring operation, and adding the change history of the source method in the method down-moving refactoring operation to the change history of the target method in the method down-moving refactoring operation; when there is a class renaming refactoring operation, obtaining the common method in the source class and the target class, obtaining the change history of the common method in the source class, and adding the change history of the common method in the source class to the change history of the common method in the target class; when there is a method renaming refactoring operation, obtaining the change history of the source method in the method renaming refactoring operation, and adding the change history of the source method in the method renaming refactoring operation to the change history of the target method in the method renaming refactoring operation.
[0068] Specifically, different repair methods are used for different refactoring operations to effectively ensure the integrity of the change history of the target method.
[0069] In a possible implementation, the method according to the repaired method change history to obtain the evolution coupling relationship between each method in the to-be-extracted project comprises: according to the repaired method change history, the rule support degree of method X and method Y is obtained through the following formula:
[0070] support(X=>Y)=support(X,Y)
[0071] Wherein, support(X=>Y) is the rule support degree of method X and method Y, support(X,Y) is the number of times that method Y is changed after method X in the repaired method change history, and the number of times that the revision instruction of method X and the revision instruction of method Y in the repaired method change history satisfy the following formula is obtained by counting:
[0072] commit2_index>commit1_index
[0073] commit2_index-commit1_index<=Index_Threshold
[0074] commit2_time-commit1_time<=Time_threshold
[0075] Wherein, commit1_index is the time sequence of the current revision instruction of method X, commit2_index is the time sequence of the current revision instruction of method Y, Index_Threshold is a preset time sequence threshold, commit1_time is the occurrence time of the current revision instruction of method X, commit2_time is the occurrence time of the current revision instruction of method Y, and Time_threshold is a preset time threshold.
[0076] The change following probability of method X and method Y is obtained through the following formula:
[0077] confidence(X=>Y)=support(X=>Y) / support(X)
[0078] Wherein, confidence(X=>Y) is the change following probability of method X and method Y, and support(X) is the number of times that method X is changed in the repaired method change history.
[0079] When the rule support degree of method X and method Y is greater than a preset rule support degree threshold, and the change following probability of method X and method Y is greater than a preset change following probability threshold, the evolution coupling relationship exists between method X and method Y.
[0080] Specifically, unlike the association rules, the evolution coupling relationship extraction method of the present application mines the frequent patterns of time series and generates rules. First, the rule is defined as the expression of the form X=>Y, and the method X and the method Y are both a method in the project to be extracted. In the context of software engineering, such a rule means that if the method X has been modified in a specific commit1, then the method Y also has a tendency to be modified in commit2, and commit1 and commit2 satisfy the following conditions:
[0081] commit2_index > commit1_index
[0082] commit2_index-commit1_index <= Index_Threshold
[0083] commit2_time-commit1_time <= Time_threshold
[0084] Optionally, the Index_Threshold can be set by viewing the average number of modification instructions submitted in a day, which ignores the days without submission. The preset time sequence threshold is obtained by the following formula:
[0085] Index_Threshold = CommitNum / DayNum
[0086] Wherein, CommitNum is the total number of revision instructions in the repaired method change history, and DayNum is the total number of days with revision instructions in the repaired method change history.
[0087] The preset time threshold is the third quartile of the time interval between all adjacent revision instructions in the repaired method change history.
[0088] If X=>Y satisfies the rule support threshold and the change following probability threshold, it is considered that the two methods of method X and method Y have an evolution coupling relationship. The higher the rule support threshold and the change following probability threshold, the fewer the method groups obtained that have an evolution coupling relationship. The rule support threshold and the change following probability threshold can be set according to the number of rules required by the project.
[0089] In one possible implementation, the project to be extracted is a software project written in a dynamic type language Python language.
[0090] Specifically, at present, due to the lack of a method change extraction tool for a software project written in a dynamic type language Python, existing researches are all file-level evolution coupling extraction. In addition, the object of evolution coupling analysis is mainly a project written in a static type language Java, C, C++ or C#, and there is little research on evolution coupling of a software project written in a dynamic type language Python.
[0091] The evolution coupling relationship extraction method of the present application can realize method-level research on a software project written in a dynamic type language Python, and makes up for the deficiency of the current file-level evolution coupling mining of a software project written in a dynamic type language Python.
[0092] In a possible implementation, the evolution coupling relationship extraction method of the present application is illustrated by taking a revision history of a software project written in a dynamic type language Python as an example, and includes the following steps:
[0093] Table 1 Revision history information table
[0094]
[0095]
[0096]
[0097]
[0098] S11: Based on the revision history shown in Table 1, obtain the method change history.
[0099] The change history of the is_access_token_expired() method, the is_session_access_token_expired() method and the send_new_user_email() method can be obtained: is_access_token_expired(9fbec), is_session_access_token_expired(fabcc) and send_new_user_email(2c9f7,b93cf).
[0100] S12: Obtain the method refactoring information using pyref based on the revision history shown in Table 1, as shown in Table 2.
[0101] Table 2 Method refactoring information table
[0102]
[0103] S13: Combine the method change history and the method refactoring information, and repair the method change history.
[0104] Due to the renaming of is_access_token_expired() to is_session_access_token_expired(), a history break of is_session_access_token_expired() is caused. According to the repair method of the method renaming refactoring operation, the change history of the repaired is_session_access_token_expired() is obtained:
[0105] is_session_access_token_expired(9fbec, fabcc).
[0106] S14: Extract the evolution coupling relationship using the repaired method change history.
[0107] According to the setting method of Index_Threshold and TimeThreshold, based on the revision history of Table 1, Index_Threshold and TimeThreshold are obtained as 2 and 8h respectively. Through calculation, it can be obtained that:
[0108] support(is_session_access_token_expired()=>send_new_user_email())=2
[0109] confidence(is_session_access_token_expired()=>send_new_user_email())=1
[0110] In the embodiment, the rule support threshold and the change following probability threshold are set as 1 and 0.5 respectively. Since the rule support and the change following probability of the rule is_session_access_token_expired()=>send_new_user_email() exceed the rule support threshold and the change following probability threshold, the evolution coupling relationship exists between is_session_access_token_expired() and send_new_user_email().
[0111] The following is a device embodiment of the application, which can be used to execute the method embodiment of the application. For details not disclosed in the device embodiment, please refer to the method embodiment of the application.
[0112] Reference Figure 2In still another embodiment of the present application, an evolution coupling relationship extraction system is provided, which can be used to implement the evolution coupling relationship extraction method described above. Specifically, the evolution coupling relationship extraction system comprises a data acquisition module, an information extraction module, a repair module, and an evolution coupling relationship extraction module.
[0113] The data acquisition module is configured to acquire the revision history of the project to be extracted. The information extraction module is configured to obtain the method change history and the method refactoring information of the project to be extracted according to the revision history. The repair module is configured to repair the method change history according to the method refactoring information. The evolution coupling relationship extraction module is configured to obtain the evolution coupling relationship between the methods in the project to be extracted according to the repaired method change history.
[0114] In a possible implementation, the obtaining of the method change history of the project to be extracted according to the revision history comprises: converting the source code corresponding to each revision instruction in the revision history into an abstract syntax tree, and using the abstract syntax tree to extract the line number information of the methods in the source code of the project to be extracted; obtaining the information of the modified line in each revision instruction in the revision history, and obtaining the modified method in each revision instruction in the revision history according to the line number information of the methods in the source code of the project to be extracted and the information of the modified line in each revision instruction in the revision history, to obtain the method change history of the project to be extracted.
[0115] In a possible implementation, the obtaining of the method refactoring information of the project to be extracted according to the revision history comprises: using a refactoring detection tool PyRef to obtain the inlining refactoring operation information, the moving refactoring operation information, the upward moving refactoring operation information, the downward moving refactoring operation information, the class renaming refactoring operation information, and the method renaming refactoring operation information of the methods in each revision instruction in the revision history of the project to be extracted, to obtain the method refactoring information of the project to be extracted.
[0116] In a possible implementation, the reconstructing the information according to the method, and repairing the method change history comprises: when there is a method inlining refactoring operation, obtaining the change history of a source method in the method inlining refactoring operation, and adding the change history of the source method in the method inlining refactoring operation to the change history of a target method in the method inlining refactoring operation; when there is a method moving refactoring operation, obtaining the change history of a source method in the method moving refactoring operation, and adding the change history of the source method in the method moving refactoring operation to the change history of a target method in the method moving refactoring operation; when there is a method up-moving refactoring operation, obtaining the change history of a source method in the method up-moving refactoring operation, and adding the change history of the source method in the method up-moving refactoring operation to the change history of a target method in the method up-moving refactoring operation; when there is a method down-moving refactoring operation, obtaining the change history of a source method in the method down-moving refactoring operation, and adding the change history of the source method in the method down-moving refactoring operation to the change history of a target method in the method down-moving refactoring operation; when there is a class renaming refactoring operation, obtaining a common method in a source class and a target class in the class renaming refactoring operation, obtaining the change history of the common method in the source class, and adding the change history of the common method in the source class to the change history of the common method in the target class; and when there is a method renaming refactoring operation, obtaining the change history of a source method in the method renaming refactoring operation, and adding the change history of the source method in the method renaming refactoring operation to the change history of a target method in the method renaming refactoring operation.
[0117] In a possible implementation, the obtaining the evolution coupling relationship between the methods in the to-be-extracted item according to the repaired method change history comprises: obtaining the rule support degree of a method X and a method Y according to the repaired method change history by the following formula:
[0118] support(X=>Y)=support(X,Y)
[0119] wherein, the support(X=>Y) is the rule support degree of the method X and the method Y, the support(X,Y) is the number of times that the method Y is changed after the method X in the repaired method change history, and the support(X,Y) is obtained by counting the number of times that the revision instruction of the method Y meets the following formula in the revision instruction of the method X in the repaired method change history:
[0120] commit2_index>commit1_index
[0121] commit2_index-commit1_index<=Index_Threshold
[0122] commit2_time-commit1_time<=Time_threshold
[0123] Wherein, commit1_index is the time order of the current revision instruction of method X, commit2_index is the time order of the current revision instruction of method Y, Index_Threshold is the preset time order threshold, commit1_time is the occurrence time of the current revision instruction of method X, commit2_time is the occurrence time of the current revision instruction of method Y, Time_threshold is the preset time threshold.
[0124] The change following probability of method X and method Y is obtained by the following formula:
[0125] confidence(X=>Y)=support(X=>Y) / support(X)
[0126] Wherein, confidence(X=>Y) is the change following probability of method X and method Y, support(X) is the number of method X change in the repaired method change history.
[0127] When the rule support degree of method X and method Y is greater than the preset rule support degree threshold, and the change following probability of method X and method Y is greater than the preset change following probability threshold, there is an evolutionary coupling relationship between method X and method Y.
[0128] In a possible implementation, the preset time order threshold is obtained by the following formula:
[0129] Index_Threshold=CommitNum / DayNum
[0130] Wherein, CommitNum is the total number of revision instructions in the repaired method change history, and DayNum is the total number of days with revision instructions in the repaired method change history.
[0131] The preset time threshold is the third quartile time interval between all adjacent revision instructions in the repaired method change history.
[0132] In a possible implementation, the to-be-extracted project is a software project written in a dynamic type language Python.
[0133] The foregoing embodiment of the evolutionary coupling relationship extraction method relates to the function description of the function modules corresponding to the evolutionary coupling relationship extraction system in the embodiment of the present application, and thus the details are not repeated here.
[0134] The division of the modules in the embodiments of the present application is illustrative, and is only logical function division. In actual implementation, another division manner can be used. In addition, each function module in each embodiment of the present application can be integrated in one processor, or can be physically separated, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software function module.
[0135] In still another embodiment of the present application, a computer device is provided, which includes a processor and a memory. The memory is configured to store a computer program, and the computer program includes program instructions. The processor is configured to execute the program instructions stored in the computer storage medium. The processor can be a central processing unit (CPU), and can also be another general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or another programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and the like. The processor is a computing core and a control core of the terminal, and is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions in the computer storage medium to implement a corresponding method flow or a corresponding function. The processor in the embodiments of the present application can be used for the operation of the evolution coupling relationship extraction method.
[0136] In still another embodiment, the present application provides a storage medium, specifically a computer readable storage medium (Memory), which is a memory device in a computer system, for storing programs and data. It should be understood that the computer readable storage medium here can include an internal storage medium in the computer system, and of course can also include an extended storage medium supported by the computer system. The computer readable storage medium provides a storage space, which stores an operating system of the terminal. In addition, one or more instructions adapted to be loaded and executed by the processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer readable storage medium here can be a high-speed RAM memory, or a non-volatile memory such as at least one disk memory. The one or more instructions stored in the computer readable storage medium can be loaded and executed by the processor to implement the corresponding steps of the evolution coupling relationship extraction method in the above embodiments.
[0137] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code.
[0138] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device implemented in the flowcharts and / or block diagrams. Figure 1 The functions specified in one or more flows and / or blocks Figure 1 The means for performing the functions specified in one or more flows and / or blocks.
[0139] These computer program instructions can also be stored in a computer readable storage medium capable of directing the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer readable storage medium produce a manufactured product including instruction means, which implements the flowcharts and / or block diagrams. Figure 1 The functions specified in one or more flows and / or blocks Figure 1the function specified in the one or more blocks.
[0140] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operation steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, so that the instructions executed on the computer or other programmable devices provide processes for implementing the flowcharts Figure 1 one or more flows and / or blocks Figure 1 the function specified in the one or more blocks.
[0141] Finally, it should be noted that: the above examples are only used to illustrate the technical solutions of the present application, but not to limit it, although the above embodiments of the present application have been described in detail, those skilled in the art should understand: the specific embodiments of the present application can be modified or replaced by the same, without departing from the spirit and scope of the present application, any modification or equivalent replacement, which should be covered within the scope of protection of the claims of the present application.
Claims
1. An evolutionary coupling relation extraction method, characterized in that, The method comprises the following steps: obtaining the revision history of the project to be extracted; obtaining the method change history and the method refactoring information of the project to be extracted according to the revision history, which comprises the following steps: converting the source code corresponding to each revision instruction in the revision history into an abstract syntax tree, and extracting the line number information of the method in the source code of the project to be extracted by using the abstract syntax tree; obtaining the information of the modified line in each revision instruction in the revision history, and obtaining the modified method in each revision instruction in the revision history according to the line number information of the method in the source code of the project to be extracted and the information of the modified line in each revision instruction in the revision history, thereby obtaining the method change history of the project to be extracted; repairing the method change history according to the method refactoring information, which comprises the following steps: when there is a method inlining, method moving, method up-moving, method down-moving or method renaming refactoring operation, obtaining the change history of the source method in the method refactoring operation, and adding the change history of the source method in the method refactoring operation to the change history of the target method in the method refactoring operation; when there is a class renaming refactoring operation, obtaining the common method in the source class and the target class, and obtaining the change history of the source method in the method moving refactoring operation, and adding the change history of the common method in the source class to the change history of the common method in the target class; obtaining the evolution coupling relationship between the methods in the project to be extracted according to the repaired method change history, which comprises the following steps: obtaining the rule support degree of the method X and the method Y according to the repaired method change history by the following formula: wherein, is the rule support of method X and method Y, is the number of times method Y follows method X in the repaired method change history, which is obtained by counting the number of times the revision instruction of method X and the revision instruction of method Y satisfy the following formula in the repaired method change history: wherein, is a time order of the current revision instruction for method X, is a time order of the current revision instruction for method Y, is a preset time order threshold value, is a time of occurrence of the current revision instruction for method X, is a time of occurrence of the current revision instruction for method Y, is a preset time threshold value; obtaining the change following probability of the method X and the method Y by the following formula: wherein, is the probability of a method X and method Y change following, is the number of method X changes in the repaired method change history; when the rule support degree of the method X and the method Y is greater than the preset rule support degree threshold, and the change following probability of the method X and the method Y is greater than the preset change following probability threshold, there is an evolution coupling relationship between the method X and the method Y; the preset time sequence threshold is obtained by the following formula: um / DayNum wherein, um total number of revisions in the method change history for the fix, DayNum total number of days in the method change history for the fix that have revisions. The preset time threshold is the third quartile time interval between all adjacent revision instructions in the repaired method change history.
2. The method of claim 1, wherein, According to the revision history, the method refactoring information of the project to be extracted comprises the following steps: using the refactoring detection tool PyRef, obtaining the method inlining refactoring operation information, the method moving refactoring operation information, the method up-moving refactoring operation information, the method down-moving refactoring operation information, the class renaming refactoring operation information and the method renaming refactoring operation information in each revision instruction in the revision history of the project to be extracted, thereby obtaining the method refactoring information of the project to be extracted.
3. The method of claim 1, wherein, The project to be extracted is a software project written in a dynamic type language Python.
4. An evolution coupling relationship extraction system based on the evolution coupling relationship extraction method according to any one of claims 1 to 3, characterized in that, The method comprises the following steps: a data acquisition module for obtaining the revision history of the project to be extracted; an information extraction module for obtaining the method change history and the method refactoring information of the project to be extracted according to the revision history; a repair module for repairing the method change history according to the method refactoring information; an evolution coupling relationship extraction module for obtaining the evolution coupling relationship between the methods in the project to be extracted according to the repaired method change history.
5. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor implements the steps of the evolution coupling relationship extraction method as claimed in any one of claims 1 to 3 when executing the computer program.
6. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 5. The computer program, when executed by the processor, implements the steps of the evolution coupling relationship extraction method as claimed in any one of claims 1 to 3.
Citation Information
Patent Citations
Python code change reminding method on basis of abstract syntax tree node change extraction
CN105159715A