A fine-grained software defect location method based on blockchain traceability and method level

Through the method-level fine-grained software defect positioning method based on blockchain traceability, the problem of inaccurate defect positioning in the existing technology is solved, method-level defect positioning is realized, cost and complexity are reduced, and security and efficiency are improved.

CN115525552BActive Publication Date: 2025-08-19GUANGDONG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211156898.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-22
Publication Date
2025-08-19
Estimated Expiration
2042-09-22

AI Technical Summary

Technical Problem

Most existing software defect positioning methods position defects at the file level and cannot be accurately positioned to the specific method location, resulting in long defect repair time, high cost and low user satisfaction, complex data storage and management of defect positioning technology and lack of security and reliability.

Method used

The fine-grained software defect positioning method based on blockchain traceability and method level is adopted to store and manage the source code method body through blockchain technology, and combine the cosine similarity between IRBL technology and Skip-gram model to calculate the method level defect positioning, and improve positioning efficiency and accuracy through blockchain traceability technology.

Benefits of technology

The method level refinement of software defect positioning is realized, which reduces the cost and difficulty of defect positioning, provides unified data storage and management, improves the security and reliability of defect positioning, and reduces the time and maintenance costs of defect repair.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115525552B_ABST
    Figure CN115525552B_ABST
Patent Text Reader

Abstract

The present invention discloses a fine-grained software defect location method based on blockchain traceability and method level, comprising: extracting method bodies from historical defect reports and source code files in the defect reports, calculating cosine similarity and sorting them; expanding the sorted method bodies; saving all method bodies extracted from the historical defect reports and source code files in the defect reports on a blockchain system block; submitting a new defect report; constructing a query statement after extracting and expanding the method bodies of the new defect report; determining whether there are unsearched blocks in the blockchain system, or constructing a query statement to continue searching, or calculating cosine similarity and ranking and performing defect location; determining whether the software defect location is successful, or performing information processing and packaging and uploading, or constructing a query statement and re-querying until the location is successful. The present invention refines software defect location to the method level, solves the problem of sparse terms in the method body, and uses blockchain technology to provide more effective management and implementation of fine-grained software defect location technology based on the method level in engineering applications and other aspects, reducing the implementation cost and difficulty of the defect location technology, providing unified data storage and management, and having certain security and reliability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of software defect location, and specifically relates to a fine-grained software defect location method based on blockchain traceability and method level. Background Art

[0002] A software defect is an error, fault, or flaw in a computer program or system that causes it to behave incorrectly or unexpectedly, potentially resulting in the software product failing to meet user needs to some extent. During software project development, defect tracking systems such as Bugzilla and JIRA are often used to manage defects. These systems manage the entire lifecycle of software defects, including the submission, confirmation, assignment, repair, and closure of defect reports. A large software project receives a large number of defect reports submitted by users every day, and fixing these defects consumes a significant amount of time and effort on the part of defect repair personnel.

[0003] Once a software defect report is confirmed by a defect manager and assigned to a developer for repair, the assigned defect fixer must locate the defect—that is, identify the code snippet that needs to be modified to fix the defect—and then perform the repair. For a software maintainer, fixing a defect requires a thorough understanding of the relevant information. Therefore, they must read extensive software source code to locate the defect. With a large number of defect reports and source code files, defect location is a time-consuming and labor-intensive task. If a defect remains unlocated, repair time increases, leading to higher maintenance costs for the corresponding software project and reduced user satisfaction with the product. Therefore, an automated technology to assist defect fixers in defect location could significantly reduce the time spent on defect repair and software maintenance costs.

[0004] Software defect location methods are generally divided into static location methods and dynamic location methods. Static defect location relies on software defect reports, source code, and static information of the development process to locate software defects. Dynamic defect location relies on technologies such as instrumentation, execution monitoring, and formal methods to track the software runtime state to determine where software defects may occur. Most of the current defect location methods, whether static or dynamic, locate the defect at the file level. In other words, the existing defect location technology assists defect repair personnel in finding certain source code files that cause defects at a large granularity. However, the specific location in the source code file (that is, which method in the file the defect occurs) still requires further modification and debugging by software maintenance personnel to determine. Summary of the Invention

