Software defect positioning method and device based on multiple views

By applying multi-view methods of graph neural network and comparison learning technology in software engineering, the problem of low positioning accuracy caused by the lack of information in defect report text is solved, and in-depth mining and efficient utilization of multi-source information is achieved, which significantly improves defect positioning performance and efficiency.

CN119396687APending Publication Date: 2025-02-07WUHAN UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411363094.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In the context of lack of information on defect report text, the existing technology cannot fully tap and utilize multi-source information, resulting in low positioning accuracy and lack of in-depth analysis of the potential impact and effective strategies of multi-source information on positioning performance.

Method used

Using a multi-view method based on graph neural network and contrast learning technology, multiple relationship data between defect reports and source code files in software projects are extracted, characterization learning is performed, feature similarity is calculated, and similarity is selected through similarity sorting. Source code files greater than the preset similarity to determine defect location information.

Benefits of technology

Through in-depth mining and efficient utilization of multi-source information, we can effectively make up for the shortcomings of text information, significantly improve the performance and efficiency of defect positioning, and solve the problems of low positioning accuracy and lack of effective strategies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396687A_ABST
    Figure CN119396687A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of software engineering, in particular to a software defect positioning method and device based on multiple views, and the method comprises the steps: extracting various relational data between a defect report and a source code file in a software project, carrying out characterization learning on a multi-source relationship between the defect report and the source code file based on a graph neural network and a contrast learning technology to obtain characterization of the defect report and the source code file; calculating feature similarity between the defect reports and the source code files, and generating a similarity sequence of the source code files for the corresponding defect reports according to the similarity; and based on the similarity sequence, selecting the source code files with the similarity greater than a preset similarity, and determining defect positioning information in the software project by utilizing the selected source code files. Therefore, the problems that in the prior art, multi-source information cannot be fully mined and utilized, so that a key path with low positioning precision is caused, the influence of analyzing the multi-source information on the positioning performance is not generated, and an effective strategy is lacked are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software engineering technology, and in particular to a software defect location method and device based on multiple views. Background Art

[0002] During the life cycle of a software system, the project team often receives a large number of defect reports. Once a defect report is received, developers need to be quickly mobilized to deeply analyze the source code files to accurately identify and repair potential defects. Therefore, efficient defect location technology is particularly critical.

[0003] In the related technologies, defect location technology is mainly divided into: one is the spectrum-based method, which relies on the dynamic spectrum information of the program in different execution processes to assist in locating the fault source; the other is the information retrieval-based method, which does not require dynamic execution information, but focuses on analyzing the text content between the defect report and the source code file, and achieves defect location by evaluating the correlation between the two. The information retrieval-based method can be divided into two categories: text matching method and semantic matching method. The text matching method focuses on directly utilizing the similarity at the lexical level, treating the defect report as a query and the program module as a corpus for text retrieval. The introduction of the semantic matching method has injected new vitality into the defect location technology based on information retrieval, and is expected to become the mainstream development direction in this field in the future.

[0004] However, in the related technologies, in the context of scarce text information in defect reports, it is impossible to fully explore and utilize multi-source information, which leads to the key path of low positioning accuracy. In addition, there is no in-depth analysis of the potential impact of multi-source information on positioning performance, and there is a lack of effective strategies to optimize the adaptive extraction and integration of valuable data from multiple information sources. Summary of the invention

[0005] The present application provides a software defect localization method and device based on multiple views to solve the key problems in the related art that, in the context of a lack of text information in defect reports, multi-source information cannot be fully mined and utilized, resulting in low positioning accuracy. In addition, there is no in-depth analysis of the potential impact of multi-source information on positioning performance, and there is a lack of effective strategies to optimize the adaptive extraction and integration of valuable data from multiple information sources.

[0006] The first aspect of the present application provides a software defect localization method based on multiple views, comprising the following steps: extracting multiple relationship data between defect reports and source code files in a software project, and characterizing and learning the multi-source relationship between the defect report and the source code file based on a graph neural network and contrastive learning technology to obtain a characterization of the defect report and the source code file; based on the characterization of the defect report and the source code file, calculating the feature similarity between the defect report and the source code file, and generating a similarity ranking of the source code files for the corresponding defect report according to the similarity; based on the similarity ranking, selecting a source code file whose similarity is greater than a preset similarity, and using the selected source code file to determine defect localization information in the software project.

[0007] Optionally, in one embodiment of the present application, the extracting of multiple relationship data between defect reports and source code files in a software project, and performing characterization learning on the multi-source relationship between the defect reports and the source code files based on a graph neural network and contrastive learning technology to obtain characterizations of defect reports and source code files, includes: extracting repair history data between defect reports and source code files, similarity data between defect reports, and co-citation data between source code files based on the multiple relationship data between the defect reports and the source code files, and constructing them into different views respectively, wherein the views may include but are not limited to historical interaction views, defect report similarity views, and source code co-citation views; constructing a historical interaction view based on the repair history data, and performing characterization learning on the historical interaction view using the graph neural network to obtain a first defect report characterization matrix of the defect report and a first source code file characterization matrix of the source code file; constructing a defect report similarity view based on the similarity data, and performing characterization learning on the defect report similarity view using the graph neural network to obtain a second defect report characterization matrix of the defect report; constructing a source code co-citation view based on the co-citation data, and performing characterization learning on the source code co-citation view using the graph neural network to obtain a second source code file characterization matrix of the source code file.

