Skip to main content

Method-Level Code Smells Detection Using Machine Learning Models

  • Conference paper
  • First Online:
Computational Intelligence in Pattern Recognition (CIPR 2022)

Part of the book series: Lecture Notes in Networks and Systems ((LNNS,volume 725))

Abstract

Code smell detection is critical for calculating system quality and identifying issues that require more work and development. The technique of finding wrongly developed code components and implementing them is known as code smell detection. In this study, we used two method-level code smell datasets: the long parameter list and the switch statement, for detecting the code smells. A SMOTE class balancing approach is utilized to deal with the issue of class imbalance in datasets. A wrapper-based feature selection approach is used to choose the best features from each dataset. We applied three ensemble learning-based machine learning methods. To validate the model's accuracy, we utilized a fivefold cross-validation technique with five performance measurements (precision, recall, F-measure, AUC_Score, and accuracy). Using the max voting dataset, we obtained the best accuracy of 97.12% for the long parameter list dataset.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 189.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 249.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. Booch G (1980) Object-oriented analysis and design. Addison-Wesley

    Google Scholar 

  2. Fowler M, Beck K, Brant J, Opdyke W, Roberts D (1999) Refactoring: improving the design of existing programs

    Google Scholar 

  3. Bavota G, Lucia AD, Penta MD, Oliveto R, Palomba F (2015) An experimental investigation on the innate relationship between quality and refactoring. J Syst Softw 107:1–14. https://doi.org/10.1016/j.jss.2015.05.024

  4. Charalampidou S, Ampatzoglou A, Avgeriou P (2015) Size and cohesion metrics as indicators of the long method bad smell: an empirical study. In: Proceedings of the 11th International conference on predictive models and data analytics in software engineering, PROMISE ’15. Association for Computing Machinery, Beijing, China, pp 1–10. https://doi.org/10.1145/2810146.2810155

  5. Moha N, Gueheneuc Y-G, Duchien L, Le Meur A-F (2010) DECOR: a method for the specification and detection of code and design smells. IEEE Trans Softw Eng 36(1):20–36. https://doi.org/10.1109/TSE.2009.50

    Article  MATH  Google Scholar 

  6. Alkharabsheh K, Crespo Y, Manso E, Taboada JA (2019) Software design smell detection: a systematic mapping study. Softw Qual J 27(3):1069–1148. https://doi.org/10.1007/s11219-018-9424-8

    Article  Google Scholar 

  7. Wiegers K, Beatty J (2013) Software requirements. Pearson Education, London, UK

    Google Scholar 

  8. Chung L, do PLJCS (2009) On non-functional requirements in software engineering. In: Borgida AT, Chaudhri V, Giorgini P, YuE ES (eds) Conceptual modeling: foundations and applications. Lecture Notes in Computer Science. Springer, Cham, Switzerland, pp 363–379

    Google Scholar 

  9. Fontana FA, Mäntylä MV, Zanoni M, Marino A (2016) Comparing and experimenting machine learning techniques for code smell detection. Empirical Softw Eng 21(3):1143–1191

    Google Scholar 

  10. Alazba A, Aljamaan HI (2021) Code smell detection using feature selection and stacking ensemble: an empirical investigation. Inf Softw Technol 138:106648

    Article  Google Scholar 

  11. Dewangan S, Rao RS, Mishra A, Gupta M (2021) A novel approach for code smell detection: an empirical study. IEEE Access 9:162869–162883. https://doi.org/10.1109/ACCESS.2021.3133810

    Article  Google Scholar 

  12. Mhawish MY, Gupta M (2019) Generating code-smell prediction rules using decision tree algorithm and software metrics. Int J Comput Sci Eng (IJCSE) 7(5):41–48

    Google Scholar 

  13. Mhawish MY, Gupta M (2020) Predicting code smells and analysis of predictions: using machine learning techniques and software metrics. J Comput Sci Technol 35(6):1428–1445. https://doi.org/10.1007/s11390-020-0323-7

  14. Yadav PS, Dewangan S, Rao RS (2021) Extraction of prediction rules of code smell using decision tree algorithm. In: 2021 10th International conference on internet of everything, microwave engineering, communication and networks (IEMECON), pp. 1–5. https://doi.org/10.1109/IEMECON53809.2021.9689174

  15. Dewangan S, Rao RS (2022) Code smell detection using classification approaches. In: Udgata SK, Sethi S, Gao XZ (eds) Intelligent systems. Lecture notes in networks and systems, vol 431. Springer, Singapore. https://doi.org/10.1007/978-981-19-0901-6_25

  16. Dewangan S, Rao RS, Yadav PS (2022) Dimensionally reduction based machine learning approaches for code smells detection. In: 2022 International conference on intelligent controller and computing for smart power (ICICCSP), pp 1–4. https://doi.org/10.1109/ICICCSP53532.2022.9862030

  17. Dewangan S, Rao RS, Mishra A, Gupta M (2022) Code smell detection using ensemble machine learning algorithms. Appl Sci 12(20):10321. https://doi.org/10.3390/app122010321

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Rajwant Singh Rao .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Dewangan, S., Rao, R.S. (2023). Method-Level Code Smells Detection Using Machine Learning Models. In: Das, A.K., Nayak, J., Naik, B., Vimal, S., Pelusi, D. (eds) Computational Intelligence in Pattern Recognition. CIPR 2022. Lecture Notes in Networks and Systems, vol 725. Springer, Singapore. https://doi.org/10.1007/978-981-99-3734-9_7

Download citation

Publish with us

Policies and ethics