Luận văn: Phát hiện nợ kỹ thuật (SATD) bằng học sâu - Trần Thị Dinh

Khám phá phương pháp ứng dụng học sâu và xử lý văn bản để tự động phát hiện nợ kỹ thuật (SATD) trong mã nguồn, giúp cải thiện chất lượng phần mềm.

Chuyên ngành

Kỹ thuật phần mềm

Người đăng

Ẩn danh

Thể loại

Luận văn tốt nghiệp

2023

64
0
0

Phí lưu trữ

30 Point

Tóm tắt

I. Khái niệm Nợ Kỹ Thuật và Phát Hiện SATD

Nợ kỹ thuật (Technical Debt - TD) là những giải pháp tạm thời trong phát triển phần mềm mà các đội ngũ chọn để cân bằng giữa hiệu quả ngắn hạn và ổn định dài hạn. Những giải pháp này có thể dẫn đến các vấn đề bảo trì phức tạp cần được giải quyết sau. SATD (Self-Admitted Technical Debt) là một dạng nợ kỹ thuật được các lập trình viên tự thừa nhận trong mã nguồn hoặc bình luận. Phát hiện nợ kỹ thuật tự thừa nhận giúp các đội phát triển xác định và xử lý các vấn đề tiềm ẩn sớm hơn, giảm chi phí bảo trì và cải thiện chất lượng phần mềm.

1.1. Định nghĩa Nợ Kỹ Thuật

Nợ kỹ thuật là những quyết định phát triển không tối ưu nhưng giúp tăng tốc độ giao hàng ngắn hạn. Đây là chi phí ẩn mà các doanh nghiệp phần mềm phải trả trong tương lai thông qua bảo trì khó khăn và hiệu suất kém. Nhận biết và quản lý nợ kỹ thuật là yếu tố quan trọng trong quản lý dự án phần mềm hiện đại.

1.2. SATD là gì

Self-Admitted Technical Debt (SATD) là nợ kỹ thuật được developers tự động nhận biết và ghi chú trong mã. Các lập trình viên thường để lại bình luận như "TODO", "FIXME", hoặc "HACK" để chỉ ra những điểm yếu. Phát hiện tự động những ghi chú này giúp tăng cường kiểm soát chất lượng mã và hỗ trợ quản lý nợ kỹ thuật hiệu quả hơn.

II. Phương Pháp Học Sâu cho Phát Hiện SATD

Ứng dụng học sâu (deep learning) đã tạo ra cuộc cách mạng trong việc phát hiện nợ kỹ thuật. Phương pháp này vượt trội hơn các kỹ thuật khai thác văn bản truyền thống, đặc biệt trong việc xử lý các ngôn ngữ lập trình động như R và Java. DebtSniffer là một phương pháp thực tế sử dụng các mô hình BERT được huấn luyện trước để giữ lại thông tin ngữ nghĩa phong phú trong bình luận mã nguồn. Kết hợp với mạng tích chập đồ thị (Graph Convolutional Networks), phương pháp này học được các biểu diễn tốt từ dữ liệu có nhãn và không có nhãn bằng cách truyền tác động nhãn qua các nút đồ thị.

2.1. Mô hình BERT và Nhúng Mã

BERT (Bidirectional Encoder Representations from Transformers) là mô hình xử lý ngôn ngữ tiên tiến sử dụng kiến trúc Transformer. Khi áp dụng vào nhúng mã (code embedding), BERT có khả năng nắm bắt ngữ cảnh hai chiều của bình luận mã, cung cấp biểu diễn ngữ nghĩa phong phú hơn các phương pháp nhúng từ truyền thống. Công nghệ này đặc biệt hiệu quả trong việc phân biệt các bình luận SATD từ các bình luận bình thường.

2.2. Mạng Tích Chập Đồ Thị GCN