[0005] In order to solve the background technical problems, the present invention provides a fine-grained software defect localization method based on blockchain traceability and method level. The method-level fine-grained software defect localization of this method locates software defects at the method level, solves the problem of sparse terms in the method body, and at the same time utilizes blockchain technology to enable the fine-grained software defect localization technology based on the method level to provide more effective management and implementation in engineering applications and other aspects, reduce the implementation cost and difficulty of the defect localization technology, provide unified data storage and management, and have certain security and reliability.

[0006] From a data storage perspective, blockchain is a unit of data storage. Blockchain technology is a decentralized shared ledger that combines data blocks in a chronological chain into a specific data structure, cryptographically guaranteed to be tamper-proof and unforgeable. It can securely store simple, sequential, and internally verifiable data. In a blockchain, data is stored in linked data blocks. Each block is divided into a header and a body. The header contains the hash value and timestamp of the previous block, while the body contains a series of transaction records digitally signed by the transacting parties. New blocks are appended to the previous block in chronological order, gradually forming a chain with a time dimension, which records all transactions in a distributed ledger, thus ensuring the authenticity and traceability of the data.

[0007] Currently, most large-scale software project development and maintenance are carried out using multiple systems. Existing information retrieval-based software defect localization technology uses multiple features in these systems to improve the effectiveness of the algorithm, which makes the data storage and management of software defect localization technology complex and lacks security and reliability.

[0008] This paper proposes a fine-grained software defect localization technology based on blockchain traceability and method level. First, all source files are processed and uploaded to the block of the blockchain system as query objects. The current new defect report (including the summary content, discription content, and comment content in the defect report) is processed, and the blockchain smart contract technology is used to construct query statements and query reconstruction.

[0009] The present invention combines blockchain traceability with method-level fine-grained software defect localization technology, combining IRBL technology with blockchain traceability technology. IRBL technology is reduced to a method-level fine-grained software defect localization technology. The Skip-gram model in the document vector representation method based on word2vec word vectors is used to vectorize the source code method body content in historical defect reports. Specifically, this software defect localization method includes the following steps:

[0010] S1: Extract the method bodies of the historical defect reports and the source code files in the defect reports, calculate the cosine similarity and sort them. Specific implementation steps:

[0011] S101: Parsing the source code file using the abstract syntax tree (AST) and extracting the method body as mi, where 1<=i<=n, and n is the total number of source code method bodies.

[0012] S102: Each method body is preprocessed, including separating English words from the method name according to the Java programming camel case naming rule, removing stop words, removing Java reserved keywords, and removing various symbols to obtain the preprocessed method m′ i ;

[0013] S103: Report all defects i and method m′ i Through Skip-gram model training, we get m′ i N corresponding to each word in is the word vector w, w=(v1,v2,...,v N ), where v N Represents the value in the Nth dimension; the minimum frequency of the Skip-gram model is set to 1, the number of windows is set to 5, and the value of dimension N is set to 300;

[0014] S104: Calculate the tfidf value of each word vector, {t1, t2, ..., t m} indicates that from the method body m′ i The extracted terms, m represents the total number of stems, for a single term t i , its tfidf calculation formula is:

[0015] tfidf(t i )=tf(t i )×idf(t i )

[0016] The vocabulary frequency tf(t i ), inverse document frequency idf(t i )The formula is as follows:

[0017]

[0018] Refers to method m j The stem t in i frequency, refers to the stem t i The number of methods, |M| represents the sum of the number of methods in all source files; for each method M j , where 1≤j≤|M|, and its representation after processing by the word vector representation set tfidf is:

[0019]

[0020] in, Indicates this item t i word vectors;

[0021] S105: Take the kth method, where 1≤k≤|M| As a query, other methods Among them, i≠k is regarded as the query object; by calculating and The cosine similarity of Among them, i≠k is sorted, thus obtaining a sequence of size |M|-1, and by sorting the similar methods of each method in all |M| methods, |M| sequences of size |M|-1 are obtained; method and methods The angle cosine similarity is S k,1 ,S k,2 ,...,S k,|M|-1 , and the corresponding formula is:

