Abstract
JavaScript has become one of the widely-used languages. However, as the size of JavaScript-based applications grows, the number of defects grows as well. Recent studies have produced a set of manually defined rules to identify these defects. We propose, in this work, the automation of deriving these rules to ensure scalability and potentially the detection of a wider set of defects without requiring any extensive knowledge on rules tuning. To this end, we rely on a base of existing code smells that is used to train the detection rules using Genetic Programming and find the best threshold of metrics composing the rules. The evaluation of our work on 9 JavaScript web projects has shown promising results in terms of detection precision of 92% and recall of 85%, with no threshold tuning required.
Notes
- 1.
For replication purposes, the dataset and tools used are located in: https://github.com/mkaouer/Code-Smells-Detection-in-JavaScript.
References
Richards, G., Lebresne, S., Burg, B., Vitek, J.: An analysis of the dynamic behavior of JavaScript programs. In: Proceedings of the 31st ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2010, Toronto, Ontario, Canada, pp. 1–12 (2010)
Richards, G., Hammer, C., Burg, B., Vitek, J.: The eval that men do. In: Mezini, M. (ed.) ECOOP 2011. LNCS, vol. 6813, pp. 52–78. Springer, Heidelberg (2011). doi:10.1007/978-3-642-22655-7_4
Ratanaworabhan, P., Livshits, B., Zorn, B.G.: JSMeter: comparing the behavior of JavaScript benchmarks with real web applications. In: WebApps 2010, vol. 10, p. 3 (2010)
Nikiforakis, N., Invernizzi, L., Kapravelos, A., Van Acker, S., Joosen, W., Kruegel, C., Piessens, F., Vigna, G.: You are what you include: large-scale evaluation of remote JavaScript inclusions. In: Proceedings of the 2012 ACM Conference on Computer and Communications Security, CCS 2012, Raleigh, North Carolina, USA, pp. 736–747 (2012)
Guarnieri, S., Pistoia, M., Tripp, O., Dolby, J., Teilhet, S., Berg, R.: Saving the world wide web from vulnerable JavaScript. In: Proceedings of the 2011 International Symposium on Software Testing and Analysis, ISSTA 2011, Toronto, Ontario, Canada, pp. 177–187 (2011)
Fowler, M., Beck, K., Brant, J., Opdyke, W., Roberts, D.: Refactoring: improving the design of existing programs. Addison-Wesley Longman Publishing Co., Inc., Boston (1999)
Madsen, M., Tip, F., Andreasen, E., Sen, K., Møller, A.: Feedback-directed instrumentation for deployed JavaScript applications. In: Proceedings of the 38th International Conference on Software Engineering, ICSE 2016, Austin, Texas, pp. 899–910 (2016)
Crockford, D.: JSLint: The javascript code quality tool, 95 (2011). http://www.jslint.com
Kovalyov, A., Kluge, W., Perez, J.: JSHint, a JavaScript code quality tool (2010)
Pradel, M., Schuh, P., Sen, K.: TypeDevil: Dynamic type inconsistency analysis for JavaScript. In: Proceedings of the 37th International Conference on Software Engineering, ICSE 2015, Florence, Italy, pp. 314–324 (2015)
Raychev, V., Vechev, M., Sridharan, M.: Effective race detection for event-driven programs. In: Proceedings of the 2013 ACM SIGPLAN International Conference, OOPSLA 2013, Indianapolis, Indiana, USA, pp. 151–166 (2013)
Mesbah, A., Prasad, M.R.: Automated cross-browser compatibility testing. In: Proceedings of the 33rd International Conference on Software Engineering, ICSE 2011, Waikiki, Honolulu, HI, USA, pp. 561–570 (2011)
Fard, A.M., Mesbah, A.: JSNOSE: detecting JavaScript code smells. In: Proceedings of the 13th IEEE International Conference on Source Code Analysis and Manipulation, SCAM 2013, pp. 116–125 (2013)
Marinescu, R., Ganea, G., Verebi, I.: inCode: continuous quality assessment and improvement. In: Proceedings of the 14th European Conference on Software Maintenance and Reengineering, pp. 274–275 (2010)
Palomba, F., Bavota, G., Di Penta, M., Oliveto, R., De Lucia, A., Poshyvanyk, D.: Detecting bad smells in source code using change history information. In: 2013 IEEE/ACM 28th International Conference on Automated Software Engineering (2013)
Palomba, F.: Textual analysis for code smell detection. In: Proceedings of the 37th International Conference on Software Engineering, ICSE 2015, Florence, Italy, pp. 769–771 (2015)
Garrett, J.J.: Ajax: a new approach to web applications (2005)
Cornelissen, B., Zaidman, A., Van Deursen, A., Moonen, L., Koschke, R.: A systematic survey of program comprehension through dynamic analysis. IEEE Transactions on Software Engineering 35(5), 684–702
Silva, L.H., Ramos, M., Valente, M.T., Bergel, A., Anquetil, N.: Does JavaScript software embrace classes? In: Proceedings of the 22nd International Conference on Software Analysis, Evolution and Reengineering (SANER), pp. 73–82 (2015)
Mendes, T., Valente, M.T., Hora, A.: Identifying utility functions in Java and JavaScript. In: 2016 X Brazilian Symposium on Software Components, Architectures and Reuse (SBCARS), 19–20 September 2016, pp. 121–130 (2016)
Humberto Silva, L., Hovadick, D., Tulio Valente, M., Bergel, A., Anquetil, N., Etien, A.: JSClassFinder: a tool to detect class-like structures in JavaScript. arXiv preprint arXiv:1602.05891 (2016)
Merlo, E., Antoniol, G., Di Penta, M., Rollo, V.F.: Linear complexity object-oriented similarity for clone detection and software evolution analyses. In: Proceedings of IEEE 20th International Conference on Software Maintenance, ICSM 2004, pp. 412–416 (2004)
Van Belle, T., Ackley, D.H.: Uniform subtree mutation, pp. 152–161 (2002)
http://pmd.sourceforge.net/snapshot/. Accessed 17 July 2016
Van Emden, E., Moonen, L.: Java quality assurance by detecting code smells. In: Proceedings of the 9th Working Conference on Reverse Engineering (WCRE 2002), Washington, DC, USA, pp. 97–106 (2002)
Mäntylä, M., Vanhanen, J., Lassenius, C.: A taxonomy and an initial empirical study of bad smells in code. Proceedings of the International Conference on Software Maintenance, ICSM 2003, 381–384 (2003)
Marinescu, R.: Detection strategies: metrics-based rules for detecting design flaws, pp. 350–359 (2004)
Moha, N., Gueheneuc, Y.-G., Duchien, L., Le Meur, A.-F.: DECOR: a method for the specification and detection of code and design smells. IEEE Trans. Software Eng. 36(1), 20–36 (2010)
Kessentini, M., Kessentini, W., Sahraoui, H., Boukadoum, M., Ouni, A.: Design defects detection and correction by example. In: Proceedings of the 19th IEEE International Conference on Program Comprehension (ICPC 2011), 22–24 June 2011, pp. 81–90 (2011)
Ouni, A., Kessentini, M., Sahraoui, H., Boukadoum, M.: Maintainability defects detection and correction: a multi-objective approach. Automated Software Engineering 20(1), 47–79 (2012)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2017 Springer International Publishing AG
About this paper
Cite this paper
Shoenberger, I., Mkaouer, M.W., Kessentini, M. (2017). On the Use of Smelly Examples to Detect Code Smells in JavaScript. In: Squillero, G., Sim, K. (eds) Applications of Evolutionary Computation. EvoApplications 2017. Lecture Notes in Computer Science(), vol 10200. Springer, Cham. https://doi.org/10.1007/978-3-319-55792-2_2
Download citation
DOI: https://doi.org/10.1007/978-3-319-55792-2_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-55791-5
Online ISBN: 978-3-319-55792-2
eBook Packages: Computer ScienceComputer Science (R0)