Exception Miner: Multi-language Static Analysis Tool to Identify Exception Handling Anti-Patterns

  • Jairo Souza UFPE
  • Tales Alves UFPE
  • Robson Oliveira UFPE
  • Leopoldo Teixeira UFPE
  • Baldoino Fonseca UFAL

Resumo


Exception handling is a technique used to manage errors or exceptional events that occur during program execution and disrupt the standard flow of the program. Although this method is beneficial, developers often neglect proper exception handling. Misuse of exception handling mechanisms can lead to exception handling anti-patterns in the source code, negatively impacting software quality. Additionally, many projects nowadays are built using multiple languages, which increases the complexity of identifying these anti-patterns and the workload involved in configuring various linters or detection tools. To address this gap, we developed a tool that identifies exception handling anti-patterns in three popular languages: Java, TypeScript, and Python. To evaluate our tool, we conducted an empirical study on 11 multi-language projects to investigate the occurrence of exception handling patterns across different languages. Our results demonstrated that the occurrence of exception handling anti-patterns is similar between Python and TypeScript. However, in Java, exception handling anti-patterns occur up to four times more frequently in the analyzed projects. The tool is available on GitHub1, along with a video2 demonstrating its use.
Palavras-chave: Exception Handling, Anti-Patterns, Mining Software Repositories, Static Analysis

Referências

David M. Beazley. 2022. Python distilled. Addison-Wesley.

Joshua Bloch. 2008. Effective Java™, Second Edition (second ed.). Prentice Hall Press, USA.

Ozren Dabic, Emad Aghajani, and Gabriele Bavota. 2021. Sampling Projects in GitHub for MSR Studies. In 18th IEEE/ACM International Conference on Mining Software Repositories, MSR 2021. IEEE, 560–564.

C. Hsieh, C. L.My, Kim T. Ho, and Yu C. Cheng. 2017. Identification and Refactoring of Exception Handling Code Smells in JavaScript. Journal of Internet Technology 18, 6 (2017), 1461–1471.

Chin-Yun Hsieh, Canh Le My, Kim Thoa Ho, and Yu Chin Cheng. 2017. Identification and Refactoring of Exception Handling Code Smells in JavaScript. Journal of Internet Technology 18, 6 (2017), 1461–1471. [link]

Miryung Kim, Romain Robbes, Christian Bird, Demóstenes Sena, Roberta Coelho, Uirá Kulesza, and Rodrigo Bonifácio. 2016. Understanding the exception handling strategies of Java libraries. Proceedings of the 13th International Conference on Mining Software Repositories (2016), 212–222. DOI: 10.1145/2901739.2901757

Oracle. 2014. What is an exception? [link]

Haidar Osman, Andrei Chiş, Claudio Corrodi, Mohammad Ghafari, and Oscar Nierstrasz. 2017. Exception Evolution in Long-lived Java Systems. 2017 IEEE/ACM 14th International Conference on Mining Software Repositories (MSR) (2017), 302–311. DOI: 10.1109/msr.2017.21

Yun Peng, Yu Zhang, and Mingzhe Hu. 2021. An Empirical Study for Common Language Features Used in Python Projects. 2021 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER) 00 (2021), 24–35. DOI: 10.1109/saner50967.2021.00012

Guilherme Bicalho de Pádua and Weiyi Shang. 2017. Studying the Prevalence of Exception Handling Anti-Patterns. 2017 IEEE/ACM 25th International Conference on Program Comprehension (ICPC) (2017), 328–331. DOI: 10.1109/icpc.2017.1

Linda Rising. 1998. Design patterns: elements of reusable architectures. Cambridge University Press, USA, 9–17.

Jonathan Rocha, Hugo Melo, Roberta Coelho, and Bruno Sena. 2018. Towards a Catalogue of Java Exception Handling Bad Smells and Refactorings. In Proceedings of the 25th Conference on Pattern Languages of Programs (Portland, Oregon) (PLoP ’18). The Hillside Group, USA, Article 7, 17 pages.

Hina Shah, Carsten Görg, and Mary Jean Harrold. 2008. Why do developers neglect exception handling?. In Proceedings of the 4th International Workshop on Exception Handling (Atlanta, Georgia) (WEH ’08). Association for Computing Machinery, New York, NY, USA, 62–68. DOI: 10.1145/1454268.1454277

Dêmora Bruna Cunha de Sousa, Paulo Henrique Maia, Lincoln Souza Rocha, and Windson Viana. 2018. Analysing the Evolution of Exception Handling Anti- Patterns in Large-Scale Projects: A Case Study. Proceedings of the VII Brazilian Symposium on Software Components, Architectures, and Reuse on - SBCARS ’18 (2018), 73–82. DOI: 10.1145/3267183.3267191

Dêmora B C de Sousa, Paulo Henrique M. Maia, Lincoln S Rocha, and Windson Viana. 2020. Studying the evolution of exception handling anti-patterns in a long-lived large-scale project. Journal of the Brazilian Computer Society 26, 1 (2020), 1. DOI: 10.1186/s13173-019-0095-5

Jairo Souza, Tales Alves, Robson Oliveira, Leopoldo Texeira, and Baldoino Fonseca. 2024. Complementary Material. [link]

Veselin Kolev Svetlin Nakov. 2013-09-01. Fundamentals of Computer Programming with C#. Faber Publishing.
Publicado
30/09/2024
SOUZA, Jairo; ALVES, Tales; OLIVEIRA, Robson; TEIXEIRA, Leopoldo; FONSECA, Baldoino. Exception Miner: Multi-language Static Analysis Tool to Identify Exception Handling Anti-Patterns. In: SIMPÓSIO BRASILEIRO DE ENGENHARIA DE SOFTWARE (SBES), 38. , 2024, Curitiba/PR. Anais [...]. Porto Alegre: Sociedade Brasileira de Computação, 2024 . p. 732-738. DOI: https://doi.org/10.5753/sbes.2024.3573.