A Causal Perspective on Measuring, Explaining and Mitigating Smells in LLM-Generated Code
Alejandro Velasco, Daniel Rodriguez-Cardenas, Dipin Khati, David N. Palacio, Luftar Rahman Alif, Denys Poshyvanyk

TL;DR
This paper introduces a causal analysis framework using the Propensity Smelly Score (PSC) to understand, measure, and reduce code smells in LLM-generated code, enhancing code quality and developer interpretability.
Contribution
It proposes a novel causal approach with PSC to analyze factors influencing code smells and offers mitigation strategies to improve LLM-generated code quality.
Findings
Prompt design significantly impacts smell propensity.
Model architecture influences code quality.
PSC aids developers in interpreting model behavior.
Abstract
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,…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Software Engineering Techniques and Practices · Model-Driven Software Engineering Techniques
