The Effects of Extract Function Refactoring On High Cyclomatic Complexity Code Smell and Maintainability Index
Muhammad Naufal Pratama, Beta Noranita, Khadijah Khadijah · 2023
Software that operates actively needs to be adequately managed and maintained to avoid future problems. One of the problems in the software is the existence of code smells. A code smell indicates that a problem will, in turn, occur in the software's source code. OpenSID is open-source software used to create village administration websites. The detection carried out in this study shows that the OpenSID source code contains 32 code smells of High Cyclomatic Complexity type, which, if left untreated, can cause problems in the future. One of the problems is the reduced level of maintainability of the software. This research performs refactoring using the Extract Function method on a High Cyclomatic Complexity code smell to analyze what effect refactoring has on the code smell and its impact on the value of the OpenSID Maintainability Index. The research used the following tools: PHPMD, PHPDepend, and PhpStorm®. The results showed that after refactoring, the High Cyclomatic Complexity code smells were gone in some functions, and the average value of the OpenSID Maintainability Index increased from 37.0337 to 42.0912. Even though, in the end, the maintainability of this software is still in the category of difficult to maintain, this Maintainability Index increases to 13.66% has shown that the refactoring Extract Function method in code smells High Cyclomatic Complexity can increase the maintainability of this software.