Vol.68, No.2, 2021, pp.1919-1935, doi:10.32604/cmc.2021.015586
Code Smell Detection Using Whale Optimization Algorithm
  • Moatasem M. Draz1, Marwa S. Farhan2,3,*, Sarah N. Abdulkader4,5, M. G. Gafar6,7
1 Department of Software Engineering, Faculty of Computers and Information, Kafrelsheikh University, Kafr Elsheikh, Egypt
2 Faculty of Informatics and Computer Science, British University in Egypt, Cairo, Egypt
3 Department of Information Systems, Faculty of Computers and Artificial Intelligence, Helwan University, Cairo, Egypt
4 Department of Computer Science, Faculty of Computers and Artificial Intelligence, Helwan University, Cairo, Egypt
5 Faculty of Computer Studies, Arab Open University, Cairo, Egypt
6 Department of Computer Science, College of Science and Humanities in Al-Sulail, Prince Sattam bin Abdulaziz University, Kharj, Saudi Arabia
7 Department of Machine Learning and Information Retrieval, Faculty of Artificial Intelligence, Kafrelsheikh University, Kafr Elsheikh, Egypt
* Corresponding Author: Marwa S. Farhan. Email:
(This article belongs to this Special Issue: Emerging Computational Intelligence Technologies for Software Engineering: Paradigms, Principles and Applications)
Received 29 November 2020; Accepted 14 February 2021; Issue published 13 April 2021
Software systems have been employed in many fields as a means to reduce human efforts; consequently, stakeholders are interested in more updates of their capabilities. Code smells arise as one of the obstacles in the software industry. They are characteristics of software source code that indicate a deeper problem in design. These smells appear not only in the design but also in software implementation. Code smells introduce bugs, affect software maintainability, and lead to higher maintenance costs. Uncovering code smells can be formulated as an optimization problem of finding the best detection rules. Although researchers have recommended different techniques to improve the accuracy of code smell detection, these methods are still unstable and need to be improved. Previous research has sought only to discover a few at a time (three or five types) and did not set rules for detecting their types. Our research improves code smell detection by applying a search-based technique; we use the Whale Optimization Algorithm as a classifier to find ideal detection rules. Applying this algorithm, the Fisher criterion is utilized as a fitness function to maximize the between-class distance over the within-class variance. The proposed framework adopts if-then detection rules during the software development life cycle. Those rules identify the types for both medium and large projects. Experiments are conducted on five open-source software projects to discover nine smell types that mostly appear in codes. The proposed detection framework has an average of 94.24% precision and 93.4% recall. These accurate values are better than other search-based algorithms of the same field. The proposed framework improves code smell detection, which increases software quality while minimizing maintenance effort, time, and cost. Additionally, the resulting classification rules are analyzed to find the software metrics that differentiate the nine code smells.
Software engineering intelligence; search-based software engineering; code smell detection; software metrics; whale optimization algorithm; fisher criterion
Cite This Article
M. M. Draz, M. S. Farhan, S. N. Abdulkader and M. G. Gafar, "Code smell detection using whale optimization algorithm," Computers, Materials & Continua, vol. 68, no.2, pp. 1919–1935, 2021.
This work is licensed under a Creative Commons Attribution 4.0 International License , which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.