Code Smell Classification in Python: Are Small Language Models Up to the Task?
Code quality is essential for maintainable and evolvable software systems. Traditional code smell detection tools rely on AST-based techniques and metric-driven heuristics, which, while effective, often lack interpretability and require specialized knowledge. This paper investigates the use of Small Language Models (SLMs) for classifying two widely studied code smells—Long Method and Long Parameter List—in Python codebases. Unlike Large Language Models (LLMs), SLMs offer lower latency and reduced computational cost, making them suitable for deployment in resourceconstrained environments. We systematically compare the performance of SLMs with traditional Machine Learning (ML) and Deep Learning (DL) models, and the AST-based DPy tool. We also analyze the role of prompt engineering techniques—zero-shot and chain-of-thought—in enhancing SLM performance. Our evaluation considers precision, recall, F1-score, and processing time, using a custom event-driven dataset designed for code classification. Results show that SLMs achieve competitive accuracy with improved interpretability. Additionally, we release an annotated dataset comprising classifications from all approaches. This work provides new insights into lightweight, explainable, and practical methods for automated code quality assessment, and supports the broader adoption of SLMs in software engineering.
Authors
- Jessica Ribas (ORCID: https://orcid.org/0000-0002-9294-9533)
- Joanne Carneiro
- Juliana Alves Pereira (ORCID: https://orcid.org/0000-0002-0799-2829)
- Igor Soares de Oliveira
Institutions
- Pontifícia Universidade Católica do Rio de Janeiro (BR)
Publication Details
- Published
- 2025-09-22
- DOI
- https://doi.org/10.5753/sbes.2025.11046
- Primary Topic
- Software Engineering Research
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- Fundação de Amparo à Pesquisa do Estado de São Paulo
- Coordenação de Aperfeiçoamento de Pessoal de Nível Superior