Graph Convolutional Networks (GCN) là một kiến trúc học sâu tiên tiến giúp liên kết các câu bình luận rải rác trong mã nguồn. GCN hoạt động bằng cách truyền thông tin nhãn qua cấu trúc đồ thị, cho phép mô hình học từ cả dữ liệu huấn luyện có nhãn lẫn dữ liệu kiểm tra không có nhãn. Phương pháp này đặc biệt hữu ích trong các dự án nguồn mở có dữ liệu SATD không cân bằng.

III. Ứng dụng trong Ngôn ngữ R và Java

Phát hiện nợ kỹ thuật trong các ngôn ngữ khác nhau đòi hỏi các phương pháp tiếp cận riêng biệt. Ngôn ngữ R, với lập trình động và bình luận compact hướng thuật toán, đặt ra thách thức đặc biệt cho phát hiện SATD tự động. Tương tự, Java có các nguồn dữ liệu đa dạng bao gồm bình luận mã nguồn, thông báo commit, yêu cầu pull, và hệ thống theo dõi vấn đề. DebtSniffer thành công trong việc xác định SATD trên 4.961 bình luận R từ 503 dự án nguồn mở được phân loại thành 12 lớp nợ kỹ thuật, cũng như bốn nguồn dữ liệu Java khác nhau.

3.1. Phát hiện SATD trong Mã R

Ngôn ngữ R được sử dụng rộng rãi trong khoa học dữ liệuphân tích thống kê. Các bình luận trong R thường ngắn gọn và tập trung vào thuật toán, điều này khiến phát hiện SATD trở nên khó khăn. Phương pháp DebtSniffer, với sử dụng BERT và GCN, vượt qua những thách thức này bằng cách nắm bắt đầy đủ ngữ cảnh ngữ nghĩa của các bình luận R phức tạp, cung cấp độ chính xác cao hơn các phương pháp truyền thống.

3.2. Phát hiện SATD trong Mã Java

Java là ngôn ngữ lập trình hướng đối tượng phổ biến với nhiều dự án mã nguồn mở. SATD trong Java xuất hiện trong nhiều dạng khác nhau: bình luận mã, thông báo commit, PR, và issue tracker. DebtSniffer tích hợp các nguồn dữ liệu đa dạng này, giúp phát hiện nợ kỹ thuật toàn diện hơn. Kết quả thử nghiệm cho thấy phương pháp này vượt trội hơn các phương pháp dựa trên nhúng từ truyền thống.

IV. Kết quả và Tác động của Phát hiện Nợ Kỹ Thuật

Kết quả thử nghiệm với DebtSniffer cho thấy hiệu quả vượt trội trong phát hiện SATD so với các phương pháp hiện đại. Hệ thống đã xác định chính xác nợ kỹ thuật từ hàng nghìn bình luận mã, giúp các đội phát triển nhận biết và ưu tiên các vấn đề bảo trì. Ứng dụng học sâu không chỉ cải thiện độ chính xác mà còn giúp tự động hóa quá trình phát hiện, tiết kiệm thời gian và tài nguyên. Các khám phá này có tác động lâu dài trong việc nâng cao chất lượng phần mềm và quản lý rủi ro kỹ thuật.

4.1. Hiệu quả của Phương pháp DebtSniffer

DebtSniffer đạt được độ chính xác cao trong phát hiện SATD trên cả R và Java. Phương pháp này vượt trội hơn so với text mining truyền thống, nhờ vào sử dụng BERT pre-trainedGraph Convolutional Networks. Kết quả thử nghiệm chứng minh rằng các mô hình học sâu có khả năng nắm bắt tốt hơn các đặc điểm ngữ nghĩa phức tạp của nợ kỹ thuật tự thừa nhận.

4.2. Ứng dụng Thực Tế và Hướng Phát Triển

