Open Access Open Access  Restricted Access Subscription or Fee Access

Automatic Detection of Bad Smells from Code Changes

Maen M. Hammad(1*), Asma Labadi(2)

(1) Department of Software Engineering, The Hashemite University, Jordan
(2) Department of Software Engineering, The Hashemite University, Jordan
(*) Corresponding author


DOI: https://doi.org/10.15866/irecos.v11i11.10590

Abstract


Code bad smells are indicators of code bad design that affects its quality attributes like understandability and readability. This effect has a direct impact on future maintenance tasks and code changing activities. Badly written code is hard to understand, change and test. The goal of this paper is to present an approach, supported by a tool, to automatically detect bad smells from code changes on the fly during code changing activities. An Eclipse plug-in tool (JFly) is developed to realize the approach. The tool analyzes code changes, detects bad smells and notifies developers about the location and the type of the detected bad smell. Nine bad smells are detected by JFly. A set of bad smells rules is defined, based on software metrics, to determine if code changes have one or more bad smells. JFly has been tested by different scenarios to evaluate its performance, usability and correctness. Results showed that JFly is very fast, easy to use and achieved high recall and precision values. By providing the JFly tool, developers are kept aware about code bad smells as soon as they implemented. As a result, the code is kept clean without the need to go over it periodically to check bad smells which consumes time and effort.
Copyright © 2016 Praise Worthy Prize - All rights reserved.

Keywords


Code Bad Smells; Software Maintenance; Automatic Tool

Full Text:

PDF


References


I. Sommerville, Software Engineering: Addison-Wesley, 2010.

M. M. Lehman, J. F. Ramil, P. D. Wernick, D. E. Perry, and W. M. Turski, "Metrics and laws of software evolution-the nineties view," in Proceedings of the 4th International Software Metrics Symposium, 1997, pp. 20-32.
http://dx.doi.org/10.1109/metric.1997.637156

R. Baggen, J. P. Correia, K. Schill, and J. Visser, "Standardized code quality benchmarking for improving software maintainability," Software Quality Journal, vol. 20, no. 2, pp. 287-307, 2012.
http://dx.doi.org/10.1007/s11219-011-9144-9

T. Mens and S. Demeyer, Software Evolution: Springer, 2008.
http://dx.doi.org/10.1007/978-3-540-76440-3

M. Fowler, K. Beck, and J. Brant, Refactoring: Improving the design of existing code: Addison-Wesley Educational, 1999.
http://dx.doi.org/10.1007/3-540-45672-4_31

W. H. Brown, R. C. Malveau, and T. J. Mowbray, "AntiPatterns: refactoring software, architectures, and projects in crisis”, Wiley, 1998.
http://dx.doi.org/10.1201/9781420031249.ch3

M. V. Mantyla and C. Lassenius, "Subjective evaluation of software evolvability using code smells: An empirical study," Empirical Software Engineering, vol. 11, no. 3, pp. 395-431, 2006.
http://dx.doi.org/10.1007/s10664-006-9002-8