[0008] Optionally, in one embodiment of the present application, the extracting of multiple relationship data between the defect report and the source code file in the software project, and characterizing and learning the multi-source relationship between the defect report and the source code file based on the graph neural network and contrastive learning technology to obtain the characterization of the defect report and the source code file, also includes: based on the first defect report characterization matrix, the second defect report characterization matrix, the first source code file characterization matrix and the second source code file characterization matrix, using the objective function to calculate the matching score between the defect report and the source code file; performing information interaction between the first defect report characterization matrix and the second defect report characterization matrix to obtain the defect report characterization distance of the same sample and the defect report characterization distance of different samples; performing information interaction between the first source code file characterization matrix and the second source code file characterization matrix to obtain the source code file characterization distance of the same sample and the source code file characterization distance of different samples; combining the matching score, the defect report characterization distance and the source code file characterization distance, jointly optimizing the first defect report characterization matrix, the second defect report characterization matrix, the first source code file characterization matrix and the second source code file characterization matrix with the contrast function and the multi-task strategy, and using the optimized characterization matrix as the final feature of the defect report and the source code file for subsequent calculation of similarity ranking.

[0009] Optionally, in one embodiment of the present application, the calculation formula of the matching score may be, but is not limited to,:

[0010]

[0011] Among them, z r and z c Defect report v r and source code file v c The representation vector of

[0012] The objective function of the matching score may be, but is not limited to:

[0013]

[0014] in, represents all positive sample pairs (i.e., actually associated defect reports and source code file pairs), and |C| is the total number of candidate source code files.

[0015] Optionally, in one embodiment of the present application, the objective function of the comparison function may be, but is not limited to:

[0016]

[0017] in, and represents the positive sample pairs in different views, and is a negative sample pair, It is used to calculate the cosine similarity of two representation vectors, |R| and |C| are the number of defect reports and source code files respectively, and τ is the temperature hyperparameter of contrastive learning.

[0018] The second aspect of the present application provides a software defect localization device based on multiple views, including: a learning module, which is used to extract various relationship data between defect reports and source code files in a software project, and to characterize and learn the multi-source relationship between the defect report and the source code file based on a graph neural network and contrastive learning technology to obtain a characterization of the defect report and the source code file; a sorting module, which is used to calculate the feature similarity between the defect report and the source code file based on the characterization of the defect report and the source code file, and to generate a similarity ranking of the source code files for the corresponding defect report according to the similarity; a determination module, which is used to select a source code file with a similarity greater than a preset similarity based on the similarity ranking, and use the selected source code file to determine the defect localization information in the software project.

[0019] Optionally, in one embodiment of the present application, the learning module includes: an acquisition unit, which is used to extract the repair history data between the defect report and the source code file, the similarity data between the defect reports and the co-citation data between the source code files based on the multiple relationship data between the defect report and the source code file, and construct them into different views respectively, wherein the views may include but are not limited to historical interaction views, defect report similarity views and source code co-citation views; a first learning unit, which is used to construct a historical interaction view based on the repair history data, and use the graph neural network to perform representation learning on the historical interaction view to obtain a first defect report representation matrix of the defect report and a first source code file representation matrix of the source code file; a second learning unit, which is used to construct a source code co-citation view based on the co-citation data, and use the graph neural network to perform representation learning on the defect report similarity view to obtain a second defect report representation matrix of the defect report; a third learning unit, which is used to construct a source code co-citation view based on the co-citation data, and use the graph neural network to perform representation learning on the source code co-citation view to obtain a second source code file representation matrix of the source code file.

[0020] Optionally, in one embodiment of the present application, the learning module further includes: a matching unit, configured to calculate a matching score between the defect report and the source code file using an objective function based on the first defect report representation matrix, the second defect report representation matrix, the first source code file representation matrix, and the second source code file representation matrix; a first generating unit, configured to perform information interaction between the first defect report representation matrix and the second defect report representation matrix to obtain a defect report representation distance of the same sample and a defect report representation distance of different samples; a second generating unit, configured to perform information interaction between the first source code file representation matrix and the second source code file representation matrix to obtain a source code file representation distance of the same sample and a source code file representation distance of different samples; and a third generating unit, configured to optimize the first defect report representation matrix, the second defect report representation matrix, the first source code file representation matrix, and the second source code file representation matrix in combination with the contrastive learning technology and the multi-task strategy in combination with the matching score, the defect report representation distance, and the source code file representation distance, and use the optimized representation matrix as the final feature of the defect report and the source code file for subsequent similarity ranking calculation.

[0021] Optionally, in one embodiment of the present application, the calculation formula of the matching score may be, but is not limited to,:

[0022]

[0023] Among them, z r and z c Defect report v r and source code file v c The representation vector of

[0024] The objective function of the matching score may be, but is not limited to:

[0025]

[0026] in, represents all positive sample pairs (i.e., actually associated defect reports and source code file pairs), and |C| is the total number of candidate source code files.

[0027] Optionally, in one embodiment of the present application, the objective function of the comparison function may be, but is not limited to:

[0028]

[0029] in, and represents the positive sample pairs in different views, and is a negative sample pair, It is used to calculate the cosine similarity of two representation vectors, |R| and |C| are the number of defect reports and source code files respectively, and τ is the temperature hyperparameter of contrastive learning.

[0030] The third aspect of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the multi-view-based software defect localization method as described in the above embodiment.

[0031] The fourth aspect of the present application provides a computer-readable storage medium, which stores a computer program. When the program is executed by a processor, it implements the above-mentioned multi-view-based software defect localization method.

[0032] The fifth aspect of the present application provides a computer program product, including a computer program, which, when executed, implements the above-mentioned multi-view-based software defect localization method.