Phát hiện tự động nợ kỹ thuật giúp các doanh nghiệp phần mềm tối ưu hóa quy trình phát triển. Thông qua công cụ như DebtSniffer, các đội có thể định ưu tiên công việc bảo trì, giảm chi phí kỹ thuật, và cải thiện chất lượng phần mềm dài hạn. Hướng phát triển tương lai bao gồm mở rộng sang các ngôn ngữ lập trình khác và tích hợp vào các công cụ CI/CD hiện đại.

18/12/2025

Trích đoạn nội dung tài liệu

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY THESIS Application of deep learning and text embedding methods for self-admitted technical debt detection TRAN THI DINH dinh.vn Thesis advisor : Dr. Bui Thi Mai Anh Signature of advisor Department : Department of Software Engineering Institute : School of Information and Communication Technology Hanoi, 10-2023 THESIS ASSIGNMENT 1. Student’s information : Name : Tran Thi Dinh. Phone : 0971236392 Email: dinh.vn Class : Data Science (Elitech) Affiliation : Hanoi University of Science and Technology.

Thesis title : Application of deep learning and text embedding methods for self- admitted technical debt detection 3. Declarations/Disclosures : I herewith formally declare that I — Tran Thi Dinh — have performed the work and presentation in this thesis independently under supervisions of Dr. Bui Thi Mai Anh. All of the results are genuine and are not copied from any other sources.

Every reference materials are clearly listed in the bibliography. I will accept full responsibility for even one copy that violates school regulations. Hanoi, date month year 2023 Author Tran Thi Dinh 4. Attestation of thesis advisor:.

Hanoi, date month year 2023 Thesis Advisor Dr. Bui Thi Mai Anh Acknowledgments I would like to take this moment to express my deep and heartfelt gratitude to the individuals whose unwavering support, invaluable guidance, and unwavering assistance have been the cornerstone of my successful journey in completing this thesis. Foremost, I extend my sincerest thanks to Dr.Bui Thi Mai Anh and Dr.Nguyen Thanh Phuong, whose mentorship has been a beacon of wisdom and expertise. Their continuous support and mentorship have not only illuminated the path of this research but have also significantly contributed to its depth and quality.

The insightful feedback and constructive critique they have generously provided have not only steered my work in the right direction but have also fostered my academic growth. Furthermore, beyond these formal acknowledgments, I wish to express my gratitude to my friends and family, whose unwavering support, encouragement, and invaluable in- sights have accompanied me throughout this thesis journey. Your camaraderie and moti- vation have been a constant source of inspiration, reminding me of the strength derived from community and shared aspirations. In conclusion, I humbly acknowledge that this thesis would have remained a dream without the unwavering support and collaboration of these remarkable individuals.

Their collective contributions have elevated the quality and depth of this research, and I am profoundly thankful for their unwavering dedication to my academic voyage. i Thesis advisor : Dr. Bui Thi Mai Anh Tran Thi Dinh ABSTRACT Software teams typically turn to sub-optimal solutions that deviate from the best soft- ware development principles in order to strike a balance between short-term efficiency and long-term stability. Such solutions might lead to maintenance issues, so called Technical Debt (TD), which need be paid later on.

Previous studies have leveraged text-mining techniques for automated TD detection in source code comments (a.a Self Admitted Technical Debt–SATD), primarily focusing on object-oriented languages like Java. However, SATD detection becomes challenging in scripting languages such as R, which employ dynamic programming paradigms and have highly compact and algorithm-aligned comments. In this thesis, we introduce DebtSniffer as a practical approach for detecting SATD in both R packages and Java source codes. We utilize a code-embedding technique, i., pre-trained BERT models, to retain the rich semantic information embedded in R source code comments and Java source codes.