[0022]

[0023] S2: Expand the sorted method body;

[0024] S3: Save the historical defect report and all method bodies extracted from the source code file in the defect report on the block chain system;

[0025] S4: Submit the current new defect report;

[0026] S5: After extracting and expanding the method body of the current new defect report, a query statement is constructed;

[0027] S6: Determine whether there are any unsearched blocks in the blockchain system. If so, construct a query statement and select n blocks for retrieval in the blockchain system, where n is a natural number. If there are no unsearched blocks, calculate the cosine similarity and rank them. Select the top-ranked method to locate the software defect.

[0028] S7: Determine whether the software defect location is successful. If the software defect location is successful, the defect report and the corresponding modified file information are extracted and expanded through the method body, packaged into a new block, and uploaded to the blockchain system. If the software defect location is unsuccessful, a query statement is constructed and the query is performed again.

[0029] Preferably, the specific implementation process of step S2 is:

[0030] The method obtained by S1 extraction Among them, 1≤k≤|M|, the calculation method The average value of the cosine similarity between the angle and the other |M|-1 methods θ k , which is calculated as follows:

[0031]

[0032] Comparison Method The average value of the angle cosine similarity θ k and methods and methods The cosine similarity S of the angle between k,i , if S k,i >θ k , then the vector of method i is represented by Expand to the kth method and in order to maintain the method The original vector of occupies a dominant position in the expanded method vector, and it is necessary to add a heuristic expansion rate α when the method is expanded to control the other methods. Among them, i≠k pairs The expansion effect of , the vector of the k-th method after expansion is expressed as:

[0033]

[0034] Preferably, the specific implementation process of step S3 is:

[0035] All method bodies extracted from historical defect reports and the source code files in the defect reports are saved on the blocks of the blockchain system. For the current new defect report, first searching for similar defects that have been fixed and the method bodies extracted from the modified source code files will shorten the search time and improve the efficiency and accuracy of defect location. In addition, if a source code file has been modified multiple times to fix the same defect or the same function, then this source code file is more likely to be defective.

[0036] Preferably, the step S5 includes the following specific implementation steps:

[0037] S501: For the kth new defect report k , which contains the terms The new defect report is trained through the skip-gram model, and the new defect report is br k Each term w in ki Expressed as in Represents the value in the Nth dimension;

[0038] S502: Report the defect k All word vectors in the are aggregated and the maximum value is selected as the br using the MaxPooling method on each feature dimension. k The representation vector The maximum value in this dimension, The value of the i-th dimension in is

[0039] S503: Defect Report by Calculation and the method am on the block i The cosine similarity between them is used to construct query statements and query reconstruction, and the method with the larger similarity is selected to locate software defects. The cosine similarity is calculated as:

[0040]

[0041] The model of the method body after processing.

[0042] Preferably, the software defect localization method further includes a method for evaluating the accuracy of the localization result, and the steps are as follows:

[0043] S11: Calculate the Top N Rank: This represents the ratio of the number of method bodies whose corresponding changes to the defect report appear in the top N returned results, where N = (1, 5, 10). For a given defect report, if the top N query results contain at least one method body that fixes the defect, the defect is considered to be accurately located.

[0044] S12: Calculate the Mean Average Precision (MAP): This represents the average accuracy of all defect reports after location. The MAP value reflects the single-value indicator of the defect location method's ability to accurately locate all source code that needs to be modified. The higher the ranking of the retrieved related method body, the larger the MAP value. The formula for the average precision of a single defect is:

[0045]

[0046] Where R represents the sorted set of source code method bodies that can be correctly located in a defect location, |R| represents the number of source code method bodies that are correctly located, and rank k represents the ranking of the kth correct source code method body;

[0047] The MAP formula for all defect reports is:

[0048]

[0049] Where Q is the set of defect reports, |Q| represents the number of defect reports in Q, and AvgP j represents the average precision value of the j-th defect report;