[0033] The embodiment of the present application can construct a multi-source relationship view based on the defect report and source code file in the software project, and use a graph neural network to perform in-depth representation learning on the nodes in each view, so as to display and encode the three relationships into the representation of the defect report and the source code file, and then use contrastive learning technology and multi-task joint optimization to calculate the similarity between the defect report feature representation and the source code file feature representation, select source code files with a similarity greater than a certain similarity, and determine the defect location information in the software project. In the case of a lack of defect report text information, the in-depth mining and efficient use of multi-source information can effectively make up for the lack of text information, and use contrastive learning technology and multi-task joint optimization to automatically integrate information encoding from multiple sources into the representation learning process of defect reports and source code files, thereby constructing a more comprehensive and accurate representation model, significantly improving the performance and efficiency of defect location. As a result, the key path of the related technology that cannot fully mine and utilize multi-source information, resulting in low positioning accuracy, and the lack of analysis of the impact of multi-source information on positioning performance and the lack of effective strategies are solved.

[0034] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0036] Figure 1A flowchart of a software defect location method based on multiple views provided according to an embodiment of the present application;

[0037] Figure 2 A schematic block diagram of a multi-source relationship structure provided according to an embodiment of the present application;

[0038] Figure 3 A block diagram of a process for locating software defects provided according to an embodiment of the present application;

[0039] Figure 4 A flowchart of the working principle of a software defect localization method based on multiple views provided according to an embodiment of the present application;

[0040] Figure 5 A block diagram of a software defect location device based on multiple views provided according to an embodiment of the present application;

[0041] Figure 6 It is a schematic diagram of the structure of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0042] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0043] The following describes a software defect localization method and device based on multiple views according to an embodiment of the present application with reference to the accompanying drawings. In view of the key path mentioned in the above background technology that in the context of lack of defect report text information, it is impossible to fully mine and utilize multi-source information, resulting in low positioning accuracy, and in addition, there is no in-depth analysis of the potential impact of multi-source information on positioning performance, and there is a lack of effective strategies to optimize the problem of adaptively extracting and integrating valuable data from multiple information sources. The present application provides a software defect localization method based on multiple views. In this method, a multi-source relationship view can be constructed according to the defect report and source code files in the software project, and a graph neural network is used to perform in-depth representation learning on the nodes in each view, so that the three relationships are displayed and encoded into the representation of the defect report and the source code file, and then the similarity between the defect report feature representation and the source code file feature representation is calculated by using contrastive learning technology and multi-task joint optimization, and the source code files with similarity greater than a certain similarity are selected to determine the defect location information in the software project. In the context of lack of defect report text information, the insufficiency of text information is effectively compensated by relying on in-depth mining and efficient utilization of multi-source information, and the contrastive learning technology and multi-task joint optimization are used to automatically integrate the information encoding of multiple sources into the representation learning process of the defect report and the source code file, thereby constructing a more comprehensive and accurate representation model, significantly improving the performance and efficiency of defect localization. This solves the key problem in related technologies, that is, the inability to fully exploit and utilize multi-source information, resulting in low positioning accuracy, and also the lack of analysis of the impact of multi-source information on positioning performance and the lack of effective strategies.

[0044] Specifically, Figure 1 The present invention provides a flowchart of a method for locating software defects based on multiple views according to an embodiment of the present application.

[0045] like Figure 1 As shown, the software defect localization method based on multiple views includes the following steps:

[0046] In step S101, various relationship data between defect reports and source code files in a software project are extracted, and representation learning of the multi-source relationship between defect reports and source code files is performed based on graph neural networks and contrastive learning techniques to obtain representations of defect reports and source code files.

[0047] As a possible implementation method, the embodiment of the present application can extract various relationship data between defect reports and source code files from the software project, and construct the repair history relationship between the defect report and the source code file, the similarity relationship between the defect reports, and the co-citation relationship between the source code files into different views respectively. Then, the embodiment of the present application uses a graph neural network to perform representation learning on the nodes in each view, so as to encode the repair history relationship, similarity relationship and co-citation relationship into the representation of the defect report and the source code file, and obtain the defect report feature representation of the defect report and the source code file feature representation of the source code file.

[0048] Optionally, in one embodiment of the present application, multiple relationship data between defect reports and source code files in a software project are extracted, and the multi-source relationship between the defect reports and source code files is characterized and learned based on graph neural networks and contrastive learning techniques to obtain representations of the defect reports and source code files, including: based on the multiple relationship data between the defect reports and source code files, the repair history data between the defect reports and the source code files, the similarity data between the defect reports and the co-citation data between the source code files are extracted, and they are constructed into different views respectively, wherein the views include historical interaction views, defect report similarity views and source code co-citation views; historical interaction views constructed based on the repair history data, and the historical interaction views are characterized and learned using graph neural networks to obtain a first defect report representation matrix of defect reports and a first source code file representation matrix of source code files; defect report similarity views constructed based on similarity data, and the defect report similarity views are characterized and learned using graph neural networks to obtain a second defect report representation matrix of defect reports; source code co-citation views constructed based on co-citation data, and the source code co-citation views are characterized and learned using graph neural networks to obtain a second source code file representation matrix of source code files.

