A Causal Perspective on Measuring, Explaining and Mitigating Smells in LLM-Generated Code
Recent advances in large language models (LLMs) have accelerated their adoption in software engineering contexts. However, concerns persist about the structural quality of the code they produce. In particular, LLMs often replicate poor coding practices, introducing code smells (i.e., patterns that hinder readability, maintainability, or design integrity). Although prior research has examined the detection or repair of smells, we still lack a clear understanding of how and when these issues emerge in generated code.
This paper addresses this gap by systematically measuring, explaining and mitigating smell propensity in LLM-generated code. We build on the Propensity Smelly Score (PSC), a probabilistic metric that estimates the likelihood of generating particular smell types, and establish its robustness as a signal of structural quality. Using PSC as an instrument for causal analysis, we identify how generation strategy, model size, model architecture and prompt formulation shape the structural properties of generated code. Our findings show that prompt design and architectural choices play a decisive role in smell propensity and motivate practical mitigation strategies that reduce its occurrence. A user study further demonstrates that PSC helps developers interpret model behavior and assess code quality, providing evidence that smell propensity signals can support human judgement. Taken together, our work lays the groundwork for integrating quality-aware assessments into the evaluation and deployment of LLMs for code.
Fri 17 AprDisplayed time zone: Brasilia, Distrito Federal, Brazil change
11:00 - 12:30 | AI for Software Engineering 22Research Track at Europa II Chair(s): Luca Di Grazia University of St. Gallen | ||
11:00 15mTalk | Environment-Aware Code Generation: How far are We? Research Track Tongtong Wu Monash University, Rongyi Chen Southeast University, Wenjie Du Southeast University, Suyu Ma CSIRO's Data61, Guilin Qi Southeast University, Zhenchang Xing CSIRO's Data61, Shahram Khadivi eBay Inc., Ramesh Periyathambi eBay Inc., Gholamreza Haffari Monash University File Attached | ||
11:15 15mTalk | LLM-based API Argument Completion with Knowledge-Augmented Prompts Research Track Waseem Akram Beijing Institute of Technology, Yanjie Jiang Tianjin University, Haris Ali Khan Beijing Institute of Technology, Furqan Jalil Beijing Institute of Technology, Hui Liu Beijing Institute of Technology | ||
11:30 15mTalk | Distance-Guided Search in Program Synthesis with Imperfect LLM Solutions Research Track | ||
11:45 15mTalk | Automatic Dockerfile Generation with Large Language Models Research Track Jun Lyu Nanjing University, He Zhang Nanjing University, Yusong Yuan Nanjing University, Lanxin Yang Nanjing University, Yue Li Nanjing University, Manuel Rigger National University of Singapore | ||
12:00 15mTalk | A Causal Perspective on Measuring, Explaining and Mitigating Smells in LLM-Generated Code Research Track Alejandro Velasco William & Mary, Daniel Rodriguez-Cardenas William & Mary, Dipin Khati William & Mary, David Nader Palacio Microsoft, Lutfar Rahman Alif University of Dhaka, Denys Poshyvanyk William & Mary DOI Pre-print | ||
12:15 15mTalk | A Comparison of Conversational Models and Humans in Answering Technical Questions: the Firefox Case Research Track João Correia PUC-Rio, Daniel Coutinho Pontifical Catholic University of Rio de Janeiro (PUC-Rio), Marco Castelluccio Mozilla, Caio Barbosa Pontifical Catholic University of Rio de Janeiro (PUC-Rio), Igor Steinmacher RESHAPE LAB, Northern Arizona University, USA, Marco Gerosa Northern Arizona University, Alessandro Garcia Pontifical Catholic University of Rio de Janeiro, Rafael de Mello UFRJ, Brazil, Anita Sarma Oregon State University Pre-print | ||