An Automated Refactoring Approach to Remove Unnecessary Complexity in Source Code - Magalhães, Nathan Manera; Campos Junior, Heleno de Souza; Araújo, Marco Antônio Pereira; Neves, Vânia de Oliveira (Anais do Simpósio Brasileiro de Testes de Software Sistemático e Automatizado (SAST); 2017: Anais do II Simpósio Brasileiro de Testes de Software Sistemático e Automatizado, 2017)
Programming apprentices may choose to prioritize the correct functioning of a source code without focusing on their quality, making them difficult to maintain and test. Based on that, a phenomenon called unnecessary structural complexity may occur, in which a program has a cyclomatic complexity value that can be reduced without affecting its external behavior. In a previous work, we developed an approach and tool to address this problem. The approach is able to identify the presence of unnecessary cyclomatic complexity and to show the developer a suggestion to restructure the source code, through a control flow graph. The goal of this paper is to automate the source code refactoring process to support the elimination of unnecessary cyclomatic complexity. We performed two experimental studies to evaluate the approach in the academic context. The evidences provided by these studies suggest that the approach is able to support unnecessary cyclomatic complexity removal. We could not find, however, evidences about the implications of such approach on unit tests development.