[0049] In some embodiments, the historical interaction view of the present application embodiment can be defined as a weighted bipartite graph G R-C =(V R-C ,E R-C ), where node v i (v i ∈V R-c ) represents a defect report received during the software project life cycle or a class file in the software system. If the defect report v r The source code file that needs to be repaired is v c , then there is an edge e between them rc (e rc =( <v r ,v c >∈E R-c). Further, in the embodiment of the present application, the weight between two nodes can be, but is not limited to, expressed as:

[0050] a rc (v r ,v c )=tex_sim(v r ,v c ),

[0051] Among them, tex_sim(v r ,v c ) is used to calculate the defect report v r and source code file v c The text similarity score between .

[0052] In addition, it should be noted that the embodiment of the present application can use the CodeBERT model to convert the defect report and the source code file into high-dimensional vectors respectively, and use the cosine similarity to calculate the distance between the two vectors as the weight between the two nodes.

[0053] For example, Figure 2 As shown in (a), the embodiment of the present application obtains a historical interaction view based on a weighted bipartite graph.

[0054] Furthermore, in the historical interaction view of the embodiment of the present application, the node set includes a set of defect reports and a set of source code files Where m and n represent the number of defect reports and source code files, respectively. The initial features of all nodes in the historical interaction view use uniformly distributed random initialization values ​​as the input of the graph neural network. For any defect report v r , its neighbor set N(v r ) is defined as the set of source code files in C that are connected to it by edges, that is, N(v r )={v c ∈C|(v r ,v c )∈E R-C}. Similarly, for any source code file v c , its neighbor set N(v c ) is the set of defect reports in R that are connected to it, that is, N(v c )={v r ∈R|(v r ,v c )∈E R-CUsing the GAT (Graph Attention Networks) model, through a multi-layer iterative process, each node aggregates the feature information of its neighboring nodes and merges it with the representation vector of its previous layer, gradually updating the representation until the last layer, and outputs the updated defect report representation matrix, i.e., the first defect report representation matrix and the updated source code file matrix, the first source code file representation matrix Where d is the dimension of the feature vector.

[0055] In some embodiments, the defect report similarity view of the present application embodiment can be defined as a weighted homogeneous graph G R-R =(V R-R ,E R-R ), where the node Represents a defect report. If two defect reports and There are common source code files to be repaired, then there is a certain correlation between them, that is, there is a connecting edge Further, in the embodiment of the present application, the weight between two nodes can be expressed as, but not limited to:

[0056]

[0057] in, Used to calculate two defect reports and The text similarity score between .

[0058] For example, Figure 2 (b) shows the defect report of the embodiment of the present application. and (or and ) have a certain degree of similarity (i.e. Figure 2 (b) because there are files with the same defects that have been repaired. ( and The defect files that are repaired together are ). Then, the embodiment of the present application constructs all similar relationships between defect reports in this way to form a defect report similarity view. Among them, the weight between two nodes The calculation formula is shown above.

[0059] Furthermore, in the defect report similarity view of the embodiment of the present application, the node only includes the defect report R, and any defect report v r The neighbor set of r )={ur ∈R|(v r ,u r )∈E R-R The GAT model is used to learn the similarities between defect reports, and finally the updated defect report representation matrix is ​​output, that is, the second defect report representation matrix

[0060] In some embodiments, the source code co-citation view of the present application embodiment can be defined as a weighted homogeneous graph G C-C =(V C-C ,E C-C ), where the node Represents source code files. If two source code files and If they are fixed by the same bug report at the same time, there is a certain correlation between them, that is, there is a connecting edge Furthermore, in the embodiment of the present application, the weight between two nodes may be, but is not limited to:

[0061]

[0062] in, Used to count two source code files and The more co-citations there are, the greater the correlation between the two documents.

[0063] For example, Figure 2 (b) shows that the present application embodiment provides a defect report Its related defect file is and Therefore, there is a common reference relationship between them (i.e. Figure 2 (b) is shown by the long dashed line). Then, the embodiment of the present application constructs all the co-citation relationships between source code files in this way to form a source code co-citation view. The calculation formula is shown above.

[0064] Furthermore, in the source code co-citation view of the embodiment of the present application, the node only includes the source code file C, and any source code file v c The neighbor set of c )={u c ∈C|(v c ,u c )∈E C-CThe GAT model is also used to learn the co-citation relationship between source code files, and finally outputs the updated source code file representation matrix, that is, the second source code file representation matrix

[0065] Optionally, in one embodiment of the present application, a variety of relationship data between defect reports and source code files in a software project is extracted, and the multi-source relationship between defect reports and source code files is characterized and learned based on graph neural networks and contrastive learning techniques to obtain representations of defect reports and source code files, and also includes: based on the first defect report representation matrix, the second defect report representation matrix, the first source code file representation matrix and the second source code file representation matrix, using the objective function to calculate the matching score between the defect report and the source code file; information interaction is performed on the first defect report representation matrix and the second defect report representation matrix to obtain the defect report representation distance of the same sample and the defect report representation distance of different samples; information interaction is performed on the first source code file representation matrix and the second source code file representation matrix to obtain the source code file representation distance of the same sample and the source code file representation distance of different samples; combined with the matching score, the defect report representation distance and the source code file representation distance, the first defect report representation matrix, the second defect report representation matrix, the first source code file representation matrix and the second source code file representation matrix are optimized by combining contrastive learning techniques and multi-task strategies, and the optimized representation matrix is ​​used as the final feature of the defect report and the source code file, which is used for subsequent calculation of similarity ranking. Among them, the calculation formula of the matching score can be but is not limited to:

[0066]

[0067] Among them, z r and z c Defect report v r and source code file v c The representation vector of .

[0068] The objective function of the matching score can be, but is not limited to:

[0069]

[0070] in, represents all positive sample pairs (i.e., actually associated defect reports and source code file pairs), and |C| is the total number of candidate source code files.

[0071] The objective function of the comparison function can be but is not limited to:

[0072]

[0073] in, and represents the positive sample pairs in different views, and is a negative sample pair, It is used to calculate the cosine similarity of two representation vectors, |R| and |C| are the number of defect reports and source code files respectively, and τ is the temperature hyperparameter of contrastive learning.

[0074] It is understandable that the embodiments of the present application can use contrastive learning to strengthen the sharing and fusion of information between different views, and adopt a multi-task optimization strategy to simultaneously improve the accuracy of defect location and the effectiveness of information sharing between views, and the content thereof can be:

[0075] In some embodiments, the embodiments of the present application focus on the defect location task, and calculate the matching score between the first defect report representation matrix and the first source code file representation matrix in the historical interaction view, wherein the calculation formula of the matching score can be but is not limited to:

[0076]

[0077] Among them, z r and z c Defect report v r and source code file v c The representation vector of .

[0078] Furthermore, in some embodiments, the embodiments of the present application may regard the defect location task as a sorting problem, and adopt a cross entropy loss function to train the model, aiming to maximize the score difference between positive samples and negative samples. The definition of the objective function may be, but is not limited to, as follows:

[0079]

[0080] in, represents all positive sample pairs (i.e., actually associated defect reports and source code file pairs), and |C| is the total number of candidate source code files.

[0081] In some embodiments, the embodiments of the present application can perform cross-view contrast learning to enhance information sharing. It can be understood that the embodiments of the present application can introduce a contrast learning mechanism to promote information sharing between these views in view of the different views existing in different representation spaces. Specifically, for defect reports, the first defect report representation matrix in the historical interaction view is Second defect report representation matrix in a similar view to the defect report Information interaction is performed to learn a more discriminative representation by maximizing the mutual information between the two matrices. Similarly, the same information sharing process is performed for source code files. Contrastive learning optimizes the model by comparing the representation distance of the same sample (positive sample) with that of different samples (negative samples). Among them, the objective function of the contrastive learning in the embodiment of the present application can be, but is not limited to,:

[0082]

[0083] in, and represents the positive sample pairs in different views, and is a negative sample pair, It is used to calculate the cosine similarity of two representation vectors, |R| and |C| are the number of defect reports and source code files, respectively, and τ is the temperature hyperparameter of contrastive learning, which is set to 0.1.

[0084] It can be understood that the embodiments of the present application provide a defect report. The first defect report representation matrix in the historical interaction view and the second defect report characterization matrix in the defect report view Mapped to the same space through two corresponding MLPs (Multi-Layer Perceptron Mapping) On the other hand, the defect report Another random defect report Pair and Get the mapped representation At this time, the defect report of the embodiment of the present application Positive sample pairs The representation distance should be smaller than the negative sample pair and The distance, that is

[0085] Furthermore, the embodiment of the present application may adopt multi-task joint optimization to jointly optimize the objective functions of defect localization and contrastive learning. The overall optimization goal may be, but is not limited to:

[0086] L=L FL +λL CL ,

[0087] Among them, λ is a hyperparameter for balancing the weights of different tasks and is set to 0.01.

[0088] In step S102, based on the representations of the defect report and the source code file, the feature similarity between the defect report and the source code file is calculated, and a similarity ranking of the source code file is generated for the corresponding defect report according to the similarity.

[0089] As a possible implementation method, the embodiment of the present application calculates the similarity between each defect report and the source code file using cosine similarity based on the defect report feature representation and the source code file feature representation, and then generates a similarity ranking between the defect report and the source code file.

[0090] In step S103, based on the similarity sorting, source code files with similarity greater than a preset similarity are selected, and the defect location information in the software project is determined using the selected source code files.

[0091] In the actual implementation process, the embodiment of the present application can be sorted according to the similarity, and the source code files with similarity greater than a certain similarity can be used to determine the defect location information in the software project. Among them, the certain similarity can be set by technicians in this field according to actual conditions, and this application does not make any specific restrictions.

[0092] Exemplarily, the embodiments of the present application can sort by similarity and recommend the top-N source code files with similarity greater than a certain similarity, i.e., the highest matching degree, to the defect report, to assist developers in quickly locating and fixing defects.

[0093] For example, Figure 3 As shown, in the embodiment of the present application, after the feature extraction of the defect report and the source code file in the previous steps, the defect report feature representation and the source code file feature representation can be obtained respectively, and then the cosine similarity is used to calculate the similarity score of the features between each defect report and the source code file, and sort them accordingly, and select the Top-N source code files with the highest matching degree with the defect report as recommendations, so as to assist developers to quickly locate and repair software defects.

[0094] The working principle of the software defect localization method based on multiple views proposed in the embodiment of the present application is explained below in conjunction with a specific embodiment.

[0095] in, Figure 4 The present invention is a flowchart of the working principle of a software defect localization method based on multiple views provided according to an embodiment of the present application.

[0096] Step S401: Input layer.

[0097] Among them, the embodiment of the present application can extract various relationship data between defect reports and source code files from the software project, and construct the repair history relationship between defect reports and source code files, the similarity relationship between defect reports, and the co-citation relationship between source code files into different views, such as a historical interaction view constructed based on repair history data, a defect report similarity view constructed based on similarity data, and a source code co-citation view constructed based on co-citation data.

[0098] Step S402: GNN (Graph Neural Network) embedding layer.

[0099] Among them, the embodiment of the present application can obtain a first defect report representation matrix of the defect report based on the historical interaction view and the first source code file representation matrix of the source code file Obtaining a second defect report representation matrix for defect reports based on defect report similarity views Obtaining a second source code file representation matrix of source code files based on the source code co-citation view

[0100] Step S403: Joint learning layer.

[0101] Among them, the embodiment of the present application can strengthen the encoding of shared information between different views through contrastive learning technology, and adopt a multi-task optimization strategy to simultaneously improve the accuracy of defect positioning and the effectiveness of information sharing between views. Among them, the embodiment of the present application uses contrastive learning technology and multi-task joint optimization to include the following steps:

[0102] First, the embodiment of the present application performs ranking learning and optimization of the defect location task. It can be understood that the embodiment of the present application focuses on the defect location task and calculates the matching score of the first defect report representation matrix and the first source code file representation matrix in the historical interaction view, wherein the calculation formula of the matching score is as shown above.

[0103] Furthermore, the embodiment of the present application can regard the defect localization task as a sorting problem, and use the cross entropy loss function to train the model, aiming to maximize the score difference between positive samples and negative samples. The definition of its objective function is shown above.

[0104] Secondly, the embodiment of the present application performs cross-view contrast learning to enhance information sharing. It can be understood that the embodiment of the present application can introduce a contrast learning mechanism to promote information sharing between these views in view of the fact that different views exist in different representation spaces.

[0105] Specifically, for a defect report, the first defect report representation matrix in the historical interaction view is Second defect report representation matrix in a similar view to the defect report Information exchange is performed to learn more discriminative representations by maximizing the mutual information between the two matrices. Similarly, the same information sharing process is performed for source code files. Contrastive learning optimizes the model by comparing the representation distance of the same sample (positive sample) with different samples (negative samples). On the one hand, for defect reports The first defect report representation matrix in the historical interaction view and the second defect report characterization matrix in the defect report view Mapped to the same space by two corresponding MLPs On the other hand, the defect report Another random defect report Pair and Get the mapped representation At this time, the defect report of the embodiment of the present application Positive sample pairs The representation distance should be smaller than the negative sample pair and The distance, that is

[0106] Again, the embodiment of the present application uses multi-task joint optimization. It can be understood that the embodiment of the present application can use multi-task joint optimization to jointly optimize the objective functions of defect localization and contrastive learning, and the overall optimization goal is as shown above.

[0107] Finally, the embodiment of the present application performs similarity sorting. It can be understood that the embodiment of the present application can obtain the defect report feature representation and the source code file feature representation, use the cosine similarity to calculate the similarity between each defect report and the source code file, and then generate a similarity sorting of the defect report and the source code file, and recommend the top-N source code files with the highest matching degree to the defect report according to the similarity sorting, so as to assist developers to quickly locate and fix defects.

[0108] According to the software defect location method based on multiple views proposed in the embodiment of the present application, a multi-source relationship view can be constructed based on the defect report and source code file in the software project, and a graph neural network is used to perform in-depth representation learning on the nodes in each view, so that the three relationships are displayed and encoded into the representation of the defect report and the source code file, and then the similarity between the defect report feature representation and the source code file feature representation is calculated by using contrast learning technology and multi-task joint optimization, and the source code file with a similarity greater than a certain similarity is selected to determine the defect location information in the software project. In the case of a lack of defect report text information, the insufficiency of text information is effectively compensated by in-depth mining and efficient use of multi-source information, and contrast learning technology and multi-task joint optimization are used to automatically integrate information encoding from multiple sources into the representation learning process of defect reports and source code files, thereby constructing a more comprehensive and accurate representation model, significantly improving the performance and efficiency of defect location. As a result, the key path of the related technology that cannot fully mine and utilize multi-source information, resulting in low positioning accuracy, and the lack of analysis of the impact of multi-source information on positioning performance and the lack of effective strategies are solved.

[0109] Next, a software defect location device based on multiple views proposed according to an embodiment of the present application is described with reference to the accompanying drawings.

[0110] Figure 5 A block diagram of a software defect location device based on multiple views provided according to an embodiment of the present application.

[0111] like Figure 5 As shown, the software defect location device 10 based on multiple views includes: a learning module 100 , a sorting module 200 and a determining module 300 .

[0112] Among them, the learning module 100 is used to extract various relationship data between defect reports and source code files in the software project, and to characterize and learn the multi-source relationship between defect reports and source code files based on graph neural networks and contrastive learning technology to obtain the representation of defect reports and source code files.

[0113] The sorting module 200 is used to calculate the feature similarity between the defect report and the source code file based on the representations of the defect report and the source code file, and generate a similarity sorting of the source code file for the corresponding defect report according to the similarity.

[0114] The determination module 300 is used to select source code files with similarities greater than a preset similarity based on similarity sorting, and determine defect location information in the software project using the selected source code files.

[0115] Optionally, in one embodiment of the present application, the learning module 100 includes: an acquisition unit, a first learning unit, a second learning unit and a third learning unit.

[0116] Among them, the acquisition unit is used to extract the repair history data between the defect report and the source code file, the similarity data between the defect reports and the co-citation data between the source code files based on the various relationship data between the defect report and the source code file, and construct them into different views respectively, wherein the view can include but is not limited to a historical interaction view, a defect report similarity view and a source code co-citation view.

[0117] The first learning unit is used to construct a historical interaction view based on the repair history data, and use a graph neural network to perform representation learning on the historical interaction view to obtain a first defect report representation matrix of the defect report and a first source code file representation matrix of the source code file.

[0118] The second learning unit is used to construct a source code co-citation view based on the co-citation data, and use a graph neural network to perform representation learning on similar views of the defect report to obtain a second defect report representation matrix of the defect report.

[0119] The third learning unit is used to construct a source code co-citation view based on the co-citation data, and use a graph neural network to perform representation learning on the source code co-citation view to obtain a second source code file representation matrix of the source code file.

[0120] Optionally, in one embodiment of the present application, the learning module 100 further includes: a matching unit, a first generating unit, a second generating unit and a third generating unit.

[0121] The matching unit is used to calculate the matching score between the defect report and the source code file using an objective function based on the first defect report characterization matrix, the second defect report characterization matrix, the first source code file characterization matrix and the second source code file characterization matrix.

[0122] The first generating unit is used to perform information exchange on the first defect report characterization matrix and the second defect report characterization matrix to obtain defect report characterization distances of the same sample and defect report characterization distances of different samples.

[0123] The second generating unit is used to perform information exchange on the first source code file representation matrix and the second source code file representation matrix to obtain source code file representation distances of the same sample and source code file representation distances of different samples.

[0124] The third generation unit is used to combine the matching score, the defect report representation distance and the source code file representation distance, and jointly optimize the first defect report representation matrix, the second defect report representation matrix, the first source code file representation matrix and the second source code file representation matrix with the comparison function and the multi-task strategy, and use the optimized representation matrix as the final feature of the defect report and the source code file for subsequent calculation of similarity ranking.

[0125] Optionally, in one embodiment of the present application, the calculation formula of the matching score may be, but is not limited to,:

[0126]

[0127] Among them, z r and z c Defect report v r and source code file v c The representation vector of .

[0128] The objective function of the matching score can be, but is not limited to:

[0129]

[0130] in, represents all positive sample pairs (i.e., actually associated defect reports and source code file pairs), and |C| is the total number of candidate source code files.

[0131] Optionally, in one embodiment of the present application, the objective function of the comparison function may be, but is not limited to:

[0132]

[0133] in, and represents the positive sample pairs in different views, and is a negative sample pair, It is used to calculate the cosine similarity of two representation vectors, |R| and |C| are the number of defect reports and source code files respectively, and τ is the temperature hyperparameter of contrastive learning.

[0134] It should be noted that the above explanation of the embodiment of the software defect localization method based on multiple views is also applicable to the software defect localization device based on multiple views of this embodiment, which will not be repeated here.

[0135] According to the multi-view software defect location device proposed in the embodiment of the present application, a multi-source relationship view can be constructed according to the defect report and source code file in the software project, and a graph neural network is used to perform in-depth representation learning on the nodes in each view, so that the three relationships are displayed and encoded into the representation of the defect report and the source code file, and then the similarity between the defect report feature representation and the source code file feature representation is calculated by using contrast learning technology and multi-task joint optimization, and the source code file with a similarity greater than a certain similarity is selected to determine the defect location information in the software project. In the case of a lack of defect report text information, the insufficiency of text information is effectively compensated by in-depth mining and efficient use of multi-source information, and contrast learning technology and multi-task joint optimization are used to automatically integrate information encoding from multiple sources into the representation learning process of defect reports and source code files, thereby constructing a more comprehensive and accurate representation model, significantly improving the performance and efficiency of defect location. Thus, the key path of the related technology that cannot fully mine and utilize multi-source information, resulting in low positioning accuracy, and the problem that there is no analysis of the impact of multi-source information on positioning performance and lack of effective strategies is solved.

[0136] Figure 6 This is a schematic diagram of the structure of an electronic device provided according to an embodiment of the present application. The electronic device may include:

[0137] A memory 601 , a processor 602 , and a computer program stored in the memory 601 and executable on the processor 602 .

[0138] When the processor 602 executes the program, the software defect localization method based on multiple views provided in the above embodiment is implemented.

[0139] Furthermore, the electronic device further comprises:

[0140] The communication interface 603 is used for communication between the memory 601 and the processor 602 .

[0141] The memory 601 is used to store computer programs that can be executed on the processor 602 .

[0142] The memory 601 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0143] If the memory 601, the processor 602 and the communication interface 603 are implemented independently, the communication interface 603, the memory 601 and the processor 602 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0144] Optionally, in a specific implementation, if the memory 601, the processor 602 and the communication interface 603 are integrated on a chip, the memory 601, the processor 602 and the communication interface 603 can communicate with each other through an internal interface.

[0145] The processor 602 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.

[0146] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned multi-view-based software defect localization method.

[0147] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned multi-view-based software defect localization method when executed.

[0148] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0149] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0150] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0151] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or N wirings (electronic devices), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways as necessary and then storing it in a computer memory.

