# Enhancing Software Quality with AI: A Transformer-Based Approach for Code Smell Detection
## 1 Introduction  
Modern software systems are increasingly complex, making maintainability, clarity, and early error detection essential to ensure long-term quality. Code smell is a term introduced to describe indicative patterns suggesting deeper design flaws [1]; it is a surface symptom in source code that may signal problems such as technical debt or suboptimal architecture. One particularly critical instance is the large class smell, where a class becomes excessively large in terms of lines of code, responsibilities, or complexity, ultimately hindering maintainability and extensibility. In today's increasingly complex software landscapes, the cost of undetected code smells extends far beyond mere inconvenience. Code smells are not only symptomatic of immediate design flaws but also serve as early indicators of accumulating technical debt issues that can compound over time, leading to higher maintenance costs and reducedsystem reliability. By detecting these faults early, organizations can preemptively address potential sources of error and inefficiency, ultimately safeguarding long-term software quality and developer productivity. In this context, our study introduces Relation-Aware BERT (RABERT), a transformer-based model enhanced with relational embeddings. This model is designed to overcome the limitations of traditional methods that often rely on static feature engineering and fail to capture the intricate semantic and structural relationships inherent in modern codebases. By directly modeling these interdependencies, RABERT offers a more robust and proactive approach to identifying critical issues such as the large class smell. Traditional methods for detecting these design anomalies have primarily relied on manual feature engineering and rule-based systems that use predefined metrics (e.g., lines of code, coupling, and cohesion) to identify problematic areas [1]. While effective to an extent, such approaches often fail to capture the nuanced semantic relationships inherent in modern software systems. In contrast, transformer-based models pioneered by works like [PERSON]'s [2] have revolutionized natural language processing by learning complex contextual patterns automatically. Recently, adaptations such as CodeBERT [3] and GraphCodeBERT [4] have extended these techniques to software code, yet they typically employ standard self-attention mechanisms that overlook explicit modeling of inter-metric dependencies. The use of primarily transformer-based algorithms, especially the applied BERT model, has entirely transformed natural language understanding since models can comprehend contextual dependencies in a text. As observed in these success stories, transformers have been applied to code analysis tasks based on the structural and semantic similarities of code and natural language as inputs to transformers. Building upon the transformer model, [PERSON] [5] proposed an accurate detection of numerous kinds of code smells using a CoRT model that learns semantic and structural representations of source code through self-supervision. Similarly, the SCSmell [6] model combines pre-trained models along with the help of stacking methods, highlighting the role of textual characteristics inside the code analysis and surpassing the studies' accurate results compared with other conventional methods. The breakthrough work by [PERSON] [2] laid the foundation for these models, which have since been adapted for programming language tasks as seen in CodeBERT [3] and GraphCodeBERT [4]. However, there are still some problems in implementing a solid approach for modeling the structural relations of the various abstract components of code. We are proposing Hierarchical BERT and Relation-Aware BERT (RABERT) to overcome these limitations and to adapt to improving automated detection. Hierarchical BERT is based on encoding interconnections in various hierarchical structures, such as methods and classes; on the other hand, RABERT involves relational embeddings to signify relations among code elements directly.