Subsequently, we apply graph convolutional net- works to establish connections between scattered comment sentences and learn represen- tations for both labeled training data and unlabeled test data by propagating label impact through the graph convolution. To assess the performance of DebtSniffer, we conducted experiments over 4,961 R comments from 503 open source projects which were typically categorized into 12 TD classes and four Java sources: source code comments, commit messages, pull requests, and issue tracking systems. The experimental results show that DebtSniffer accurately identifies SATD, outper- forming the current state-of-the-art approaches based on traditional word embedding tech- niques. Keywords: Self-Admitted Technical Debt, Pretrained BERT model, Graph Convolu- tional Network, Software Engineering ii Contents Abstract ii List of Figures v List of Tables vi List of Acronyms vii 1 Introduction 1 1.4 Organization of Thesis .1 General techniques for SATD detection .2 SATD detection in the R language .3 SATD detection in the Java language .1 Convolutional Neural Networks (CNN) .2 Graph Convolutional Networks (GCN) .3 Text embedding models.

24 iii Thesis advisor : Dr. Bui Thi Mai Anh Tran Thi Dinh 3.4 Transfer Learning for Code Tasks .2 Pretrained LM with CNN Model .3 Pretrained LM with GCN Model (DebtSniffer) .1 Dataset and baselines .2 Results and Discussion .1 Effectiveness of DebtSniffer on R dataset .2 Effectiveness of DebtSniffer on Java datasets .4 Threats to validity. 44 6 Conclusions and Future works 45 6. 46 References 51 Appendices 52 A Term Frequency - Inverse Document Frequency 52 B Pointwise Mutual Information 54 iv List of Figures 1.1 An example of Self-Admitted Technical Debt of the Defects type in R .2 Real-world scenarios where SATD has caused substantial problems .3 Example - SATD Type: Algorithm in Java .1 A basic convolutional neural network (CNN) architecture.1 The graph convolutional neural network.2 The graph convolutional neural network for text data.1 The SATD preprocessing workflow.1 The architecture of Pretrained LM with CNN model.

Pretrained Code- BERT is used as an example.2 The input representation of BERT model.1 The architecture of Pretrained LM with GCN model.2 Schematic of GCN model.1 Comment length distribution in R dataset.2 SATD length distribution in Java dataset.1 Influence of the number of GC layers in SATD detection for R packages. The baseline is equal to zero number of GC layers.2 Influence of the number of GC layers in SATD detection for Code com- ment source in Java. The baseline is equal to zero number of GC layers. 43 v List of Tables 1.1 Taxonomy TD definitions, based on Codabux et al [5] .2 Types of SATD with Examples .1 Statistics of the dataset.2 Number of different types of SATD .1 Comparison Results in R dataset (%) .2 Code comment dataset.3 Pull request dataset.4 Commit message dataset.6 Influence of the number of GC layers on average F1-score of R language dataset and Java Code comment data.

42 vi List of Acronyms CNN Convolutional Neural Network. GCN Graph Convolutional Network. LM Language Models. NLP Natural Language Processing.

OOP Object Oriented Programming. PMI Pointwise Mutual Information. PPMI Positive Pointwise Mutual Information. RNN Recurrent Neural Networks.

SATD Self-Admitted Technical Debt. SOTA State-Of-The-Art. SVM Support Vector Machines. TD Technical Debt.

TF-IDF Term Frequency – Inverse Document Frequency. vii Chapter 1 Introduction SATD refers to code artifacts within a software project where developers explicitly ac- knowledge the presence of suboptimal or problematic code but do not immediately ad- dress it. SATD can manifest as code comments, such as ”// TODO” or ”// FIXME,” and typically reflects issues related to design flaws, code smells, or deferred maintenance. The identification of SATD instances is crucial for several reasons.

It allows development teams to prioritize technical debt repayment, maintain code quality, and reduce the risk of project delays and increased maintenance costs.1 Problem Statement In the dynamic realm of software development, a common challenge that developers fre- quently encounter is the inexorable march of time. The pressures of deadlines and project constraints often force them to make expedient decisions and adopt shortcuts to expedite the development process. However, while these shortcuts may offer immediate relief, they can potentially sow the seeds of long-term consequences [30]. These expedient measures, taken in the heat of project development, can inadvertently give rise to a myriad of issues.