F. Palomba, G. Bavota, M. Di Penta, R. Oliveto, and A. De Lucia, "Do they really smell bad? a study on developers' perception of bad code smells," in Proceedings of theIEEE International Conference on Software Maintenance and Evolution (ICSME'14), 2014, pp. 101-110.
http://dx.doi.org/10.1109/icsme.2014.32

D. I. K. Sjoberg, A. Yamashita, B. C. D. Anda, A. Mockus, and T. Dyba, "Quantifying the effect of code smells on maintenance effort," IEEE Transactions on Software Engineering, vol. 39, no. 8, pp. 1144-1156, 2013.
http://dx.doi.org/10.1109/tse.2012.89

T. Mens and T. Tourwe, "A survey of software refactoring," IEEE Transactions on Software Engineering,vol. 30, no. 2, pp. 126-139, 2004.
http://dx.doi.org/10.1109/tse.2004.1265817

L. Zhao and J. H. Hayes, "Rank-based refactoring decision support: two studies," Innovations in Systems and Software Engineering, vol. 7, no. 3, pp. 171-189, 2011.
http://dx.doi.org/10.1007/s11334-011-0154-3

R. Gopalan, "Automatic detection of code smells in Java source code," Dissertation for Honour Degree, The University of Western Australia, 2012.
http://dx.doi.org/10.1109/scam.2015.7335413

N. Moha, Y.-G. Gueheneuc, L. Duchien, and A.-F. Le Meur, "DECOR: A method for the specification and detection of code and design smells," IEEE Transactions onSoftware Engineering, vol. 36, no. 1, pp. 20-36, 2010.
http://dx.doi.org/10.1109/tse.2009.50

N. Tsantalis, T. Chaikalis, and A. Chatzigeorgiou, "JDeodorant: Identification and removal of type-checking bad smells," in Proceedings of the 12th European Conference on Software Maintenance and Reengineering (CSMR'08), 2008, pp. 329-331.
http://dx.doi.org/10.1109/csmr.2008.4493342

C. Marinescu, R. Marinescu, P. F. Mihancea, and R. Wettel, "iPlasma: An integrated platform for quality assessment of object-oriented design," in ICSM (Industrial and Tool Volume), 2005.
http://dx.doi.org/10.1109/icsm.2005.63

E. Murphy-Hill and A. P. Black, "An interactive ambient visualization for code smells," in Proceedings of the5th international symposium on Software visualization, 2010, pp. 5-14.
http://dx.doi.org/10.1145/1879211.1879216

F. Fontana, M. Mangiacavalli, D. Pochiero, and M. Zanoni, "On Experimenting Refactoring Tools to Remove Code Smells," in In Scientific Workshop Proceedings of the XP2015, 2015, p. 7.
http://dx.doi.org/10.1145/2764979.2764986

A. J. Riel, Object-oriented design heuristics vol. 335: Addison-Wesley Reading, 1996.
http://dx.doi.org/10.4018/9781591408963.ch001

K. Dhambri, H. Sahraoui, and P. Poulin, "Visual detection of design anomalies," in Proceedings of the12th European Conference on Software Maintenance and Reengineering (CSMR'08), 2008, pp. 279-283.
http://dx.doi.org/10.1109/csmr.2008.4493326

G. Travassos, F. Shull, M. Fredericks, and V. R. Basili, "Detecting defects in object-oriented designs: using reading techniques to increase software quality," in ACM Sigplan Notices, 1999, pp. 47-56.
http://dx.doi.org/10.1145/320385.320389

E. Van Emden and L. Moonen, "Java quality assurance by detecting code smells," in Proceedings of the9th Working Conference on Reverse Engineering (WCRE'02), 2002, pp. 97-106.
http://dx.doi.org/10.1109/wcre.2002.1173068

R. Marinescu, "Detection strategies: Metrics-based rules for detecting design flaws," in Proceedings of the20th IEEE International Conference on Software Maintenance (ICSM'04), 2004, pp. 350-359.
http://dx.doi.org/10.1109/icsm.2004.1357820

M. J. Munro, "Product metrics for automatic identification of "bad smell" design problems in java source-code," in Proceedings of the11th IEEE International Symposium on Software Metrics, 2005, pp. 15-15.
http://dx.doi.org/10.1109/metrics.2005.38

M. Lanza and R. Marinescu, Object-oriented metrics in practice: using software metrics to characterize, evaluate, and improve the design of object-oriented systems: Springer Science & Business Media, 2007.
http://dx.doi.org/10.1108/k.2007.06736eae.001

F. A. Fontana, V. Ferme, and M. Zanoni, "Towards assessing software architecture quality by exploiting code smell relations," inProceedings of theIEEE/ACM 2nd International Workshop on Software Architecture and Metrics (SAM'15), 2015, pp. 1-7.
http://dx.doi.org/10.1109/sam.2015.8

A. Tahmid, N. Nahar, and K. Sakib, "Understanding the Evolution of Code Smells by Observing Code Smell Clusters," in Proceedings of theIEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER), 2016, pp. 8-11.
http://dx.doi.org/10.1109/saner.2016.45

M. Zhang, N. Baddoo, P. Wernick, and T. Hall, "Improving the precision of fowler's definitions of bad smells," in Proceedings of the32nd Annual IEEE Software Engineering Workshop (SEW'08), 2008, pp. 161-166.
http://dx.doi.org/10.1109/sew.2008.26

S. C. Kothari, L. Bishop, J. Sauceda, and G. Daugherty, "A pattern-based framework for software anomaly detection," Software Quality Journal, vol. 12, no. 2, pp. 99-120, 2004.
http://dx.doi.org/10.1023/b:sqjo.0000024058.90885.6a

D. Rapu, S. Ducasse, T. Girba, and R. Marinescu, "Using history information to improve design flaws detection," in Proceedings of the8th European Conference on Software Maintenance and Reengineering (CSMR'04), 2004, pp. 223-232.
http://dx.doi.org/10.1109/csmr.2004.1281423

F. Palomba, G. Bavota, M. Di Penta, R. Oliveto, D. Poshyvanyk, and A. De Lucia, "Mining version histories for detecting code smells," IEEE Transactions onSoftware Engineering, , vol. 41, no. 5, pp. 462-489, 2015.
http://dx.doi.org/10.1109/tse.2014.2372760

M. Hammad, M. Hammad, and M. Bsoul, "An approach to automatically enforce object-oriented constraints," International Journal of Computer Applications in Technology, vol. 49, no. 1, pp. 50-59, 2014.
http://dx.doi.org/10.1504/ijcat.2014.059095

C. Catal and B. Diri, "Software defect prediction using artificial immune recognition system," in Proceedings of the25th conference on IASTED International Multi-Conference: Software Engineering, 2007, pp. 285-290.
http://dx.doi.org/10.1007/978-3-540-73460-4_27

A. Maiga, N. Ali, N. Bhattacharya, A. Sabane, Y.-G. Gueheneuc, G. Antoniol, and E. Aimeur, "Support vector machines for anti-pattern detection," in Proceedings of the27th IEEE/ACM International Conference on Automated Software Engineering (ASE'12), 2012, pp. 278-281.
http://dx.doi.org/10.1145/2351676.2351723

M. Kessentini, S. Vaucher, and H. Sahraoui, "Deviance from perfection is a better criterion than closeness to evil when identifying risky code," in Proceedings of theIEEE/ACM international conference on Automated software engineering (ASE'10), 2010, pp. 113-122.
http://dx.doi.org/10.1145/1858996.1859015

F. A. Fontana, M. Zanoni, A. Marino, and M. V. Mantyla, "Code smell detection: towards a machine learning-based approach," in Proceedings of theIEEE International Conference on Software Maintenance (ICSM'13), 2013, pp. 396-399.
http://dx.doi.org/10.1109/icsm.2013.56

E. H. Alikacem and H. A. Sahraoui, "A metric extraction framework based on a high-level description language," in Proceedings of the9th IEEE International Working Conference on Source Code Analysis and Manipulation (SCAM'09), 2009, pp. 159-167.
http://dx.doi.org/10.1109/scam.2009.27

F. Khomh, S. Vaucher, Y.-G. Gueheneuc, and H. Sahraoui, "A bayesian approach for the detection of code and design smells," inProceedings of the9th International Conference on Quality Software (QSIC'09), 2009, pp. 305-314.
http://dx.doi.org/10.1109/qsic.2009.47

G. Rasool and Z. Arshad, "A review of code smell mining techniques," Journal of Software: Evolution and Process, vol. 27, no. 11, pp. 867-895, 2015.
http://dx.doi.org/10.1002/smr.1737


Refbacks




Please send any question about this web site to info@praiseworthyprize.com
Copyright © 2005-2021 Praise Worthy Prize