Um pipeline híbrido para detecção inteligente e confiável de bugs e code smells em Python
Resumo
A detecção precoce de bugs e code smells exige equilíbrio entre precisão, cobertura e custo. Em Python, cuja natureza dinâmica dificulta a verificação formal, ferramentas como EVA e PyVeritas traduzem código para C, mas podem perder semântica. O ESBMC-Python supera essa limitação ao verificar diretamente o código via bounded model checking, porém com alto custo e necessidade de especificações. Modelos de linguagem (LLMs e SLMs) oferecem compreensão semântica, mas sofrem com falsos positivos e alucinações. Dado o contexto, neste trabalho é proposto um pipeline híbrido que integra triagem por LLM, validação estrutural via AST e verificação formal com ESBMC-Python para três categorias de bugs e três de code smells. Avaliamos cinco modelos (gpt-5.5, claude-sonnet-4-6, gemini-3.1-flash-lite, deepseek-r1:7b e qwen2.5-coder:7b) em 70 funções Python sintéticas, geradas com auxílio de LLM e revisadas manualmente, alcançando precisão de bugs entre 0,977 e 1,000 (0,081 em code smells) e taxa de redução de ruído entre 0,500 e 1,000, reduzindo o total de falsos positivos de 48 para 2 somando os cinco modelos, com ganhos mais expressivos nos modelos locais. A validação AST eliminou completamente alucinações estruturais, presentes apenas nos modelos locais. Os resultados indicam que a abordagem híbrida aumenta a precisão, oferecendo um caminho prático para integrar garantias formais à revisão de código Python. A linha de base, uso isolado da LLM sem confirmação formal, alcança precisão entre 0,627 e 0,977.
Palavras-chave:
Code smells, Detecção de falhas, ESBMC, IA Generativa, Modelos de linguagem, Verificação formal
Referências
Yangruibo Ding, Yanjun Fu, Omniyyah Ibrahim, Chawin Sitawarin, Xinyun Chen, Basel Alomair, David Wagner, Baishakhi Ray, and Yizheng Chen. 2025. Vulnerability Detection with Code Language Models: How Far Are We?. In 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE). 1729–1741. DOI: 10.1109/ICSE55347.2025.00038
Bruno Farias, Rafael Menezes, Eddie B. de Lima Filho, Youcheng Sun, and Lucas C. Cordeiro. 2024. ESBMC-Python: A Bounded Model Checker for Python Programs. In Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA). 1836–1840. DOI: 10.1145/3650212.3685304
Martin Fowler, Kent Beck, John Brant, William Opdyke, and Don Roberts. 1999. Refactoring: Improving the Design of Existing Code. Addison-Wesley, Reading, MA.
Rohit Gheyi, Márcio Ribeiro, and Jonhnanthan Oliveira. 2025. Evaluating the Effectiveness of Small Language Models in Detecting Refactoring Bugs. arXiv preprint arXiv:2502.18454 (2025).
Dipin Khati, Daniel Rodriguez-Cardenas, Paul Pantzer, and Denys Poshyvanyk. 2026. Detecting and Correcting Hallucinations in LLM-Generated Code via Deterministic AST Analysis. In 2026 IEEE/ACM Third International Conference on AI Foundation Models and Software Engineering (FORGE ’26). 72–76. DOI: 10.1145/3793655.3793725, April 12–13, 2026, Rio de Janeiro, Brazil. arXiv:2601.19106.
Pedro Orvalho and Marta Kwiatkowska. 2025. PyVeritas: On Verifying Python via LLM-Based Transpilation and Bounded Model Checking for C. arXiv:2508.08171 Preprint.
Geanderson Santos, Amanda Santana, Gustavo Vale, and Eduardo Figueiredo. 2023. Yet Another Model! A Study on Model’s Similarities for Defect and Code Smells. In Fundamental Approaches to Software Engineering (FASE 2023) (Lecture Notes in Computer Science, Vol. 13991). Springer, 282–305. DOI: 10.1007/978-3-031-30826-0_16
Shivkumar Shivaji, Natalia Lobakhina, Klaus Havelund, Alessandro Pinto, and Lucas Cordeiro. 2026. LLM-Assisted Translation and Bounded Model Checking of Python Code. In 3rd Artificial Intelligence ISoLA. Accepted.
Saymon Souza, Amanda Santana, Eduardo Figueiredo, Igor Muzetti, João Eduardo Montandon, and Lionel Briand. 2026. Beyond Strict Rules: Assessing the Effectiveness of Large Language Models for Code Smell Detection. arXiv preprint arXiv:2601.09873 (2026).
Norbert Tihanyi, Tamas Bisztray, Mohamed Amine Ferrag, Bilel Cherif, Richard Dubniczky, Ridhi Jain, and Lucas Cordeiro. 2026. Vulnerability Detection: From Formal Verification to Large Language Models and Hybrid Approaches: A Comprehensive Overview. Springer, 33–47. DOI: 10.1007/978-3-031-99447-0_3
TIOBE Software. 2026. TIOBE Index. [link]. Accessed: 2026-08-10.
Bruno Farias, Rafael Menezes, Eddie B. de Lima Filho, Youcheng Sun, and Lucas C. Cordeiro. 2024. ESBMC-Python: A Bounded Model Checker for Python Programs. In Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA). 1836–1840. DOI: 10.1145/3650212.3685304
Martin Fowler, Kent Beck, John Brant, William Opdyke, and Don Roberts. 1999. Refactoring: Improving the Design of Existing Code. Addison-Wesley, Reading, MA.
Rohit Gheyi, Márcio Ribeiro, and Jonhnanthan Oliveira. 2025. Evaluating the Effectiveness of Small Language Models in Detecting Refactoring Bugs. arXiv preprint arXiv:2502.18454 (2025).
Dipin Khati, Daniel Rodriguez-Cardenas, Paul Pantzer, and Denys Poshyvanyk. 2026. Detecting and Correcting Hallucinations in LLM-Generated Code via Deterministic AST Analysis. In 2026 IEEE/ACM Third International Conference on AI Foundation Models and Software Engineering (FORGE ’26). 72–76. DOI: 10.1145/3793655.3793725, April 12–13, 2026, Rio de Janeiro, Brazil. arXiv:2601.19106.
Pedro Orvalho and Marta Kwiatkowska. 2025. PyVeritas: On Verifying Python via LLM-Based Transpilation and Bounded Model Checking for C. arXiv:2508.08171 Preprint.
Geanderson Santos, Amanda Santana, Gustavo Vale, and Eduardo Figueiredo. 2023. Yet Another Model! A Study on Model’s Similarities for Defect and Code Smells. In Fundamental Approaches to Software Engineering (FASE 2023) (Lecture Notes in Computer Science, Vol. 13991). Springer, 282–305. DOI: 10.1007/978-3-031-30826-0_16
Shivkumar Shivaji, Natalia Lobakhina, Klaus Havelund, Alessandro Pinto, and Lucas Cordeiro. 2026. LLM-Assisted Translation and Bounded Model Checking of Python Code. In 3rd Artificial Intelligence ISoLA. Accepted.
Saymon Souza, Amanda Santana, Eduardo Figueiredo, Igor Muzetti, João Eduardo Montandon, and Lionel Briand. 2026. Beyond Strict Rules: Assessing the Effectiveness of Large Language Models for Code Smell Detection. arXiv preprint arXiv:2601.09873 (2026).
Norbert Tihanyi, Tamas Bisztray, Mohamed Amine Ferrag, Bilel Cherif, Richard Dubniczky, Ridhi Jain, and Lucas Cordeiro. 2026. Vulnerability Detection: From Formal Verification to Large Language Models and Hybrid Approaches: A Comprehensive Overview. Springer, 33–47. DOI: 10.1007/978-3-031-99447-0_3
TIOBE Software. 2026. TIOBE Index. [link]. Accessed: 2026-08-10.
Publicado
11/09/2026
Como Citar
DUARTE, Fernanda Alice; FREITAS, Rosiane de; CORDEIRO, Lucas C..
Um pipeline híbrido para detecção inteligente e confiável de bugs e code smells em Python. In: WORKSHOP BRASILEIRO DE ENGENHARIA DE SOFTWARE INTELIGENTE (ISE), 5. , 2026, São Paulo/SP.
Anais [...].
Porto Alegre: Sociedade Brasileira de Computação,
2026
.
p. 125-128.
DOI: https://doi.org/10.5753/ise.2026.32812.
