Code smells are symptoms of design and implementation choices that may hinder software maintainability and evolvability. Large Language Models (LLMs) have shown potential for code smell detection and refactoring, but further evidence is needed on how analysis context and localization guidance affect LLM performance in these tasks. We present a controlled empirical study of GPT-5, Gemini 2.5 Pro, and Claude Sonnet 4.5 on a Java dataset covering 14 code smell types. Detection is evaluated in mixed-smell and smell-specific settings, while refactoring is assessed with and without explicit smell locations. Results show model- and smell-dependent behavior: GPT-5 provides the most balanced detection performance, while all models remove most target smell occurrences, particularly when localization guidance is provided. However, generated transformations may include unrelated modifications or compilation issues. These findings support developer-in-the-loop workflows in which LLM-generated refactorings are validated before acceptance.

From Detection to Refactoring: A Controlled Study of LLMs for Java Code Smells / Amalfitano, D., Ricca, F., Coppola, R., Fulcini, T., Distante, D.. - (In corso di stampa). (International Conference on Product-Focused Software Process Improvement Karlskrona (Svezia) 30 Novembre - 2 Dicembre 2026).

From Detection to Refactoring: A Controlled Study of LLMs for Java Code Smells

Filippo Ricca;Riccardo Coppola;Tommaso Fulcini;
In corso di stampa

Abstract

Code smells are symptoms of design and implementation choices that may hinder software maintainability and evolvability. Large Language Models (LLMs) have shown potential for code smell detection and refactoring, but further evidence is needed on how analysis context and localization guidance affect LLM performance in these tasks. We present a controlled empirical study of GPT-5, Gemini 2.5 Pro, and Claude Sonnet 4.5 on a Java dataset covering 14 code smell types. Detection is evaluated in mixed-smell and smell-specific settings, while refactoring is assessed with and without explicit smell locations. Results show model- and smell-dependent behavior: GPT-5 provides the most balanced detection performance, while all models remove most target smell occurrences, particularly when localization guidance is provided. However, generated transformations may include unrelated modifications or compilation issues. These findings support developer-in-the-loop workflows in which LLM-generated refactorings are validated before acceptance.
In corso di stampa
File in questo prodotto:
File Dimensione Formato  
Camera_Ready____PROFES____Code_Smells.pdf

accesso riservato

Tipologia: 2. Post-print / Author's Accepted Manuscript
Licenza: Non Pubblico - Accesso privato/ristretto
Dimensione 165.8 kB
Formato Adobe PDF
165.8 kB Adobe PDF   Visualizza/Apri   Richiedi una copia
Pubblicazioni consigliate

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/11583/3016917