Skip to content
Open access

An Exploratory Study on Code Smells Detection and Refactoring using LLMs

Aug 2026 · WiPiEC Journal - Works in Progress in Embedded Computing Journal · 0 citations · 34 references

TL;DR

This paper focuses on four common smells and considers five prompts of diverse complexity, asking the model for detecting and removing the identified code smells, and suggests that general-purpose LLMs cannot be reliably used for that.

Abstract

With the observed progress in machine learning (ML), and particularly the introduction of Large Language Models (LLMs), several activities related to code maintenance could be automated. That includes not only detection and evaluation of design flaws, but also code transformation and refactoring. However, the general-purpose LLMs, while being commonly used and popular, have not been specifically trained for code analysis, and may not be suitable for conducting software maintenance tasks due to biases, and inherent shortcomings of the models. In this paper, we explore if the widely available LLMs could aid the detection and the refactoring of code smells. We focus on four common smells (God Class, Long Method, Feature Envy, and Refused Bequest) and consider five prompts of diverse complexity, asking the model for detecting and removing the identified code smells. Results suggest that general-purpose LLMs cannot be reliably used for that. They can effectively detect or remove code smells only in simple cases, and frequently produce invalid code. However, their performance depends on various factors, e.g., the model, the specific code smell or the prompt objective and composition.

Read PDF

Similar papers

Preprint Aug 2026

SmellCC: A Tool for Automated Code Smells Remediation

SmellCC, a Visual Studio Code extension that augments SonarQube with an LLM-based pipeline to automatically detect and refactor Python code smells, provides in-place, one-click remediation for the top-10 most frequent smells, effectively preventing the accumulation of technical debt during development.

Xiaoting Zhang, Yujie Zhang, Zhi-Peng Gao et al. · 0 citations
Preprint Aug 2026

Unreliable in Practice? A Comprehensive Study of Errors in LLM-Generated Code

It is observed that generated code often omits basic input validation or memory-safety checks, which can lead to overflows, resource exhaustion, or other reliability/security issues, and even the largest models frequently make simple mistakes.

Rodrigo Pato Nogueira, Marco Vieira, João R. Campos · 0 citations
Review Open access Aug 2026

A Systematic Literature Review of Code Smell Detection Tools for JavaScript Systems

A systematic literature review of JavaScript code smell detection tools found that most tools use rule-based linting, which is efficient but struggles with complex architectural smells, and AI-driven detection is completely missing.

Saymon Souza, Felipe Ribeiro, Eduardo Fernandes et al. · 0 citations
Conference Jul 2026

Understanding and Reducing Code Smells in AI-Generated Java Code Using Explainable AI and Prompt Optimization

Recently, Developers have been relying on AI tools to support them in their daily work by generating code. While the use of large language model-based AI tools has improved productivity, the quality of the generated code wasn't always optimal. In a lot of cases, the code includes design issues known as code smells, whi...

Y. Younes, Yousef Elsheikh · 0 citations
Open access 2020

Machine Learning for Code Smell Detection and Resolution

The study highlights the potential of intelligent, data-driven approaches to enhance software quality and support continuous code improvement by leveraging code metrics, syntactic and semantic features, and historical refactoring data.

Emily Johnson · 0 citations
Preprint Aug 2026

RefactorAssist: Agentic Refinement for Reliable Code Refactoring

Results indicate that static checks and test-guided, context-aware agentic repair can increase the reliability of LLM-generated refactorings, bringing them closer to practical integration within developer workflows.

Jonathan Cordeiro, Shayan Noei, Ying Zou · 1 citation

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.