A Causal Perspective on Measuring, Explaining and Mitigating Smells in LLM-Generated Code

Published in ICSE 2026, 2025

This paper addresses the critical gap in understanding code smells in LLM-generated code by introducing a systematic approach to measure, explain, and mitigate smell propensity. We develop 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. Through causal analysis, we identify how generation strategy, model size, model architecture, and prompt formulation shape the structural properties of generated code. Our findings demonstrate that prompt design and architectural choices play a decisive role in smell propensity, and we propose practical mitigation strategies. A user study shows that PSC helps developers interpret model behavior and assess code quality, providing evidence that smell propensity signals can support human judgement.

Links:

Recommended citation: @article{velasco2025causal, title={A Causal Perspective on Measuring, Explaining and Mitigating Smells in LLM-Generated Code}, author={Alejandro Velasco and Daniel Rodriguez-Cardenas and Dipin Khati and David N. Palacio and Luftar Rahman Alif and Denys Poshyvanyk}, journal={Proceedings of the International Conference on Software Engineering (ICSE)}, year={2026}, url={https://arxiv.org/abs/2511.15817} }