A Framework for Software Code and Model Smell Detection through Self-Supervised Learning

A Framework for Software Code and Model Smell Detection through Self-Supervised Learning. PhD thesis, King Fahd University of Petroleum and Minerals.

[img] PDF
PhD_Thesis_Amal_Alazba 2023-12-28.pdf - Other
Restricted to Repository staff only until 31 December 2024.

Download (8MB)

Arabic Abstract

تؤثر العيوب البرمجية سلبًا على مقاييس جودة البرامج مثل سهولة الفهم وإعادة الاستخدام والصيانة. يمكن تحقيق خفض التكاليف وتحسين جودة البرامج من خلال الكشف الدقيق عن هذه العيوب. في حين تم اقتراح أساليب مختلفة، بما في ذلك أساليب التعلم الآلي التقليدية (ML) والتعلم العميق (DL)، وثبت فعاليتها في اكتشاف العيوب البرمجية، إلا أنها تتطلب بيانات ضخمة مصنفة يدويًا، وهي مكلفة ويصعب استخدامها على نطاق واسع. يهدف هذا البحث إلى اقتراح نهج جديد للكشف عن العيوب البرمجية باستخدام التعلم الخاضع للإشراف الذاتي لتعلم التمثيلات المتوسطة باستخدام البيانات غير المُعلّمة، ثم ضبط هذه التمثيلات في مهام متعددة. الدافع الأساسي وراء نهج التعلم الخاضع للإشراف الذاتي هو تسخير الكمية الهائلة من البيانات التي يمكن الوصول إليها الآن لتعلم الميزات الدلالية غير الخاضعة للإشراف، وتقليل اعتماد النموذج على البيانات المصنفة، وبالتالي تعزيز إمكانية تعميم نماذج التعلم العميق. في هذا البحث، أجرينا مراجعة منهجية للأدبيات حيث قمنا بتحليل 67 دراسة حول الكشف عن العيوب البرمجية باستخدام التعلم العميق وحصلنا على بيانات كمية ونوعية. كما قدمنا نموذج تمثيل الكود مع المحولات (CoRT) لمعرفة السمات الدلالية والهيكلية للنصوص البرمجية من خلال تدريب المحولات على التعرف على الكلمات المقنعة التي يتم تطبيقها على النصوص البرمجية المدخلة. كما قمنا بتوسيع نهجنا لاكتشاف العيوب البرمجية على مستوى النموذج. قدمنا نموذج MoRT (تمثيل النموذج مع المحولات) الذي يتعلم الدلالات والميزات الهيكلية لمخططات الفئة من خلال تدريب المحولات على التعرف على الكلمات الرئيسية المقنعة. لقد أثبتنا تجريبيًا أن المهام المحددة لـتدريب CoRT وMoRT توفر طريقة قوية لتعلم الميزات الدلالية والهيكلية. لقد قمنا بتقييم CoRT بشكل شامل في أربع مهام فرعية: ال Data Class، و God Class، و Feature Envy، و Long Method. بالإضافة إلى ذلك، قمنا بتقييم MoRT باستخدام أربع عيوب برمجية يمكن اكتشافها من خلال مخططات الفئة، وهي Blob، و Functional Decomposition، وSpaghetti Code، وSwiss Army Knife. قمنا بمقارنة نتائجنا مع نتائج نموذجين: التعلم تحت الإشراف والنهج القائم على الميزات. أخيرًا، أجرينا تجربة مشتركة بين المشاريع لتقييم إمكانية تعميم طريقتنا على البيانات المصنفة غير المرئية. لقد أثبتت الطريقة المقترحة فعاليتها في الكشف عن الروائح الكريهة على مستوى النصوص البرمجية ومستوى النماذج. بالمقارنة مع النموذج الأساسي والأساليب القائمة على الميزات، حققت طريقتنا أداء كشف أفضل ولديها قدرة عالية على اكتشاف العيوب البرمجية في مجموعات البيانات غير المرئية. توفر أتمتة اكتشاف رائحة التعليمات البرمجية من خلال روبوت برمجي فوائد كبيرة من حيث الكفاءة وجودة التعليمات البرمجية وإنتاجية المطور. تم تطوير روبوت برمجي، يُسمى SmellyBot، لأتمتة اكتشاف العيوب البرمجية. لقد قمنا بدمج SmellyBot بسلاسة في إطار عمل GitHub، ودمجنا التقارير الآلية لتحسين اكتشاف العيوب البرمجية. شمل تقييمنا 43 مطورًا لتقييم تصور المستخدم والميزات الموصى بها، إلى جانب تحليل أداء SmellyBot في ستة مشاريع في العالم الحقيقي لفحص كفاءته وفعاليته. تشير النتائج إلى آن SmellyBot مفيد للغاية وسهل الاستخدام من وجهة نظر المطورين.

