cs.SEOct 3, 2025

Investigating The Smells of LLM Generated Code

Authors: Debalina Ghosh Paul, Hong Zhu, Ian Bayley

Organizations: School of Engineering, Computing and Mathematics, Oxford Brookes University, Oxford, OX3 0BP, UK

Abstract

Context: Large Language Models (LLMs) are increasingly being used to generate program code. Much research has been reported on the functional correctness of generated code, but there is far less on code quality. Objectives: In this study, we propose a scenario-based method of evaluating the quality of LLM-generated code to identify the weakest scenarios, for which the quality of LLM-generated code should be improved. Methods: The method measures code smells, an important indicator of code quality, and compares them with a baseline formed from reference solutions of professionally written code. The test dataset is divided into various subsets according to the topics of the code and complexity of the coding tasks to represent different scenarios of using LLMs for code generation. We will also present an automated test system for this purpose and report experiments with the Java programs generated in response to prompts given to four state-of-the-art LLMs: Gemini Pro, ChatGPT, Codex, and Falcon. Results: We find that LLM-generated code has a higher incidence of code smells compared to reference solutions. Falcon performed the least badly, with a smell increase of 42.28%, followed by Gemini Pro (62.07%), ChatGPT (65.05%) and finally Codex (84.97%). The average smell increase across all LLMs was 63.34%, comprising 73.35% for implementation smells and 21.42% for design smells. We also found that the increase in code smells is greater for more complex coding tasks and for more advanced topics, such as those involving object-orientated concepts. Conclusion: In terms of code smells, LLMs' performances on various coding task complexities and topics are highly correlated to the quality of human-written code in the corresponding scenarios. However, the quality of LLM-generated code is noticeably poorer than human-written code.

Figures & tables

Explore similar work

CardsList
  1. LLM Code Smells: A Taxonomy and Detection Approach

    May 21, 2026Zacharie Chenail-Larcher, Brahim Mahmoudi, Naouel Moha +2Code QualityLLM Inference Optimization

  2. The Readability Spectrum: Patterns, Issues, and Prompt Effects in LLM-Generated Code

    May 13, 2026Hengzhi Ye, Fengyuan Ran, Weiwei Xu +1Code GenerationReadability

  3. Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Code

    May 6, 2026Kaifeng He, Xiaojun Zhang, Peiliang Cai +7Code GenerationCode Quality