DOI: https://doi.org/10.1038/s41598-026-49590-0
PMID: https://pubmed.ncbi.nlm.nih.gov/42032054
تاريخ النشر: 2026-04-24
المؤلف: Gul Saba وآخرون
الموضوع الرئيسي: أبحاث هندسة البرمجيات
نظرة عامة
تستكشف هذه الورقة البحثية أداء ثلاثة أدوات ترميز مدعومة بالذكاء الاصطناعي – ChatGPT و Gemini و Codeium – بشكل خاص في سياق إعادة هيكلة الكود. بينما درست الدراسات السابقة قدرات ChatGPT في مهام هندسة البرمجيات المختلفة، لا تزال فعاليته في إعادة هيكلة الكود غير مستكشفة بشكل كافٍ. تستخدم الدراسة SonarQube لتقييم الأدوات بناءً على قدرتها على الحفاظ على الوظائف والدقة أثناء إعادة الهيكلة. تشير النتائج إلى أن Gemini و Codeium يتفوقان على ChatGPT في مجموعات بيانات الكود الأصغر، حيث حققا درجات متوسطة تبلغ 82% و 83%، على التوالي، مقارنةً بـ 59% لـ ChatGPT. ومع ذلك، يظهر ChatGPT تحسنًا كبيرًا في قواعد الكود الأكبر، حيث يصل إلى 77.2% ويتجاوز Codeium في عدة سمات.
تكشف النتائج أنه بينما يؤدي Gemini بشكل جيد باستمرار عبر سيناريوهات مختلفة، لا يتفوق أي أداة واحدة في جميع جوانب إعادة الهيكلة. تم الإشارة إلى القيود، خاصة في التعامل مع مقاطع الكود الأكبر (أكثر من 500 سطر)، مما يشير إلى أن هذه الأدوات أكثر ملاءمة لقواعد الكود الصغيرة إلى المتوسطة. تعترف الدراسة بالقيود مثل التركيز على بايثون، وتنوع مجموعة البيانات المحدود، والاعتماد على مقاييس التقييم الآلي، والتي قد تؤثر على قابلية تعميم النتائج. تشمل اتجاهات البحث المستقبلية توسيع التحليل ليشمل لغات برمجة متعددة، ودمج التقييمات البشرية، ودمج هذه الأدوات في خطوط أنابيب التكامل المستمر / النشر المستمر (CI/CD) لتطبيقها في العالم الحقيقي.
مقدمة
تؤكد مقدمة الورقة البحثية على الدور الحاسم للحفاظ على تصميم برمجيات عالية الجودة وسط التطور المستمر المدفوع بتغير متطلبات المستخدمين والتقدم التكنولوجي. يواجه المطورون تحديات كبيرة في إدارة هذا النمو، حيث يكرسون غالبًا ما يصل إلى 75% من جهودهم لتعزيز الوظائف مع ضمان سلامة الكود. تتطلب طرق إعادة الهيكلة التقليدية، سواء كانت يدوية أو مدعومة بالأدوات، وقتًا وخبرة كبيرة، حيث يجب على المطورين التنقل عبر تعقيدات قاعدة الكود لتجنب إدخال أخطاء. بالمقابل، تقدم أدوات إعادة الهيكلة المدفوعة بالذكاء الاصطناعي حلاً واعدًا من خلال أتمتة جوانب هذه العملية، مما يقلل من عبء العمل على المطورين ويقلل من الأخطاء البشرية.
تسلط الورقة الضوء على التقدم الأخير في تطبيق نماذج اللغة الكبيرة (LLMs) لإعادة هيكلة الكود وتحسين الجودة، مشيرةً إلى أن أدوات مثل ChatGPT و Gemini قد تفوقت على الخبراء البشريين عند تزويدها بالتوجيهات المناسبة. لقد أظهرت هذه النماذج فعاليتها في تعزيز القابلية للصيانة والقراءة، على الرغم من أن أدائها يمكن أن يختلف بناءً على تعقيد وحجم الكود. تناقش الدراسة أيضًا أهمية القابلية للصيانة، التي تُعرف بأنها سهولة إدارة وتعديل الكود، والأداء، الذي يتعلق بكفاءة تنفيذ الكود. يتم استخدام مقاييس مثل نسبة الدين الفني وحسابات التعقيد لتقييم القابلية للصيانة والأداء، مما يبرز إمكانيات الأساليب المدفوعة بالذكاء الاصطناعي في هندسة البرمجيات.
الطرق
المنهجية المستخدمة في هذا البحث مستمدة من دراسة سابقة تفحص قدرات إعادة هيكلة الكود لـ ChatGPT. إنها تدمج نقاط القوة لنماذج اللغة الكبيرة (LLMs) وأدوات تحليل الكود الثابت لتعزيز كفاءة وقراءة وقابلية صيانة الكود، وهي ضرورية لتطوير البرمجيات الحديثة. يقوم النهج بتقييم منهجي لقدرات إعادة الهيكلة لثلاث أدوات بارزة: ChatGPT و Gemini و Codeium، كل منها يقدم رؤى فريدة حول تحسين الكود.
تركز نطاق الدراسة التجريبية على أدوات إعادة الهيكلة المعتمدة على الذكاء الاصطناعي باستخدام مقاطع كود بايثون صغيرة إلى متوسطة الحجم. يسهل هذا الاختيار التجارب المنضبطة والمقارنات المتسقة بين النماذج، على الرغم من أنه قد يحد من قابلية تعميم النتائج على أنظمة البرمجيات الأكبر في العالم الحقيقي ولغات البرمجة الأخرى. يهدف الاختيار المتعمد لمقاطع الكود الأصغر إلى ضمان الوضوح في تقييم تغييرات إعادة الهيكلة مع التوافق مع المنهجيات من الدراسات السابقة. بالإضافة إلى ذلك، يوفر تضمين كل من عينات الكود القصيرة والطويلة رؤية شاملة لأداء النموذج عبر مستويات مختلفة من تعقيد الكود.
النتائج
تكشف نتائج الدراسة عن رؤى مهمة حول فعالية ثلاثة نماذج ذكاء اصطناعي – ChatGPT و Gemini و Codeium – في إعادة هيكلة كود بايثون. باستخدام مجموعتين من البيانات، A و B، أنتج البحث ما مجموعه 60 مقطع كود معاد هيكلته، حيث أسفرت مجموعة البيانات A عن 45 ملفًا ومجموعة البيانات B عن 15 ملفًا. تشير التحليلات إلى أن Codeium أنتج باستمرار كودًا أكثر إيجازًا وبساطة في مجموعة البيانات A، محققًا درجة متوسطة تبلغ 83%، بينما تبعته Gemini عن كثب بمتوسط 82%. بالمقابل، تأخر ChatGPT برصيد متوسط يبلغ 59%. يبرز هذا الاتجاه القدرات المتفوقة لـ Codeium و Gemini في التعامل مع قواعد الكود الأصغر، خاصة في سمات مثل الأمان والقابلية للصيانة والموثوقية.
ومع ذلك، تغيرت ديناميات الأداء مع قواعد الكود الأكبر في مجموعة البيانات B، حيث أظهر ChatGPT تحسنًا ملحوظًا، حيث زاد متوسط درجته من 59.0% إلى 77.2%، متجاوزًا Codeium في عدة سمات إعادة الهيكلة. حافظت Gemini على أداء قوي بمتوسط 83.08%. تؤكد التحليلات المقارنة عبر كلا مجموعتي البيانات أنه بينما يتفوق Codeium في مقاطع الكود الأصغر، يتكيف ChatGPT بشكل أفضل مع الهياكل الأكبر والأكثر تعقيدًا، مما يشير إلى إمكانيته في إدارة مهام الترميز المعقدة. بشكل عام، تشير النتائج إلى أن اختيار نموذج الذكاء الاصطناعي لإعادة هيكلة الكود قد يعتمد على حجم وتعقيد قاعدة الكود المعالجة.
المناقشة
تؤكد قسم المناقشة في الورقة البحثية على الدور الحاسم للتوجيه التكراري في تعزيز نتائج إعادة هيكلة الكود عندما يتفاعل المطورون مع نماذج اللغة الكبيرة (LLMs) مثل ChatGPT. تبرز الدراسة فعالية أدوات إعادة الهيكلة المدعومة بالذكاء الاصطناعي، خاصة من خلال مكون إضافي يسمى Em-Assist المدمج مع IntelliJ IDEA، الذي يسهل تقييم جودة الكود. كما تشير إلى أهمية دمج رؤى LLM مع أدوات تحليل الكود الثابت، مثل SonarQube وكاشف الأخطاء البرمجية (PMD)، لتحسين جودة البرمجيات من خلال تحديد المشكلات البرمجية دون تنفيذ الكود. تؤكد الأبحاث على ضرورة وجود أطر تقييم منهجية لتقييم أداء أدوات الذكاء الاصطناعي المختلفة في مهام إعادة الهيكلة.
تتبنى الدراسة تصميمًا مقارنًا لتقييم قدرات إعادة الهيكلة لـ ChatGPT و Gemini و Codeium، باستخدام مقاييس SonarQube عبر سمات جودة البرمجيات المختلفة. تكشف النتائج أنه بينما يتفوق Codeium في إعادة هيكلة مقاطع الكود الأصغر، يظهر Gemini أداءً متسقًا عبر أحجام الكود المختلفة، خاصة في المشاريع الأكبر. تشير النتائج إلى أنه لا تتفوق أداة واحدة في جميع السيناريوهات، مما يشير إلى أن أدوات إعادة الهيكلة المدعومة بالذكاء الاصطناعي قد تكون أكثر فعالية لقواعد الكود الصغيرة إلى المتوسطة. تختتم الورقة بالاعتراف بحدود الدراسة، بما في ذلك تركيزها على بايثون والاعتماد على المقاييس الآلية، بينما تقترح اتجاهات البحث المستقبلية لتعزيز قابلية تعميم وتطبيق أدوات إعادة الهيكلة المدعومة بالذكاء الاصطناعي في بيئات تطوير البرمجيات في العالم الحقيقي.
القيود
تقدم تقييم الدراسة قيودًا ملحوظة، خاصة فيما يتعلق بغياب التحقق البشري في تقييم الكود المعاد هيكلته. بينما يتم استخدام SonarQube كأداة رائدة لتوفير مقاييس موضوعية لجودة الكود، لا تتضمن الدراسة التحقق اليدوي من الخبراء، مما يقيد التقييم بالتحسينات الهيكلية وقابلية الصيانة دون تأكيد التكافؤ الوظيفي أو القراءة المتصورة من قبل المطورين. لمعالجة هذه الفجوة، تأكد الباحثون من صحة أساسية من خلال تأكيد أن الكود المعاد هيكلته خالٍ من أخطاء التجميع وانتهاكات التحليل الثابت الكبيرة.
بالإضافة إلى ذلك، تعتمد الدراسة على مقاييس SonarQube، مثل روائح الكود، والتكرار، ومؤشر القابلية للصيانة، كمؤشرات معيارية لتحسين جودة الكود. ومع ذلك، قد يحد نقص التقييم البشري من شمولية النتائج، حيث لا تلتقط هذه المقاييس تمامًا الفروق الدقيقة في قراءة الكود ووظيفته كما يدركها المطورون البشر.
DOI: https://doi.org/10.1038/s41598-026-49590-0
PMID: https://pubmed.ncbi.nlm.nih.gov/42032054
Publication Date: 2026-04-24
Author(s): Gul Saba et al.
Primary Topic: Software Engineering Research
Overview
This research paper investigates the performance of three AI-assisted coding tools—ChatGPT, Gemini, and Codeium—specifically in the context of code refactoring. While prior studies have examined the capabilities of ChatGPT in various software engineering tasks, its effectiveness in code refactoring remains underexplored. The study employs SonarQube to evaluate the tools based on their ability to maintain functionality and correctness during refactoring. Results indicate that Gemini and Codeium outperform ChatGPT in smaller code datasets, achieving average scores of 82% and 83%, respectively, compared to ChatGPT’s 59%. However, ChatGPT shows significant improvement in larger codebases, reaching 77.2% and surpassing Codeium in several attributes.
The findings reveal that while Gemini consistently performs well across different scenarios, no single tool excels in all aspects of refactoring. Limitations are noted, particularly in handling larger code segments (over 500 lines), suggesting that these tools are better suited for small to medium-sized codebases. The study acknowledges constraints such as the focus on Python, limited dataset diversity, and reliance on automated evaluation metrics, which may affect the generalizability of the results. Future research directions include expanding the analysis to multiple programming languages, incorporating human evaluations, and integrating these tools into continuous integration/continuous deployment (CI/CD) pipelines for real-world applicability.
Introduction
The introduction of the research paper emphasizes the critical role of maintaining high-quality software design amidst continuous evolution driven by changing user requirements and technological advancements. Developers face significant challenges in managing this growth, often dedicating up to 75% of their efforts to enhancing functionality while ensuring code integrity. Traditional refactoring methods, whether manual or tool-assisted, require substantial time and expertise, as developers must navigate the complexities of the codebase to avoid introducing errors. In contrast, AI-driven refactoring tools present a promising solution by automating aspects of this process, thereby reducing developer workload and minimizing human error.
The paper highlights recent advancements in the application of Large Language Models (LLMs) for code refactoring and quality improvement, noting that tools like ChatGPT and Gemini have outperformed human experts when provided with appropriate prompts. These models have demonstrated effectiveness in enhancing maintainability and readability, although their performance can vary based on code complexity and size. The study also discusses the importance of maintainability, defined as the ease of managing and modifying code, and performance, which pertains to the efficiency of code execution. Metrics such as the Technical Debt Ratio and complexity calculations are employed to assess maintainability and performance, respectively, underscoring the potential of AI-driven approaches in software engineering.
Methods
The methodology employed in this research is adapted from a prior study examining the code refactoring capabilities of ChatGPT. It integrates the strengths of large language models (LLMs) and static code analysis tools to enhance the efficiency, readability, and maintainability of code, which are essential for modern software development. The approach systematically evaluates the refactoring capabilities of three prominent tools: ChatGPT, Gemini, and Codeium, each offering unique insights into code improvement.
The experimental scope of the study is focused on AI-based refactoring tools using Python code snippets of small to moderate size. This choice facilitates controlled experimentation and consistent comparisons among the models, although it may limit the generalizability of the findings to larger, real-world software systems and other programming languages. The intentional selection of smaller code snippets aims to ensure clarity in assessing refactoring changes while aligning with methodologies from previous studies. Additionally, the inclusion of both shorter and longer code samples provides a comprehensive view of model performance across varying levels of code complexity.
Results
The results of the study reveal significant insights into the effectiveness of three AI models—ChatGPT, Gemini, and Codeium—in refactoring Python code. Utilizing two datasets, A and B, the research produced a total of 60 refactored code snippets, with Dataset A yielding 45 files and Dataset B yielding 15 files. The analysis indicates that Codeium consistently generated more concise and minimalist code in Dataset A, achieving an average score of 83%, while Gemini followed closely with an average of 82%. In contrast, ChatGPT lagged behind with an average score of 59%. This trend highlights the superior capabilities of Codeium and Gemini in handling smaller codebases, particularly in attributes such as security, maintainability, and reliability.
However, the performance dynamics shifted with larger codebases in Dataset B, where ChatGPT demonstrated a remarkable improvement, increasing its average score from 59.0% to 77.2%, surpassing Codeium in several refactoring attributes. Gemini maintained a strong performance with an average of 83.08%. The comparative analysis across both datasets underscores that while Codeium excels with smaller code snippets, ChatGPT adapts better to larger, more complex structures, indicating its potential for managing intricate coding tasks. Overall, the findings suggest that the choice of AI model for code refactoring may depend on the size and complexity of the codebase being addressed.
Discussion
The discussion section of the research paper emphasizes the critical role of iterative prompting in enhancing code refactoring outcomes when developers interact with large language models (LLMs) like ChatGPT. The study highlights the effectiveness of AI-assisted refactoring tools, particularly through a plugin called Em-Assist integrated with IntelliJ IDEA, which facilitates the evaluation of code quality. It also notes the importance of combining LLM insights with static code analysis tools, such as SonarQube and Programming Mistake Detector (PMD), to improve software quality by identifying programming issues without executing the code. The research underscores the necessity for systematic evaluation frameworks to assess the performance of various AI tools in refactoring tasks.
The study adopts a comparative design to evaluate the refactoring capabilities of ChatGPT, Gemini, and Codeium, utilizing SonarQube metrics across different software quality attributes. The findings reveal that while Codeium excels in refactoring smaller code snippets, Gemini demonstrates consistent performance across varying code sizes, particularly in larger projects. The results indicate that no single tool dominates across all scenarios, suggesting that AI-assisted refactoring tools may be more effective for small to medium-sized codebases. The paper concludes by acknowledging the limitations of the study, including its focus on Python and the reliance on automated metrics, while proposing future research directions to enhance the generalizability and applicability of AI-assisted refactoring tools in real-world software development environments.
Limitations
The evaluation of the study presents notable limitations, particularly regarding the absence of human validation in the assessment of the refactored code. While SonarQube is employed as a leading tool to provide objective metrics for code quality, the study does not include manual expert validation, which restricts the evaluation to structural and maintainability enhancements without confirming functional equivalence or perceived readability by developers. To address this gap, the researchers ensured basic correctness by confirming that the refactored code was free from compilation errors and significant static analysis violations.
Additionally, the study relies on SonarQube metrics, such as code smells, duplication, and maintainability index, as standardized indicators of code quality improvement. However, the lack of human assessment may limit the comprehensiveness of the findings, as these metrics do not fully capture the nuances of code readability and functionality as perceived by human developers.