[0050] S13: Calculate the Mean Reciprocal Rank (MRR): This represents the average value of the reciprocal position of the related method body. The higher the value, the higher the accuracy of the method.

[0051] The formula for calculating the average reciprocal ranking is:

[0052]

[0053] Where Q is the set of defect reports, |Q| represents the number of defect reports in Q, and rank i Indicates the top ranking position of the method body related to the i-th defect report

[0054] Beneficial effects of the present invention:

[0055] This invention refines software defect location down to the method level, solving the problem of lexical sparsity in method bodies. It also leverages blockchain technology to enable more efficient management and implementation of fine-grained method-level software defect location technology in engineering applications, reducing the cost and difficulty of implementing defect location technology, providing unified data storage and management, and ensuring a certain level of security and reliability. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 A schematic diagram of a process flow of a method according to an embodiment of the present invention;

[0057] Figure 2 Schematic diagram of the method body extraction and expansion process in an embodiment of the present invention; DETAILED DESCRIPTION

[0058] It should be noted that, unless there is a conflict, the embodiments in this application and the features in the embodiments can be combined with each other. The present invention is further described in detail below with reference to the drawings and specific embodiments.

[0059] In the embodiments of the present invention, if there are directional indications (such as up, down, left, right, front, back, etc.), they are only used to explain the relative position relationship, movement status, etc. between the various components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0060] In addition, the terms "first," "second," and so on, used in this disclosure are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features being referred to. Therefore, features specified as "first" or "second" may explicitly or implicitly include at least one of these features.

[0061] The embodiment of the present invention mainly proposes a fine-grained software defect location method based on blockchain traceability and method level to assist software defect repair personnel in defect location. Combining IRBL technology and blockchain traceability technology, the present invention uses the Skip-gram model in the document vector representation method based on word2vec word vector to vectorize historical defect reports (including summary content, description content, comment content in the defect report) and the source code method body content in the historical defect report, and calculates the cosine similarity for sorting; obtains the extracted and sorted methods, and performs method body expansion processing on the sorted method body; saves the extracted and sorted methods in the historical defect report and the source code file of the defect report on the block of the blockchain system; for the currently newly submitted defect After the method body is extracted and processed, a query statement is constructed by calculating the cosine similarity; it is determined whether there is an unretrieved block in the blockchain system. If so, a query statement is constructed, and n blocks are selected back in the blockchain system for retrieval. If there is no unretrieved block, the cosine similarity between each newly submitted defect report extracted and expanded by the method body and the source file extracted and expanded by the method body and the defect report is calculated during the retrieval process, and ranked in descending order. According to the ranking results, the software defect fixer can check the corresponding source files one by one from the beginning of the sort to determine whether the defect location is successful. If successful, the defect report of the defect location and the corresponding modified file information are packaged into a new block after the method body extraction and expansion process, and uploaded to the blockchain system. If unsuccessful, the query statement is reconstructed and the query is repeated.

[0062] Please refer to Figures 1-2 Specifically, the embodiment of the present invention combines blockchain traceability technology and method-level fine-grained software defect location technology, including the following steps:

[0063] (1) Extract the method bodies of the historical defect reports and the source code files in the defect reports, calculate the cosine similarity and sort them;

[0064] (2) Expand the sorted method body;

[0065] (3) saving the historical defect report and all method bodies extracted from the source code file in the defect report on the block chain system;

[0066] (4) Submit a new defect report;

[0067] (5) After extracting and expanding the method body of the current new defect report, a query statement is constructed;

[0068] (6) Determine whether there are any unretrieved blocks in the blockchain system. If there are any unretrieved blocks, construct a query statement and select n blocks for retrieval by tracing back to the source in the blockchain system. If there are no unretrieved blocks, calculate the cosine similarity and rank them, and select the top-ranked method body for software defect location;

[0069] (7) Determine whether the software defect location is successful. If the software defect location is successful, the defect report of the defect location and the corresponding modified file information are extracted and expanded by the method body and packaged into a new block, and uploaded to the blockchain system. If the software defect location is unsuccessful, construct a query statement and re-query;

