Uppsats
Integrating Static Analysis and LLMs to Refactor ComplexMethods
Kandidat-uppsats
Mittuniversitetet/Institutionen för kommunikation, kvalitetsteknik och informationssystem (2023-)
Publicerad: 2025
Språk: Engelska
Nyckelord
klicka för att sökaSammanfattning
Code complexity significantly affects the readability andmaintainability of large-scale software systems. Refactoringis a common practice to address this, and recentadvancements in Large Language Models (LLMs) showpromise for automating the process. However, purely LLMbased refactoring often introduces errors or fails to addressspecific complexity issues. To mitigate such problems,hybrid approaches that combine static analysis with LLMshave been proposed, yet their effectiveness for complexityfocused refactoring remains underexplored. This studyevaluates PMD-LLM-Refactor, a hybrid approach integratingstatic complexity analysis with LLM-driven refactoring,specifically targeting method-level code complexity. Weempirically compared it against an LLM-only baseline usingthree models (DeepSeek-R1 Distill Qwen 32B, Gemini 2.0Flash, Llama 4 Maverick) across 45 methods from five opensource Java projects. The comparison evaluated fourstructural complexity metrics (Cyclomatic, Cognitive, NPath,and Method Length) and verified functional correctnessthrough existing unit tests. The hybrid approachoutperformed the LLM-only baseline, yielding more effectiverefactorings, a higher average complexity reduction acrossall metrics (58.8% vs. 51.7%), and lower variability. However,no statistically significant performance difference wasobserved among the three LLMs within the hybridconfiguration. The findings suggest that combining staticanalysis with LLMs improves the precision, consistency, andoverall effectiveness of automated method-level refactoringto reduce code complexity. The structured guidance enablesLLMs to perform more targeted transformations while alsomitigating common failure modes such as syntax errors andhallucinated code.
Information
- Författare
- Moussa, Sara, Olsson, Micael
- Lärosäte / institution
- Mittuniversitetet/Institutionen för kommunikation, kvalitetsteknik och informationssystem (2023-)
- Publiceringsdatum
- 2025
- Uppsatstyp
- Kandidat-uppsats
- Språk
- Engelska
Utforska vidare
Liknande uppsatser
Uppsatser med liknande ämnen och nyckelord.
Kandidat-uppsats, Jönköping University/IHH, Företagsekonomi
Hauber, Mats, Topolski, Nicolas
Publicerad: 2025
Kandidat-uppsats, Högskolan i Skövde/Institutionen för informationsteknologi
Dargren, Calle
Publicerad: 2026
Kandidat-uppsats, Jönköping University/Tekniska Högskolan
Rönnqvist, Emilia, Skoogh, Lovisa
Publicerad: 2026
Kandidat-uppsats, Högskolan i Gävle/Avdelningen för datavetenskap och samhällsbyggnad
Vambe, Vimbainaishe
Publicerad: 2026
Kandidat-uppsats, Högskolan i Halmstad/Akademin för informationsteknologi
Johansson, Nathalie, Jonsson, Liam
Publicerad: 2026
Kandidat-uppsats, Linnéuniversitetet/Institutionen för datavetenskap och medieteknik (DM)
Lindberg, Leia, Hugosson, Ester
Publicerad: 2026