journal article·2020-11-03Open access

Automated Code-Smell Detection in Microservices Through Static Analysis: A Case Study

Andrew Walker, Dipta Das, Tomas Cerny

Applied Sciences· Volume 10· Issue 21

Abstract

Microservice Architecture (MSA) is becoming the predominant direction of new cloud-based applications. There are many advantages to using microservices, but also downsides to using a more complex architecture than a typical monolithic enterprise application. Beyond the normal poor coding practices and code smells of a typical application, microservice-specific code smells are difficult to discover within a distributed application setup. There are many static code analysis tools for monolithic applications, but tools to offer code-smell detection for microservice-based applications are lacking. This paper proposes a new approach to detect code smells in distributed applications based on microservices. We develop an MSANose tool to detect up to eleven different microservice specific code smells and share it as open-source. We demonstrate our tool through a case study on two robust benchmark microservice applications and verify its accuracy. Our results show that it is possible to detect code smells within microservice applications using bytecode and/or source code analysis throughout the development process or even before its deployment to production.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Software Engineering Research · Software System Performance and Reliability · Software Testing and Debugging Techniques

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

Computer Science, Baylor University, One Bear Place #97141, Waco, TX 76798, USA

Funding

National Science Foundation · Red Hat Research

References (80)

Show source-provided references
1. NGINX, Inc. (2020, March 27). The Future of Application Development and Delivery Is Now Containers and Microservices Are Hitting the Mainstream. Available online: https://www.nginx.com/resources/library/app-dev-survey/.
2. Contextual Understanding of Microservice Architecture: Current and Future Directions10.1145/3183628.3183631 ↗
3. On Cloud Computing Infrastructure for Existing Code-Clone Detection Algorithms10.1145/3392350.3392351 ↗
4. Fowler, M. (2018). Refactoring: Improving the Design of Existing Code, Addison-Wesley Longman Publishing Co., Inc.
5. Yamashita, A., and Moonen, L. (2013, January 14–17). Do developers care about code smells? An exploratory survey. Proceedings of the 2013 20th Working Conference on Reverse Engineering (WCRE), Koblenz, Germany.10.1109/WCRE.2013.6671299 ↗
6. DeMichiel, L., and Shannon, W. (2020, March 27). JSR 366: Java Platform, Enterprise Edition 8 Spec. Available online: https://jcp.org/en/jsr/detail?id=342.
7. DeMichiel, L., and Keith, M. (2020, March 27). JSR 220: Enterprise JavaBeans Version 3.0. Java Persistence API. Available online: http://jcp.org/en/jsr/detail?id=220.
8. Bernard, E. (2020, March 27). JSR 303: Bean Validation. Available online: http://jcp.org/en/jsr/detail?id=303.
9. DeMichiel, L. (2020, March 27). JSR 317: JavaTM Persistence API, Version 2.0. Available online: http://jcp.org/en/jsr/detail?id=317.
10. Hopkins, W. (2020, March 27). JSR 375: JavaTM EE Security API. Available online: https://jcp.org/en/jsr/detail?id=375.
11. Fontana, F.A., and Zanoni, M. (2011, January 21–25). On Investigating Code Smells Correlations. Proceedings of the 2011 IEEE Fourth International Conference on Software Testing, Verification and Validation Workshops, Berlin, Germany.10.1109/ICSTW.2011.14 ↗
12. Suryanarayana, G., Samarthyam, G., and Sharma, T. (2014). Refactoring for Software Design Smells: Managing Technical Debt, Morgan Kaufmann Publishers Inc.. [1st ed.].10.1016/B978-0-12-801397-7.00001-1 ↗
13. Tufano, M., Palomba, F., Bavota, G., Oliveto, R., Di Penta, M., De Lucia, A., and Poshyvanyk, D. (2015, January 16–24). When and Why Your Code Starts to Smell Bad. Proceedings of the 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering, Florence, Italy.10.1109/ICSE.2015.59 ↗
14. Gupta, V., Kapur, P., and Kumar, D. (2016). Modelling and measuring code smells in enterprise applications using TISM and two-way assessment. Int. J. Syst. Assur. Eng. Manag., 7.10.1007/s13198-016-0460-0 ↗
15. Yamashita, A., and Moonen, L. (2013, January 18–26). Exploring the impact of inter-smell relations on software maintainability: An empirical study. Proceedings of the 2013 35th International Conference on Software Engineering (ICSE), San Francisco, CA, USA.10.1109/ICSE.2013.6606614 ↗
16. Moonen, L., and Yamashita, A. (2012, January 23–28). Do Code Smells Reflect Important Maintainability Aspects?. Proceedings of the 2012 IEEE International Conference on Software Maintenance (ICSM), Trento, Italy.10.1109/ICSM.2012.6405287 ↗
17. Code smells as system-level indicators of maintainability: An empirical study10.1016/j.jss.2013.05.007 ↗
18. Macia, I., Garcia, J., Daniel, P., Garcia, A., Medvidovic, N., and Staa, A. (2012, January 25–30). Are automatically-detected code anomalies relevant to architectural modularity? An exploratory analysis of evolving systems. Proceedings of the AOSD’12—11th Annual International Conference on Aspect Oriented Software Development, Potsdam, Germany.10.1145/2162049.2162069 ↗
19. Counsell, S., Hamza, H., and Hierons, R.M. (2010, January 21–24). The ‘deception’ of code smells: An empirical investigation. Proceedings of the ITI 2010—32nd International Conference on Information Technology Interfaces, Cavtat/Dubrovnik, Croatia.
20. Sehgal, R., Nagpal, R., and Mehrotra, D. (2019, January 21–22). Measuring Code Smells and Anti-Patterns. Proceedings of the 2019 4th International Conference on Information Systems and Computer Networks (ISCON), Mathura, India.
21. Sae-Lim, N., Hayashi, S., and Saeki, M. (2017, January 17–22). How Do Developers Select and Prioritize Code Smells? A Preliminary Study. Proceedings of the 2017 IEEE International Conference on Software Maintenance and Evolution (ICSME), Shanghai, China.10.1109/ICSME.2017.66 ↗
22. Peters, R., and Zaidman, A. (2012, January 27–30). Evaluating the Lifespan of Code Smells using Software Repository Mining. Proceedings of the 2012 16th European Conference on Software Maintenance and Reengineering, Szeged, Hungary.10.1109/CSMR.2012.79 ↗
23. Oliveira, R. (2016, January 14–22). When More Heads Are Better than One? Understanding and Improving Collaborative Identification of Code Smells. Proceedings of the 2016 IEEE/ACM 38th International Conference on Software Engineering Companion (ICSE-C), Austin, TX, USA.10.1145/2889160.2889272 ↗
24. When and Why Your Code Starts to Smell Bad (and Whether the Smells Go Away)10.1109/TSE.2017.2653105 ↗
25. A large scale study on how developers discuss code smells and anti-pattern in Stack Exchange sites10.1016/j.infsof.2020.106333 ↗
26. Van Emden, E., and Moonen, L. (November, January 28). Java Quality Assurance by Detecting Code Smells. Proceedings of the Ninth Working Conference on Reverse Engineering (WCRE’02), Richmond, VA, USA.
27. Alikacem, E.H., and Sahraoui, H.A. (2009, January 20–21). A Metric Extraction Framework Based on a High-Level Description Language. Proceedings of the 2009 Ninth IEEE International Working Conference on Source Code Analysis and Manipulation, Edmonton, AB, Canada.10.1109/SCAM.2009.27 ↗
28. Marinescu, R., and Ratiu, D. (2004, January 8–12). Quantifying the quality of object-oriented design: The factor-strategy model. Proceedings of the 11th Working Conference on Reverse Engineering, Delft, The Netherlands.
29. Rao, A., and Reddy, K. (2008). Detecting Bad Smells in Object Oriented Design Using Design Change Propagation Probability Matrix. Lecture Notes in Engineering and Computer Science, Newswood Limited.
30. Moha, N. (2007, January 21–25). Detection and correction of design defects in object-oriented designs. Proceedings of the OOPSLA ’07, Montreal, QC, USA.10.1145/1297846.1297960 ↗
31. Moha, N., Guéhéneuc, Y.G., Meur, A.F., Duchien, L., and Tiberghien, A. (2010). From a Domain Analysis to the Specification and Detection of Code and Design Smells. Form. Asp. Comput., 22.10.1007/s00165-009-0115-x ↗
32. A Domain Analysis to Specify Design Defects and Generate Detection Algorithms
33. DECOR: A Method for the Specification and Detection of Code and Design Smells10.1109/TSE.2009.50 ↗
34. Khomh, F., Di Penta, M., and Gueheneuc, Y. (2009, January 13–16). An Exploratory Study of the Impact of Code Smells on Software Change-proneness. Proceedings of the 2009 16th Working Conference on Reverse Engineering, Lille, France.10.1109/WCRE.2009.28 ↗
35. Moha, N., Gueheneuc, Y., and Leduc, P. (2006, January 18–22). Automatic Generation of Detection Algorithms for Design Defects. Proceedings of the 21st IEEE/ACM International Conference on Automated Software Engineering (ASE’06), Tokyo, Japan.10.1109/ASE.2006.22 ↗
36. Marinescu, R. (2005, January 26–29). Measurement and quality in object-oriented design. Proceedings of the 21st IEEE International Conference on Software Maintenance (ICSM’05), Budapest, Hungary.10.1109/ICSM.2005.63 ↗
37. (2020, March 27). SpotBugs. Available online: https://spotbugs.github.io.
38. Pugh, B. (2020, March 27). FindBugs. Available online: http://findbugs.sourceforge.net.
39. (2020, March 27). CheckStyle. Available online: https://checkstyle.sourceforge.io.
40. (2020, March 27). PMD: An Extensible Cross-Language Static Code Analyzer. Available online: https://pmd.github.io.
41. Mathew, A.P., and Capela, F.A. (2020, January 17). An Analysis on Code Smell Detection Tools. Proceedings of the 17th SC@ RUG 2019–2020, Groningen, The Netherlands.
42. Azadi, U., Arcelli Fontana, F., and Taibi, D. (2019, January 26–27). Architectural Smells Detected by Tools: A Catalogue Proposal. Proceedings of the 2019 IEEE/ACM International Conference on Technical Debt (TechDebt), Montreal, QC, Canada.10.1109/TechDebt.2019.00027 ↗
43. On the Definition of Microservice Bad Smells10.1109/MS.2018.2141031 ↗
44. Pigazzini, I., Fontana, F.A., Lenarduzzi, V., and Taibi, D. (July, January 24). Towards Microservice Smells Detection. Proceedings of the 42nd International Conference on Software Engineering, Seoul, Korea.
45. (2020, September 21). Logarix. AI Reviewer. Available online: http://aireviewer.com.
46. Le, D.M., Behnamghader, P., Garcia, J., Link, D., Shahbazian, A., and Medvidovic, N. (2015, January 16–17). An Empirical Study of Architectural Change in Open-Source Software Systems. Proceedings of the 2015 IEEE/ACM 12th Working Conference on Mining Software Repositories, Florence, Italy.10.1109/MSR.2015.29 ↗
47. Sharma, T. (2016, January 17). Designite—A Software Design Quality Assessment Tool. Proceedings of the 2016 IEEE/ACM 1st International Workshop on Bringing Architectural Design Thinking Into Developers’ Daily Activities (BRIDGE), Austin, TX, USA.10.1145/2896935.2896938 ↗
48. Mo, R., Cai, Y., Kazman, R., and Xiao, L. (2015, January 4–8). Hotspot Patterns: The Formal Definition and Automatic Detection of Architecture Smells. Proceedings of the 2015 12th Working IEEE/IFIP Conference on Software Architecture, Montreal, QC, Canada.10.1109/WICSA.2015.12 ↗
49. Dietrich, J. (2012, January 19–26). Upload Your Program, Share Your Model. Proceedings of the 3rd Annual Conference on Systems, Programming, and Applications: Software for Humanity, Tucson, AZ, USA, .10.1145/2384716.2384727 ↗
50. von Zitzewitz, A. (2019, January 26–27). Mitigating Technical and Architectural Debt with Sonargraph. Proceedings of the 2019 IEEE/ACM International Conference on Technical Debt (TechDebt), Montreal, QC, Canada.10.1109/TechDebt.2019.00022 ↗
51. (2020, September 21). Bugan IT Consulting UG. STAN. Available online: http://stan4j.com.
52. Headway Software Technologies Ltd (2020, September 21). Structure101. Available online: https://structure101.com.
53. Cerny, T., Svacina, J., Das, D., Bushong, V., Bures, M., Tisnovsky, P., Frajtak, K., Shin, D., and Huang, J. (2020). On Code Analysis Opportunities and Challenges for Enterprise Systems and Microservices. IEEE Access.10.1109/ACCESS.2020.3019985 ↗
54. Kumar, K.S., and Malathi, D. (2017, January 22–24). A Novel Method to Find Time Complexity of an Algorithm by Using Control Flow Graph. Proceedings of the 2017 International Conference on Technical Advancements in Computers and Communications (ICTACC), Kochi, India.10.1109/ICTACC.2017.26 ↗
55. Ribeiro, J.C.B., de Vega, F.F., and Zenha-Rela, M. (, January June). Using Dynamic Analysis Of Java Bytecode For Evolutionary Object-Oriented Unit Testing. Proceedings of the 25th Brazilian Symposium on Computer Networks and Distributed Systems (SBRC), Belem, Brazil.
56. Conventional Software Testing Using White Box Method
57. Comparison and Evaluation of Code Clone Detection Techniques and Tools: A Qualitative Approach10.1016/j.scico.2009.02.007 ↗
58. Selim, G.M.K., Foo, K.C., and Zou, Y. (2010, January 13–16). Enhancing Source-Based Clone Detection Using Intermediate Representation. Proceedings of the 2010 17th Working Conference on Reverse Engineering, Beverly, MA, USA.10.1109/WCRE.2010.33 ↗
59. Hanus, M. (2007). Verification of Java Bytecode Using Analysis and Transformation of Logic Programs. Practical Aspects of Declarative Languages, Springer.
60. SeByte: Scalable clone and similarity search for bytecode10.1016/j.scico.2013.10.006 ↗
61. Keivanloo, I., Roy, C.K., and Rilling, J. (2012, January 4). Java Bytecode Clone Detection via Relaxation on Code Fingerprint and Semantic Web Reasoning. Proceedings of the 6th International Workshop on Software Clones, Zurich, Switzerland.10.1109/IWSC.2012.6227864 ↗
62. Lau, D. (2020, March 27). An Abstract Syntax Tree Generator from Java Bytecode. Available online: https://github.com/davidlau325/BytecodeASTGenerator.
63. Software Clone Detection: A review
64. Gabel, M., Jiang, L., and Su, Z. (2008, January 10–18). Scalable Detection of Semantic Clones. Proceedings of the 30th International Conference on Software Engineering, Leipzig, Germany.10.1145/1368088.1368132 ↗
65. Su, F.H., Bell, J., Harvey, K., Sethumadhavan, S., Kaiser, G., and Jebara, T. (2016, January 13–18). Code Relatives: Detecting Similarly Behaving Software. Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, Seattle, WA, USA.10.1145/2950290.2950321 ↗
66. Makai, M. (2020, March 27). Object-Relational Mappers (ORMs). Available online: https://www.fullstackpython.com/object-relational-mappers-orms.html.
67. Kim, K.J., and Kim, H.Y. (2020). On Automated Role-Based Access Control Assessment in Enterprise Systems. Information Science and Applications, Springer.10.1007/978-981-15-1465-4 ↗
68. Securing Internet of Things Devices Using the Network Context10.1109/TII.2019.2954100 ↗
69. Svacina, J., Simmons, J., and Cerny, T. (April, January 30). Semantic Code Clone Detection for Enterprise Applications. Proceedings of the 35th ACM/SIGAPP Symposium On Applied Computing, Brno, Czech Republic.
70. Torres, A., Galante, R., and Pimenta, M.S. (2009, January 5–9). Towards a uml profile for model-driven object-relational mapping. Proceedings of the 2009 XXIII Brazilian Symposium on Software Engineering, Fortaleza, Brazil.10.1109/SBES.2009.22 ↗
71. Aspect-driven, data-reflective and context-aware user interfaces design10.1145/2577554.2577561 ↗
72. Nurcan, S., Reinhartz-Berger, I., Soffer, P., and Zdravkovic, J. (2020). A Modeling Method for Systematic Architecture Reconstruction of Microservice-Based Software Systems. Enterprise, Business-Process and Information Systems Modeling, Springer International Publishing.10.1007/978-3-030-49418-6 ↗
73. Alshuqayran, N., Ali, N., and Evans, R. (May, January 30). Towards Micro Service Architecture Recovery: An Empirical Study. Proceedings of the 2018 IEEE International Conference on Software Architecture (ICSA), Seattle, WA, USA.10.1109/ICSA.2018.00014 ↗
74. Granchelli, G., Cardarelli, M., Di Francesco, P., Malavolta, I., Iovino, L., and Di Salle, A. (2017, January 5–7). Towards Recovering the Software Architecture of Microservice-Based Systems. Proceedings of the 2017 IEEE International Conference on Software Architecture Workshops (ICSAW), Gothenburg, Sweden.10.1109/ICSAW.2017.48 ↗
75. Tarjan, R. (1971, January 13–15). Depth-first search and linear graph algorithms. Proceedings of the 12th Annual Symposium on Switching and Automata Theory (SWAT 1971), East Lansing, MI, USA.10.1109/SWAT.1971.10 ↗
76. Márquez, G., and Astudillo, H. (2019, January 9–13). Identifying Availability Tactics to Support Security Architectural Design of Microservice-Based Systems. Proceedings of the 13th European Conference on Software Architecture, Paris, France.10.1145/3344948.3344996 ↗
77. Aderaldo, C.M., Mendonça, N.C., Pahl, C., and Jamshidi, P. (2017, January 22). Benchmark Requirements for Microservices Architecture Research. Proceedings of the 1st International Workshop on Establishing the Community-Wide Infrastructure for Architecture-Based Software Engineering, Buenos Aires, Argentina.10.1109/ECASE.2017.4 ↗
78. Chaudron, M., Crnkovic, I., Chechik, M., and Harman, M. (June, January 27). Benchmarking microservice systems for software engineering research. Proceedings of the 40th International Conference on Software Engineering: Companion Proceeedings, Gothenburg, Sweden.
79. Smid, A., Wang, R., and Cerny, T. (2019, January 24–27). Case Study on Data Communication in Microservice Architecture. Proceedings of the Conference on Research in Adaptive and Convergent Systems, Chongqing, China.10.1145/3338840.3355659 ↗
80. Mantyla, M., Vanhanen, J., and Lassenius, C. (2003, January 22–26). A taxonomy and an initial empirical study of bad smells in code. Proceedings of the International Conference on Software Maintenance, Amsterdam, The Netherlands.