English Abstract

Bad smells negatively impact software quality metrics such as understandability, reusability, and maintainability. Reduced costs and enhanced software quality can be achieved through accurate bad smell detection. While various approaches, including traditional machine learning (ML) and deep learning (DL) methods, have been proposed and shown to detect bad smells effectively, they require extensive manually labeled data, which is expensive and challenging to scale. This research aims to propose a new bad smell detection approach that utilizes self-supervised learning to learn intermediate representations using unlabeled data and then fine-tune these representations on multiple tasks. The primary motivation behind the self-supervised learning approach is to harness the vast amount of data now accessible for unsupervised semantic feature learning, reduce the model's reliance on labeled data, and consequently enhance the generalizability of deep learning models. In this research, we conducted a systematic literature review where we analyzed 67 studies on DL-based bad smell detection and obtained quantitative and qualitative data. Also, we introduced a Code Representation with Transformers (CoRT) model to learn the semantic and structural features of the source code by training transformers to recognize masked reserved words that are applied to the code given as input. We extended our approach to detect bad smells at the model level. We introduced the MoRT (Model Representation with Transformers) model that learns semantics and the structural features of the UML class diagrams by training Transformers to recognize masked keywords. We empirically demonstrated that the defined proxy tasks for CoRT and MoRT provide a powerful method for learning semantic and structural features. We exhaustively evaluated CoRT on four downstream tasks: detection of the Data Class, God Class, Feature Envy, and Long Method code smells. In addition, we assessed MoRT using four bad smells that can be detected through class diagrams, namely the Blob, Functional Decomposition, Spaghetti Code, and Swiss Army Knife. We compared our results with those of supervised learning and a feature-based approach. Finally, we conducted a cross-project experiment to evaluate the generalizability of our method to unseen labeled data. The proposed method has been shown to detect bad smells at the code and model levels effectively. Compared with the baseline model and feature-based approaches, our method achieved better detection performance and had a high capability to detect bad smells in unseen datasets. Automating code smell detection through a software bot significantly improves efficiency, code quality, and developer productivity. A software bot named SmellyBot was developed to automate the detection of code smells. We seamlessly integrated SmellyBot within the GitHub framework, incorporating automated reporting to enhance code smell detection. Our evaluation involved 43 developers to assess user perception and recommended features, alongside an analysis of SmellyBot's performance in six real-world projects to examine its efficiency and effectiveness. Also, developers perceive SmellyBot as highly useful and easy to use.

Item Type: Thesis (PhD)
Subjects: Computer
Department: College of Computing and Mathematics > Information and Computer Science
Committee Advisor: Alshayeb, Mohammad
Committee Members: Niazi, Mahmood and Mahmood, Sajjad and Hassine, Jameleddine
Depositing User: AMAL ALAZBA (g201901590)
Date Deposited: 03 Jan 2024 07:13
Last Modified: 03 Jan 2024 07:13
URI: http://eprints.kfupm.edu.sa/id/eprint/142637