One of the foremost concerns is the inadvertent creation of low-quality code. These hasty coding practices, often driven by the urgency of project timelines, may result in code that lacks the robustness, efficiency, and maintainability that are the hallmarks of high-quality software. Consequently, such code can become a source of frustration for developers and may hinder the overall progress of the project. The concept of Technical Debt (TD) was introduced by Cunningham [6], referring to the phenomenon of “not-quite-right code” that represents an incomplete, temporary, or sub-optimal solution.

In the pursuit of short-term advantages, incurring debts, over the 1 Thesis advisor : Dr. Bui Thi Mai Anh Tran Thi Dinh long term, must be repaid at an increasing cost [30]. Self-Admitted Technical Debt (SATD) represents a particular form of TD where devel- opers leave comments within the source code to acknowledge sections that are not fully completed or optimized, indicating the need for further refinement or additional atten- tion [17].1: An example of Self-Admitted Technical Debt of the Defects type in R Figure 1.1 is an example of the SATD categorized into “Defect”. In this example, the comment explicitly mentions the function name, ’validate input’, and the variable ’threshold’, indicating that there is an issue related to the initialization of the variable.

However, it suggests deferring the resolution of this defect, which is a characteristic of the ”Defects” type of SATD. Detecting and effectively dealing with SATD issues presents a multifaceted challenge within the realm of software development. One of the primary complexities lies in the fact that SATD concerns often fly under the radar, remaining obscure and known to only a select few developers. The inherent intricacy of SATD identification and management is compounded by the urgency of the matter.

Failing to address these debts in a timely and efficient manner can lead to a cascading effect of adverse consequences. These repercussions reverberate through various facets of software quality, making it imperative to allocate the requisite time and resources for resolution. In essence, the proactive detection and management of SATD issues are critical com- ponents in the continuous pursuit of software quality enhancement. The intricacies in- volved in this process necessitate a thorough understanding of the various SATD types, as well as the adoption of effective strategies for their detection and subsequent mitiga- tion.

By doing so, software development teams can ensure that their projects remain on a trajectory towards improved reliability, maintainability, and overall excellence. While Self-Admitted Technical Debt (SATD) may not lead to traditional ”disasters” in the sense of natural disasters, it can have significant negative impacts on software projects, 2 Thesis advisor : Dr. Bui Thi Mai Anh Tran Thi Dinh organizations, and even individuals. SATD can lead to software failures, causing applica- tions to crash or malfunction.

For instance, in 2012, Knight Capital Group lost 440 million dolars in under an hour due to a trading algorithm error caused by an undetected software bug, which can be considered a financial disaster.2: Real-world scenarios where SATD has caused substantial problems Technical debt often includes poor security practices. Unresolved security issues in software can lead to data breaches, exposing sensitive information. The Equifax data breach in 2017, affecting 147 million people, was partly attributed to unpatched software vulnerabilities. As a multi-paradigm programming language, R is being used more and more in ap- plications related to data science and statistics [33].

Despite the fact that the R end-user programming community has been growing, the bulk of contributors are statisticians and scientists rather than software engineers. Indeed, prior research has indicated that few R-users are familiar with the nuances of the programming language and that they do not view themselves as developers [26]. While there are several studies dealing with SATD in programming languages such as Java [30], little attention has been paid to the detection of technical debt in the R language. We hypothesize that the detection of SATD in R pack- ages is more difficult than that in other languages due to the mixing of several program- ming paradigms including dynamically typing.

In the context of Java, which is widely used in various software projects, SATD detection becomes particularly relevant. SATD in Java refers to code segments where developers have knowingly introduced suboptimal solutions, which are often documented as comments within the code.Java codebases are typically large and complex, making it challenging to manually identify SATD.

Nội dung được bảo vệ bản quyền — Tải xuống đầy đủ