Skip to main content

A Lightweight Approach for Detection of Code Smells


The accurate removal of code smells from source code supports activities such as refactoring, maintenance, examining code quality etc. A large number of techniques and tools are presented for the specification and detection of code smells from source code in the last decade, but they still lack accuracy and flexibility due to different interpretations of code smell definitions. Most techniques target just detection of few code smells and render different results on the same examined systems due to different informal definitions and threshold values of metrics used for detecting code smells. We present a flexible and lightweight approach based on multiple searching techniques for the detection and visualization of all 22 code smells from source code of multiple languages. Our approach is lightweight and flexible due to application of SQL queries on intermediate repository and use of regular expressions on selected source code constructs. The concept of approach is validated by performing experiments on eight publicly available open source software projects developed using Java and C# programming languages, and results are compared with existing approaches. The accuracy of presented approach varies from 86–97 % on the eight selected software projects.

This is a preview of subscription content, access via your institution.


  1. 1

    Abbes, M.; Khomh, F.; Guéhéneuc, Y.G.; Antoniol, G.: An empirical study of the impact of two antipatterns, blob and spaghetti code, on program comprehension. In: Proceedings of 15th European Conference on Software Maintenance and Reengineering, pp. 181–190 (2011)

  2. 2

    Arcelli, F.; Tosi, C.; Zanoni, M.; Maggioni, S.: The MARPLE project: A tool for design pattern detection and software architecture reconstruction. In: 1st International Workshop on Academic Software Development Tools and Techniques (WASDeTT-1) (2008)

  3. 3

    Chaikalis, T.; Tsantalis, N.; Chatzigeorgiou, A.: JDeodorant: identification and removal of type-checking bad smells. In: Proceeding of 12th European Conference on Software Maintenance and Reengineering, pp. 329–331 (2008)

  4. 4


  5. 5

    Dehagani, S.M.H.; Hajrahimi, N.: Which factors affect software projects maintenance cost more? Acta Inform. Med. 21(1), 63 (2013)

  6. 6

    Fard, A.M.; Mesbah, A.: Jsnose: detecting javascript code smells. In: Proceedings of 13th International Working Conference on Source Code Analysis and Manipulation, pp. 116–125 (2013)

  7. 7

    Fontana F.A., Braionea P., Zanonia M.: Automatic detection of bad smells in code: an experimental assessment. J. Object Technol. 11(2), 1–38 (2012)

    Google Scholar 

  8. 8

    Fowler M., Beck K., Brant J., Opdyke W., Robert D.: Refactoring: Improving the Design of Existing Code. Addison-Wesley, Reading (1999)

    Google Scholar 

  9. 9

    Kiefer C.; Bernstein A.; Tappolet J.: Mining software repositories with iSPAROL and a software evolution ontology. In: Fourth International Workshop on Mining Software Repositories (MSR), p. 10 (2007)

  10. 10

    Lozano, A.; Wermelinger, M.; Nuseibeh, B.: Assessing the impact of bad smells using historical information. In: Ninth International Workshop on Principles of Software Evolution: in Conjunction with the 6th ESEC/FSE Joint Meeting, pp. 31–34 (2007)

  11. 11

    Mäntylä M.V., Lassenius C.: Subjective evaluation of software evolvability using code smells: an empirical study. J. Empir. Softw. Eng. 11(3), 395–431 (2006)

    Article  Google Scholar 

  12. 12

    Mantyla, M.; Vanhanen J.; Lassenius C.: Bad smells-humans as code critics. In: Proceedings of the International Conference on Software Maintenance, pp. 399–408, (2004)

  13. 13

    Marinescu, R.: Detection strategies: metrics-based rules for detecting design flaws. In: Proceedings of 20th International Conference on Software Maintenance, pp. 350–359 (2004)

  14. 14

    Moha N., Guéhéneuc Y., Duchien L., Meur A.L.: DECOR: a method for the specification and detection of code and design smells. IEEE Trans. Softw. Eng. 36(1), 20–36 (2010)

    Article  MATH  Google Scholar 

  15. 15

    Oliveira, P.; Valente, M.T.; Paim Lima, F.: Extracting relative thresholds for source code metrics. In: Software Evolution Week: IEEE Conference on Software Maintenance, Reengineering and Reverse Engineering (CSMR-WCRE’2014), pp. 254–263. Antwerp, Belgium: IEEE Computer Society (2014)

  16. 16

    Palomba F.; Bavota G.; Penta MD.; Oliveto R.; De Lucia A.; Poshyvanyk D.: Detecting bad smells in source code using change history information. In: Proceedings of 28th IEEE/ACM International Conference on Automated Software Engineering, pp. 268–278 (2013)

  17. 17

    Palomba F., Bavota G., Di Penta M., Oliveto R., Poshyvanyk D., De Lucia A.: Mining version histories for detecting code smells. IEEE Trans. Softw. Eng. 41(5), 462–489 (2015)

    Article  Google Scholar 

  18. 18

    Rasool G., Arshad Z.: A review of code smell mining techniques. J. Softw.: Evol. Process 27(11), 867–895 (2015)

    Google Scholar 

  19. 19

    Ratiu D.; Ducasse S.; Gîrba T.; Marinescu R.: Using history information to improve design flaws detection. In: Proceedings of the Eight Euromicro Working Conference on Software Maintenance and Reengineering, p. 223 (2004)

  20. 20

    Sjoberg D.I.K., Yamashita A., Anda B.C.D., Mockus A., Dyba T.: Quantifying the effect of code smells on maintenance effort. IEEE Trans. Softw. Eng. 39(8), 1144–1156 (2013)

    Article  Google Scholar 

  21. 21

    Sparx System Enterprise Architect Modeling tool, homepage:

  22. 22

    Marcus, A.; Maletic, J.: Identification of high-level concept clones in source code. In: Proceedings of 16th Annual International Conference on Automated Software Engineering, pp. 107–114 (2001)

  23. 23

    Marinescu, R.; Ratiu, D.: Quantifying the quality of object-oriented design: the factor-strategy model. In: Proceedings of Working Conference on Reverse Engineering, pp. 192–201 (2004)

  24. 24

    Marticorena, R.; Crespo, Y.: Parallel inheritance hierarchy: detection from a static view of the system. In: 6th International Workshop on Object Oriented Reengineering, p. 6 (2005)

  25. 25

    Mihancea P.F.; Marinescu R.: Towards the optimization of automatic detection of design flaws in object-oriented software systems. In: Proceedings of Ninth European Conference on Software Maintenance and Reengineering, pp. 92–101 (2005)

  26. 26

    Munro, M.J.: Product metrics for automatic identification of bad smell design problems in java source-code. In: 11th IEEE International Symposium on Software Metrics, p. 15 (2005)

  27. 27

    Naveen R.: JSmell: a bad smell detection tool for java systems. Dissertation and theses (2009)

  28. 28

    Nitin M.: JAVA SMELL DETECTOR, Master thesis, San Jose State University (2011)

  29. 29


  30. 30

    Pettersson N., Löwe W., Nivre J.: Evaluation of accuracy in design pattern occurrence detection. Proc. IEEE Trans. Softw. Eng. 36(4), 575–590 (2010)

    Article  Google Scholar 

  31. 31

    Rasool, G.; Asif, N.: Software artifacts recovery using abstract regular expressions. In: Proceedings of International Multitopic Conference (INMIC’2007), pp. 1–6 (2007)

  32. 32

    Rasool G., Philippow I., Mäeder P.: Design pattern recovery based on annotations. Adv. Eng. Softw. 41(4), 519–526 (2010)

    Article  MATH  Google Scholar 

  33. 33

    Nongpong K.: Integrating Code Smells Detection with Refactoring Tool Support. Ph.D thesis, The University of Wisconsin-Milwaukee (2012)

  34. 34

    Gopalan R.: Automatic detection of code smells in java source code. Dissertation for Honour Degree, The University of Western Australia (2012)

  35. 35

    Slinger, S.: Code smell detection in eclipse. Thesis report, Delft University of Technology (2005)

  36. 36

    Sahin D., Kessentini M., Bechikh S., Deb K.: Code-smells detection as a bi-level problem. ACM Trans. Softw. Eng. Methodol. 24(1), 1–44 (2014)

    Article  Google Scholar 

  37. 37

    Kim T.W., Kim T.G., Seu J.H.: Specification and automated detection of code smells using ocl. Int. J. Softw. Eng. Appl. 7(4), 35–44 (2013)

    Google Scholar 

  38. 38

    Kessentini W., Kessentini M., Sahraoui H., Bechikh S., Ouni A.: A cooperative parallel search-based software engineering approach for code-smells detection. IEEE Trans. Softw. Eng. 40(9), 841–861 (2014)

    Article  Google Scholar 

  39. 39

    dos Santos Neto B.F., Ribeiro M., da Silva V.T., Braga C., de Lucena C.J.P., de Barros Costa E.: AutoRefactoring: a platform to build refactoring agents. Expert Syst. Appl. 42(3), 1652–1664 (2015)

    Article  Google Scholar 

  40. 40

    Ganea, G.; Verebi, I.; Marinescu, R.: Continuous quality assessment with inCode. Sci. Comput. Program. 1–18 (2015). doi:10.1016/j.scico.2015.02.007

  41. 41

    Ierusalimschy R.: A text pattern matching tool based on parsing expression grammars. Softw.: Pract. Exp. 39(3), 221–258 (2009)

    Google Scholar 

  42. 42

    InFusion Code Smells tool. [Accessed on 15-01-2016]

  43. 43

    Khamis, N.; Witte, R.; Rilling, J.: Automatic quality assessment of source code comments: the JavadocMiner. In: Hopfe, C.J., Rezgui, Y., Métais, E., Preece, A., Li, H. (eds.) Natural Language Processing and Information Systems. Lecture Notes in Computer Science, vol. 6177, pp. 68–79. Springer, Berlin, Heidelberg (2010)

  44. 44

    Lanza M., Marinescu R., Ducasse S.: Object-oriented metrics in practice, pp. 29–31. Springer, Heidelberg (2006)

    Google Scholar 

  45. 45

    Roperia N.: JSmell: A Bad Smell Detection Tool for Java Systems. California State University, Long Beach (2009)

    Google Scholar 

  46. 46

    Macia, I.; Garcia, J.; Popescu, D.; Garcia, A.; Medvidovic, N.; von Staa, A.: Are automatically-detected code anomalies relevant to architectural modularity?: an exploratory analysis of evolving systems, In: Proceedings of the 11th Annual International conference on Aspect-Oriented Software Development, pp. 167–178. ACM, Potsdam, Germany (2012)

  47. 47

    Mantyla M.; Vanhanen J.; Lassenius C.: Bad smells in software-a taxonomy and an empirical study. In: Proceedings of ICSM, pp. 381–384 (2003)

  48. 48

    Mens T.; Tourwe T.; Munoz F.: Beyond the refactoring browser: advanced tool support for software refactoring. In: Proceedings of the Sixth International Workshop on Principles of Software Evolution, pp. 39–44 (2003)

  49. 49

    Web link for results: Experimental results for the eight evaluated systems, 2015. URL

  50. 50

    Rasool, G.; Mäder, P.: Flexible design pattern detection based on feature types. In: Proceedings of the 26th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 243–252 (2011)

  51. 51

    Wohlin, C.; Runeson, P.; Höst, M.; Ohlsson, M.C.; Regnell, B.; Wesslén, A.

  52. 52

    Tsantalis N., Chatzigeorgiou A.: Identification of move method refactoring opportunities. IEEE Trans. Softw. Eng. 35(3), 347–367 (2009)

    Article  Google Scholar 

  53. 53

    Yamashita A., Counsell S.: Code smells as system-level indicators of maintainability: an empirical study. J. Syst. Softw. 86(10), 2639–2653 (2013)

    Article  Google Scholar 

  54. 54

    Yamashita A.; Moonen L.: Exploring the impact of inter-smells relationships in the maintainability of a system: an empirical study. In: Proceedings of International Conference on Software Engineering, pp. 682–691 (2013)

  55. 55

    Zhang M., Hall T., Baddoo N.: Code bad smells: a review of current knowledge. J. Softw. Maint. Evol.: Res. Pract. 23(3), 179–202 (2011)

    Article  Google Scholar 

  56. 56

    Zhang, M.; Hall, T.; Baddoo, N.; Wernick, P.: Do bad smells indicate trouble in code?. In: Proceedings of the 2008 Workshop on Defects in Large Software Systems, pp. 43–44 (2008)

Download references

Author information



Corresponding author

Correspondence to Ghulam Rasool.

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Rasool, G., Arshad, Z. A Lightweight Approach for Detection of Code Smells. Arab J Sci Eng 42, 483–506 (2017).

Download citation


  • Code smells
  • Code flaws
  • SQL
  • Regular expressions
  • Refactoring