[0152] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented by hardware, as in another embodiment, it can be implemented by any one or a combination of multiple of the following technologies known in the art: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0153] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0154] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0155] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A software defect location method based on multiple views, characterized in that: The following steps are involved: Extracting multiple relationship data between defect reports and source code files in a software project, and performing representation learning on the multi-source relationship between the defect reports and the source code files based on graph neural networks and contrastive learning techniques to obtain representations of the defect reports and source code files; Based on the representations of the defect report and the source code file, calculating the feature similarity between the defect report and the source code file, and generating a similarity ranking of the source code file for the corresponding defect report according to the similarity; Based on the similarity ranking, source code files with similarities greater than a preset similarity are selected, and defect location information in the software project is determined using the selected source code files.

2. The method according to claim 1, characterized in that Extract multiple relationship data between defect reports and source code files in the software project, and perform characterization learning on the multi-source relationship between the defect reports and the source code files based on graph neural network and contrastive learning technology to obtain characterizations of defect reports and source code files, including: Based on the multiple relationship data between the defect report and the source code file, the repair history data between the defect report and the source code file, the similarity data between the defect reports and the co-citation data between the source code files are extracted, and they are constructed into different views respectively, wherein the views include a history interaction view, a defect report similarity view and a source code co-citation view; A historical interaction view is constructed based on the repair history data, and representation learning is performed on the historical interaction view using the graph neural network to obtain a first defect report representation matrix of the defect report and a first source code file representation matrix of the source code file; A similar view of the defect report is constructed based on the similar data, and the similar view of the defect report is characterized by learning using the graph neural network to obtain a second defect report representation matrix of the defect report; A source code co-citation view is constructed based on the co-citation data, and representation learning is performed on the source code co-citation view using the graph neural network to obtain a second source code file representation matrix of the source code file.

