Facebook pixel tracking

The Science and Information (SAI) Organization publishes open-access peer-reviewed journals in computer science and artificial intelligence.

Contact Info
Website thesai.org
Follow Us
Contact Info
Follow Us
Research Article | Open Access |

Enhancing Code Quality Through Automated Refactoring Using Transformer-Based Language Models

Author 1: A. Sri Lakshmi Author 2: E. S. Sharmila Sigamany Author 3: Roopa Traisa Author 4: Raman Kumar Author 5: Karaka Ramakrishna Reddy Author 6: Jasgurpreet Singh Chohan Author 7: Aseel Smerat
International Journal of Advanced Computer Science and Applications (IJACSA) · Vol. 16, No. 9 · Published 2025

DOI: https://doi.org/10.14569/IJACSA.2025.0160951

Abstract

Maintaining high-quality source code is crucial for software reliability, scalability, and maintainability. Traditional refactoring methods, which involve manual code improvement or rule-based automation, often fall short due to their inability to understand the contextual semantics of code. These approaches are rigid, language-specific, and prone to inconsistencies, especially in large and complex codebases. As a result, developers spend significant time and effort identifying code smells, restructuring poorly written segments, and ensuring behavior preservation shows an accuracy of 97%. To address these limitations, this study proposes an automated code refactoring framework powered by Transformer-based language models. Leveraging models such as CodeT5, which are pre-trained on massive code corpora, this approach captures both syntax and semantic patterns to suggest intelligent, context-aware code transformations. The model is fine-tuned using a curated dataset of original and refactored code pairs to learn efficient refactoring strategies. The methodology involves preprocessing raw source code, tokenizing it for model input, and generating improved versions of the code using the trained Transformer model. Output suggestions are validated using Abstract Syntax Tree (AST) analysis and unit testing to ensure behavioral equivalence. Code quality improvements are quantified using metrics like maintainability index, cyclomatic complexity, and duplication rate. Experimental results demonstrate that the proposed method significantly enhances code readability and maintainability while reducing developer effort, outperforming traditional rule-based refactoring tools.

Keywords

How to Cite this Article

Lakshmi, A. S., Sigamany, E. S. S., Traisa, R., Kumar, R., Reddy, K. R., Chohan, J. S., & Smerat, A. (2025). Enhancing Code Quality Through Automated Refactoring Using Transformer-Based Language Models. International Journal of Advanced Computer Science and Applications, 16(9). https://doi.org/10.14569/IJACSA.2025.0160951

Lakshmi, A. Sri, et al.. "Enhancing Code Quality Through Automated Refactoring Using Transformer-Based Language Models." International Journal of Advanced Computer Science and Applications, vol. 16, no. 9, 2025, https://doi.org/10.14569/IJACSA.2025.0160951.

@article{Lakshmi2025,
  title     = {Enhancing Code Quality Through Automated Refactoring Using Transformer-Based Language Models},
  journal   = {International Journal of Advanced Computer Science and Applications},
  volume    = {16},
  number    = {9},
  year      = {2025},
  publisher = {The Science and Information Organization},
  author    = {A. Sri Lakshmi and E. S. Sharmila Sigamany and Roopa Traisa and Raman Kumar and Karaka Ramakrishna Reddy and Jasgurpreet Singh Chohan and Aseel Smerat},
  doi       = {10.14569/IJACSA.2025.0160951},
  url       = {https://doi.org/10.14569/IJACSA.2025.0160951}
}

Open Access — licensed under a Creative Commons Attribution 4.0 International License. Unrestricted use, distribution, and reproduction in any medium, even commercially, as long as the original work is properly cited.