[0070] The process of step (1) is as follows: first, the source code file is parsed through the abstract syntax tree (AST) from the source code file, and the extracted method body is denoted as mi, where 1<=i<=n, and n is the total number of source code method bodies; then each method body is subjected to text preprocessing, including separating English words from the method name according to the Java programming camel case naming rule, removing stop words, removing Java reserved keywords, and removing various symbols,

[0071] Get the preprocessed method m′ i ;

[0072] Report all defects to i and method m′ i Through Skip-gram model training, we get m′ i N corresponding to each word in is the word vector w, w=(v1,v2,...,v N ), where v N Represents the value at dimension N. The minimum frequency of the Skip-gram model is set to 1, the number of windows is set to 5, and the value of dimension N is set to 300;

[0073] Calculate the tfidf value of each word vector, {t1,t2,...,t m} indicates that from the method body m′ i The extracted terms, m represents the total number of stems, for a single term t i , its tfidf calculation formula is:

[0074] tfidf(t i )=tf(t i )×idf(t i )

[0075] The vocabulary frequency tf(t i ), inverse document frequency idf(t i )The formula is as follows:

[0076]

[0077] Refers to method m j The stem t in i frequency, refers to the stem t i The number of methods, |M| represents the sum of the number of methods in all source files; for each method M j , where 1≤j≤|M|, and its representation after processing by the word vector representation set tfidf is:

[0078]

[0079] here, Indicates this item t i word vectors.

[0080] Take the kth method, where 1≤k≤|M| As a query, other methods Among them, i≠k is regarded as the query object. By calculating and The cosine similarity of Among them, i≠k is sorted, thereby obtaining a sequence of size |M|-1, and by sorting the similar methods of each method in all |M| methods, |M| sequences of size |M|-1 are obtained.

[0081] method and methods The angle cosine similarity is S k,1 ,S k,2 ,...,S k,|M|-1 , and the corresponding formula is:

[0082]

[0083] The process of step (2) is as follows:

[0084] Method extracted from (1) Among them, 1≤k≤|M|, the calculation method Between other |M|-1 methods (excluding ) is the average value of the cosine similarity of the angle θ k , which is calculated as follows:

[0085]

[0086] Comparison Method The average value of the angle cosine similarity θk and methods and methods The cosine similarity S of the angle between k,i , if S k,i >θ k , then the vector of method i is represented by Expand to the kth method and in order to maintain the method The original vector of occupies a dominant position in the expanded method vector, and it is necessary to add a heuristic expansion rate α when the method is expanded to control the other methods. Among them, i≠k pairs The expansion effect of , the vector of the k-th method after expansion is expressed as:

[0087]

[0088] The process of step (3) is as follows:

[0089] All method bodies extracted from historical bug reports and the source code files in those reports are stored on the blockchain system. For new bug reports, searching for similar fixed bugs and method bodies extracted from modified source code files first shortens search time and improves bug location efficiency and accuracy. Furthermore, if a source code file has been modified multiple times to fix the same bug or function, it is more likely to be defective.

[0090] The process of step (5) is as follows:

[0091] For the kth new bug report br k , which contains the terms The new defect report is trained through the skip-gram model, and the new defect report is br k Each term w in k,i Expressed as in Represents the value at the Nth dimension.

[0092] Report the defect k All word vectors in the are aggregated and the maximum value is selected as the br using the MaxPooling method on each feature dimension. k The representation vector The maximum value in this dimension, The value of the i-th dimension in is

[0093] By calculating defect reports and the method am on the block iThe cosine similarity between them is used to construct query statements and query reconstruction, and the method with the larger similarity is selected to locate software defects. The cosine similarity is calculated as:

[0094]

[0095] The model of the method body after that.

[0096] Accordingly, the embodiment of the invention proposes a method for evaluating the accuracy of software defect location results:

