Code Smell Detection Using a Weighted Cockroach Swarm Optimization Algorithm
G. Saranya, Dibyajyoti Mishra, Vojjala Srikar, C B Abhilash, Saketh Dooda · 2023
Code smells are a common problem in software development, leading to decreased maintainability, poor performance, and reduced code quality. Addressing code smells is crucial in ensuring that software is maintainable, scalable, and efficient. To detect them, different algorithms are used, including evolutionary algorithms such as Hybrid Particle Swarm Optimization (HPSOM), Genetic Algorithm (GA), Parallel Evolutionary Algorithm (PEA), and the weighted cockroach swarm optimization algorithm (WCSO). WCSO is especially effective for detecting code smells, as it generates rules that combine metrics and thresholds to detect code smells automatically. The main focus of this paper is detecting code smells using WCSO. We empirically evaluated WCSO with other evolutionary algorithms for detecting code smells such as blob, spaghetticode, dataclass, featureenvy, and functionaldecomposition. Our results prove that WCSO outperforms other algorithms, including GA, HPSOM, and PEA. Furthermore, we found that WCSO performs better on a range of open-source applications, including JfreeChart, GanttProject, Apache Ant 7.0, Apache Ant 5.2, Nutch, Log4J, Lucene, Xerces-J, and Rhino. By detecting these code smells, we can take steps to address them, such as refactoring code to make it more modular or reducing code complexity to improve maintainability and performance. In conclusion, this paper establishes the effectiveness of WCSO for detecting code smells in software development and making the software more reliable and efficient.