# Automated Code-Smell Detection in Microservices Through Static Analysis: A Case Study
## 3 Microservice Code Smell Catalogue  
For this paper's purposes, we reused the definition of eleven microservice specific code smells from a recent exploratory study by [PERSON] et al. [43]. They used existing literature and interviews with industry leaders to distill and rank these eleven code smells for microservices. The code smells are briefly summarized as follows:  
* _ESB Usage (EU)_: An Enterprise Service Bus (ESB) [2] is a way of message passing between modules of a distributed application in which one module acts as a service bus for all of the other modules to pass messages on. There are pros and cons to this approach. However, in microservices, it can become an issue of creating a single point of failure, and increasing coupling, so it should be avoided. An example is displayed in Figure 1.
* _Too Many Standards (MS)_: Given the distributed nature of the microservice application, multiple discrete teams of developers often work on a given module, separate from the other teams. This can create a situation where multiple frameworks are used when a standard should be established for consistency across the modules. * _Wrong Cuts (WC)_: This occurs when microservices are split into their technical layers (presentation, business, and data layers). Microservices are supposed to be split by features, and each fully contains their domain's presentation, business, and data layers. * _Not Having an API Gateway (NAG)_: The API gateway pattern is a design pattern for managing the connections between microservices. In large, complex systems, this should be used to reduce the potential issues of direct communication. * _Hard-Coded Endpoints (HCE)_: Hardcoded IP addresses and ports are used to communicate between services. By hardcoding the endpoints, the application becomes more brittle to change and reduces the application's scalability. * _API Versioning (AV)_: All Application Programming Interfaces (API) should be versioned to keep track of changes properly. * _Microservice Greedy (MG)_: This occurs when microservices are created for every new feature, and, oftentimes, these new modules are too small and do not serve many purposes. This increases complexity and the overhead of the system. Smaller features should be wrapped into larger microservices if possible. * _Shared Persistency (SP)_: When two microservice application modules access the same database, it breaks the microservice definition. Each microservice should have autonomy and control over its data and database. An example is provided in Figure 2.
* _Inappropriate Service Intimacy (ISI)_: One module requesting private data from a separate module also breaks the microservice definition. Each microservice should have control over its private data. An example is given in Figure 3.
* _Shared Libraries (SL)_: If microservices are coupled with a common library, that library should be refactored into a separate module. This reduces the fragility of the application by migrating the shared functionality behind a common, unchanging interface. This will make the system resistant to ripples from changes within the library. * _Cyclic Dependency (CD)_: This occurs when there is a cyclic connection between calls to different modules. This can cause repetitive calls and also increase the complexity of understanding call traces for developers. This is a poor architectural practice for microservices. Figure 1: Example ESB usage. Figure 3: Inappropriate service intimacy. Figure 2: Shared persistency. To highlight the gap in microservice code smells, we took a list of existing state-of-the-art architecture-specific code-smell detection tools from a previous and recent study [42] and verified whether they detect any of the previously mentioned microservice-specific code smells. We chose these tools as they were compiled to study the existing state of the art of architecture smell detection tools and were shown to meet a minimum threshold of documentation and information about the tool.