3. The method according to claim 2, characterized in that Extracting multiple relationship data between defect reports and source code files in the software project, and performing characterization learning on the multi-source relationship between the defect reports and the source code files based on graph neural network and contrastive learning technology to obtain characterizations of the defect reports and source code files, further comprising: Calculating a matching score between the defect report and the source code file using an objective function based on the first defect report characterization matrix, the second defect report characterization matrix, the first source code file characterization matrix, and the second source code file characterization matrix; Performing information exchange on the first defect report characterization matrix and the second defect report characterization matrix to obtain defect report characterization distances of the same sample and defect report characterization distances of different samples; Performing information exchange on the first source code file representation matrix and the second source code file representation matrix to obtain source code file representation distances of the same sample and source code file representation distances of different samples; The matching score, the defect report representation distance and the source code file representation distance are combined, and the contrastive learning technology and the multi-task strategy are combined to optimize the first defect report representation matrix, the second defect report representation matrix, the first source code file representation matrix and the second source code file representation matrix, and the optimized representation matrix is ​​used as the final feature of the defect report and the source code file for subsequent calculation of similarity ranking.

4. The method according to claim 3, characterized in that in, The calculation formula of the matching score is: Among them, z r and z c Defect report v r and source code file v c The representation vector of The objective function of the matching score is: in, represents all positive sample pairs (i.e., actually associated defect reports and source code file pairs), and |C| is the total number of candidate source code files.

