AI Chat Paper
Note: Please note that the following content is generated by AMiner AI. SciOpen does not take any responsibility related to this content.
{{lang === 'zh_CN' ? '文章概述' : 'Summary'}}
{{lang === 'en_US' ? '中' : 'Eng'}}
Chat more with AI
PDF (3 MB)
Collect
Submit Manuscript AI Chat Paper
Show Outline
Outline
Show full outline
Hide outline
Outline
Show full outline
Hide outline
Article | Open Access

Constrained LLM-Guided Refactoring of JavaScript: A Smell-Targeted Transformation Framework with Human-in-the-Loop Validation

Emir KuanyshevHashim Ali( )
Department of Computer Science, Nazarbayev University, Astana, Kazakhstan
Show Author Information

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.

References

【1】
【1】
 
 
Computers, Materials & Continua

{{item.num}}

Comments on this article

Go to comment

< Back to all reports

Review Status: {{reviewData.commendedNum}} Commended , {{reviewData.revisionRequiredNum}} Revision Required , {{reviewData.notCommendedNum}} Not Commended Under Peer Review

Review Comment

Close
Close
Cite this article:
Kuanyshev E, Ali H. Constrained LLM-Guided Refactoring of JavaScript: A Smell-Targeted Transformation Framework with Human-in-the-Loop Validation. Computers, Materials & Continua, 2026, 88(1). https://doi.org/10.32604/cmc.2026.080737

4

Views

0

Downloads

0

Crossref

0

Web of Science

0

Scopus

Received: 13 February 2026
Accepted: 08 April 2026
Published: 08 May 2026
© The Author 2026.

This work is licensed under a Creative Commons Attribution 4.0 International License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.