[0097] 1) Calculate the Top N Rank: This represents the ratio of the number of method bodies whose corresponding bug report changes appear in the top N returned results, where N = (1, 5, 10). For a given bug report, if the top N query results contain at least one method body that fixes the bug, the bug is considered accurately located.

[0098] 2) Calculate the Mean Average Precision (MAP): This represents the average accuracy of all defect reports after location. The MAP value reflects the single-value indicator of the defect location method's ability to accurately locate all source code that needs to be modified across all defects. The higher the ranking of the retrieved related method bodies, the larger the MAP value. The formula for the average precision of a single defect is:

[0099]

[0100] Where R represents the sorted set of source code method bodies that can be correctly located in a defect location, |R| represents the number of source code method bodies that are correctly located, and rank k represents the rank of the kth correct source code method body.

[0101] The MAP formula for all defect reports is:

[0102]

[0103] Where Q is the set of defect reports, |Q| represents the number of defect reports in Q, and AvgP j represents the average precision value of the j-th defect report.

[0104] 3) Calculate the Mean Reciprocal Rank (MRR): This represents the average of the reciprocal positions of the related method bodies. The higher the value, the higher the accuracy of the method. The formula for calculating the mean reciprocal rank is:

[0105]

[0106] Where Q is the set of defect reports, |Q| represents the number of defect reports in Q, and ranki Indicates the top-ranked position of the method body related to the i-th defect report.

[0107] The above description of the embodiments is intended to facilitate understanding and application of the present invention by those skilled in the art. It will be apparent that those skilled in the art can readily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without requiring any creative effort. Therefore, the present invention is not limited to the above embodiments, and improvements and modifications made by those skilled in the art based on the disclosure of the present invention should fall within the scope of protection of the present invention.

Claims

1. A fine-grained software defect location method based on blockchain traceability and method level, characterized by: The following steps are involved: S1: Extract method bodies from historical defect reports and source code files in the defect reports, calculate cosine similarity and sort them. Specific implementation steps: S101: Parsing the source code file using the abstract syntax tree (AST) and extracting the method body as mi, where 1<=i<=n, and n is the total number of source code method bodies. S102: Each method body is preprocessed, including separating English words from the method name according to the Java programming camel case naming rule, removing stop words, removing Java reserved keywords, and removing various symbols to obtain the preprocessed method m′ i ; S103: Report all defects i and method m′ i Through Skip-gram model training, we get m′ i N corresponding to each word in is the word vector w, w=(v1,v2,...,v N ), where v N Represents the value in the Nth dimension; the minimum frequency of the Skip-gram model is set to 1, the number of windows is set to 5, and the value of dimension N is set to 300; S104: Calculate the tfidf value of each word vector, {t1, t2, ..., t m } indicates that from the method body m′ i The extracted terms, m represents the total number of stems, for a single term t i , its tfidf calculation formula is: tfidf(t i )=tf(t i )×idf(t i ) The vocabulary frequency tf(t i ), inverse document frequency idf(t i )The formula is as follows: Refers to method m j The stem t in i frequency, refers to the stem t i The number of methods, |M| represents the sum of the number of methods in all source files; for each method M j , where 1≤j≤|M|, and its representation after processing by the word vector representation set tfidf is: in, Indicates this item t i word vectors; S105: Take the kth method, where 1≤k≤|M| As a query, other methods Among them, i≠k is regarded as the query object; by calculating and The cosine similarity of Among them, i≠k is sorted, thus obtaining a sequence of size |M|-1, and by sorting the similar methods of each method in all |M| methods, |M| sequences of size |M|-1 are obtained; method and methods The angle cosine similarity is S k,1 ,S k,2 ,...,S k,|M|-1 , and the corresponding formula is: S2: Expand the sorted method body; S3: Save the historical defect report and all method bodies extracted from the source code file in the defect report on the block chain system; S4: Submit the current new defect report; S5: After extracting and expanding the method body of the current new defect report, a query statement is constructed; S6: Determine whether there are any unsearched blocks in the blockchain system. If so, construct a query statement and select n blocks for retrieval in the blockchain system, where n is a natural number. If there are no unsearched blocks, calculate the cosine similarity and rank them. Select the top-ranked method to locate the software defect. S7: Determine whether the software defect location is successful. If the software defect location is successful, the defect report and the corresponding modified file information are extracted and expanded through the method body, packaged into a new block, and uploaded to the blockchain system. If the software defect location is unsuccessful, a query statement is constructed and the query is performed again.