5. The method according to claim 3, characterized in that: The objective function of the comparison function is: in, and represents the positive sample pairs in different views, and is a negative sample pair, It is used to calculate the cosine similarity of two representation vectors, |R| and |C| are the number of defect reports and source code files respectively, and τ is the temperature hyperparameter of contrastive learning.

6. A software defect location device based on multiple views, characterized in that: include: A learning module, used to extract multiple relationship data between defect reports and source code files in a software project, and to perform characterization learning on the multi-source relationship between the defect reports and the source code files based on graph neural networks and contrastive learning techniques to obtain characterizations of the defect reports and source code files; A sorting module, configured to calculate feature similarity between the defect report and the source code file based on representations of the defect report and the source code file, and generate a similarity sorting of the source code file for the corresponding defect report according to the similarity; The determination module is used to select source code files with similarities greater than a preset similarity based on the similarity sorting, and determine defect location information in the software project using the selected source code files.

7. The device according to claim 6, characterized in that The learning module includes: an acquisition unit, configured to extract, based on the multiple relationship data between the defect report and the source code file, the repair history data between the defect report and the source code file, the similarity data between the defect reports and the co-citation data between the source code files, and construct them into different views respectively, wherein the views include a history interaction view, a defect report similarity view and a source code co-citation view; A first learning unit is configured to construct a historical interaction view based on the repair history data, and perform representation learning on the historical interaction view using the graph neural network to obtain a first defect report representation matrix of the defect report and a first source code file representation matrix of the source code file; A second learning unit is used for constructing similar views of defect reports based on the similar data, and performing representation learning on the similar views of defect reports using the graph neural network to obtain a second defect report representation matrix of the defect report; The third learning unit is used to construct a source code co-citation view based on the co-citation data, and use a graph neural network to perform representation learning on the source code co-citation view to obtain a second source code file representation matrix of the source code file.

