FROM CODE SMELL DETECTION TO REFACTORING RECOMMENDATION: AN EXPLAINABLE RELATION-AWARE TRANSFORMER FRAMEWORK

Authors

  • Israr Ali Author
  • Ali Ahmed Siddiqui Author
  • Aarij Mahmood Hussaan Author

Keywords:

Software refactoring; Code smells; Refactoring recommendation; Relation-aware BERT; Explainable AI; Software metrics; Software maintainability

Abstract

Software refactoring improves maintainability without changing external behavior, but many intelligent code smell studies stop at detecting problematic code and provide limited support for selecting actionable refactoring operations. Objectives: This study investigates RABERT-RR, an explainable relation-aware transformer for predicting candidate refactoring types from code and software metrics. Recommendations are decision-support outputs and are not validated executable transformations. The framework combines CodeBERT-based source-code embeddings with normalized software metrics and a relation-aware metric layer that models dependencies among size, complexity, coupling, cohesion, Halstead, and maintainability indicators. A fusion classifier predicts refactoring operations, while SHAP and LIME explain feature influence. The model was evaluated on a Java multi-class refactoring recommendation dataset of 11,072 samples using a 70:15:15 train-validation-test split and compared with classical machine learning, deep learning, transformer-based, and LLM-based baselines. The reported experiment on 11,072 Java instances gives 0.913 accuracy and 0.902 F1-score for RABERT-RR. These headline results require reconciliation with the per-class aggregates before definitive comparative conclusions can be drawn. The existing quality summaries mix historical observations and structural estimates; they do not establish behavior-preserving improvements caused by the recommendations. Combining code representations with inter-metric relationships is a promising approach to refactoring-type recommendation. Establishing practical effectiveness requires executable transformation validation, reconciled prediction-level results, and a publicly archived replication package. This revision specifies the required validation and release protocols; it does not report their completion.

Downloads

Published

2026-09-17