Abstract
Refactoring improves maintainability without altering externally observable behavior, yet it remains costly and error-prone when applied manually at scale. While large language models (LLMs) can generate plausible refactorings, practical adoption is limited by uncontrolled edit scope, inconsistent outputs under stochastic decoding, and weak traceability of why a change was produced. This paper proposes a smell-targeted, scope-bound refactoring framework for JavaScript that couples deterministic AST-based smell detection with constrained LLM transformation. The key design principle is to bind generation to explicitly detected smell instances, enforce a structured output contract (refactored code plus per-smell rationale), and log full refactoring artifacts for repeatable evaluation. We implement the framework as a microservice-based prototype (detector, prompt construction and routing, orchestrator, analytics, and UI) and evaluate it on LeetCode-style solutions and multiple GitHub repositories. Across the evaluated projects, the approach achieves an average smell reduction of 83.96% and an average maintainability index improvement of +5.366, while maintaining a mean developer acceptance rate of 91.66%. A targeted temperature study identifies an operating point around 0.4 that maximizes acceptance (approximately 95% in controlled trials), balancing determinism with sufficient flexibility for structure-improving edits. These results suggest that explicit scope control and structured traceability are central to making LLM-based refactoring reliable and reviewable, and motivate future integration with automated validation (tests, linting) and repository-conditioned policies.
| Original language | English |
|---|---|
| Article number | 78 |
| Journal | Computers, Materials and Continua |
| Volume | 88 |
| Issue number | 1 |
| DOIs | |
| Publication status | Published - Apr 23 2026 |
UN SDGs
This output contributes to the following UN Sustainable Development Goals (SDGs)
-
SDG 3 Good Health and Well-being
-
SDG 9 Industry, Innovation, and Infrastructure
Keywords
- automated refactoring
- code smell detection
- constrained generation
- human-in-the-loop evaluation
- JavaScript
- Large language models
- maintainability index
ASJC Scopus subject areas
- Biomaterials
- Modelling and Simulation
- Mechanics of Materials
- Computer Science Applications
- Electrical and Electronic Engineering
Fingerprint
Dive into the research topics of 'Constrained LLM-Guided Refactoring of JavaScript: A Smell-Targeted Transformation Framework with Human-in-the-Loop Validation'. Together they form a unique fingerprint.Cite this
- APA
- Standard
- Harvard
- Vancouver
- Author
- BIBTEX
- RIS