8. The device according to claim 7, characterized in that The learning module also includes: a matching unit, configured to calculate a matching score between the defect report and the source code file using an objective function based on the first defect report representation matrix, the second defect report representation matrix, the first source code file representation matrix, and the second source code file representation matrix; A first generating unit, configured to perform information exchange on the first defect report characterization matrix and the second defect report characterization matrix to obtain defect report characterization distances of the same sample and defect report characterization distances of different samples; a second generating unit, configured to perform information exchange on the first source code file representation matrix and the second source code file representation matrix to obtain source code file representation distances of the same sample and source code file representation distances of different samples; a third generating unit, configured to combine the matching score, the defect report representation distance, and the source code file representation distance, and optimize the first defect report representation matrix, the second defect report representation matrix, the first source code file representation matrix, and the second source code file representation matrix in combination with the contrastive learning technique and the multi-task strategy, and use the optimized representation matrix as the final feature of the defect report and the source code file for subsequent calculation of similarity ranking.

9. The device according to claim 8, characterized in that in, The calculation formula of the matching score is: Among them, z r and z c Defect report v r and source code file v c The representation vector of The objective function of the matching score is: in, represents all positive sample pairs (i.e., actually associated defect reports and source code file pairs), and |C| is the total number of candidate source code files.

10. The device according to claim 8, characterized in that The objective function of the comparison function is: in, and represents the positive sample pairs in different views, and is a negative sample pair, It is used to calculate the cosine similarity of two representation vectors, |R| and |C| are the number of defect reports and source code files respectively, and τ is the temperature hyperparameter of contrastive learning.

11. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the software defect localization method based on multiple views as described in any one of claims 1 to 5.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the software defect localization method based on multiple views as described in any one of claims 1 to 5.

13. A computer program product, characterized in that It comprises a computer program, which, when executed, is used to implement the software defect localization method based on multiple views as described in any one of claims 1 to 5.

Citation Information

Cited By

  • Software defect information fusion method and system based on multi-source data

    CN120632770A

  • A software defect information fusion method and system based on multi-source data

    CN120632770B