2. The fine-grained software defect location method based on blockchain traceability and method level according to claim 1 is characterized in that: The specific implementation process of step S2 is as follows: The method obtained by S1 extraction Among them, 1≤k≤|M|, the calculation method The average value of the cosine similarity between the angle and the other |M|-1 methods θ k , which is calculated as follows: Comparison Method The average value of the angle cosine similarity θ k and methods and methods The cosine similarity S of the angle between k,i , if S k,i >θ k , then the vector of method i is represented by Expand to the kth method and in order to maintain the method The original vector of occupies a dominant position in the expanded method vector, and it is necessary to add a heuristic expansion rate α when the method is expanded to control the other methods. Among them, i≠k pairs The expansion effect of , the vector of the k-th method after expansion is expressed as:

3. The fine-grained software defect location method based on blockchain traceability and method level according to claim 1 is characterized in that: The specific implementation process of step S3 is as follows: All method bodies extracted from historical defect reports and the source code files in the defect reports are saved on the blocks of the blockchain system. For the current new defect report, first searching for similar defects that have been fixed and the method bodies extracted from the modified source code files will shorten the search time and improve the efficiency and accuracy of defect location. In addition, if a source code file has been modified multiple times to fix the same defect or the same function, then this source code file is more likely to be defective.

4. The fine-grained software defect location method based on blockchain traceability and method level according to claim 1 is characterized in that: The step S5 includes the following specific implementation steps: S501: For the kth new defect report k , which contains the terms The new defect report is trained through the skip-gram model, and the new defect report is br k Each term w in k,i Expressed as in Represents the value in the Nth dimension; S502: Report the defect k All word vectors in the are aggregated and the maximum value is selected as the br using the MaxPooling method on each feature dimension. k The representation vector The maximum value in this dimension, The value of the i-th dimension in is S503: Defect Report by Calculation and the method am on the block i The cosine similarity between them is used to construct query statements and query reconstruction, and the method with the larger similarity is selected to locate software defects. The cosine similarity is calculated as: in, Indicates a defect report The model, |am i |Represents the module of the method body after expansion on the block.

5. The fine-grained software defect location method based on blockchain traceability and method level according to claim 1 is characterized in that: It also includes a method for evaluating the accuracy of positioning results, and its steps are as follows: S11: Calculate the Top N Rank: This represents the ratio of the number of method bodies whose corresponding changes to the defect report appear in the top N returned results, where N = 1, 5, or 10. For a given defect report, if the top N query results contain at least one method body that fixes the defect, the defect is considered to be accurately located. S12: Calculate the Mean Average Precision (MAP): This represents the average accuracy of all defect reports after location. The MAP value reflects the single-value indicator of the defect location method's ability to accurately locate all source code that needs to be modified. The higher the ranking of the retrieved related method body, the larger the MAP value. The formula for the average precision of a single defect is: Where R represents the sorted set of source code method bodies that can be correctly located in a defect location, |R| represents the number of source code method bodies that are correctly located, and rank k represents the ranking of the kth correct source code method body; The MAP formula for all defect reports is: Where Q is the set of defect reports, |Q| represents the number of defect reports in Q, and AvgP j represents the average precision value of the j-th defect report; S13: Calculate the Mean Reciprocal Rank (MRR): This represents the average value of the reciprocal position of the related method body. The higher the value, the higher the accuracy of the method. The formula for calculating the average reciprocal ranking is: Where Q is the set of defect reports, |Q| represents the number of defect reports in Q, and rank i Indicates the top-ranked position of the method body related to the i-th defect report.

Citation Information

Patent Citations

  • Code method-level software defect positioning method

    CN111309607A

  • Newly-added software defect positioning method based on query expansion

    CN114546699A