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 refacto...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.展开更多
Software systems have been employed in many fields as a means to reduce human efforts;consequently,stakeholders are interested in more updates of their capabilities.Code smells arise as one of the obstacles in the sof...Software systems have been employed in many fields as a means to reduce human efforts;consequently,stakeholders are interested in more updates of their capabilities.Code smells arise as one of the obstacles in the software industry.They are characteristics of software source code that indicate a deeper problem in design.These smells appear not only in the design but also in software implementation.Code smells introduce bugs,affect software maintainability,and lead to higher maintenance costs.Uncovering code smells can be formulated as an optimization problem of finding the best detection rules.Although researchers have recommended different techniques to improve the accuracy of code smell detection,these methods are still unstable and need to be improved.Previous research has sought only to discover a few at a time(three or five types)and did not set rules for detecting their types.Our research improves code smell detection by applying a search-based technique;we use the Whale Optimization Algorithm as a classifier to find ideal detection rules.Applying this algorithm,the Fisher criterion is utilized as a fitness function to maximize the between-class distance over the withinclass variance.The proposed framework adopts if-then detection rules during the software development life cycle.Those rules identify the types for both medium and large projects.Experiments are conducted on five open-source software projects to discover nine smell types that mostly appear in codes.The proposed detection framework has an average of 94.24%precision and 93.4%recall.These accurate values are better than other search-based algorithms of the same field.The proposed framework improves code smell detection,which increases software quality while minimizing maintenance effort,time,and cost.Additionally,the resulting classification rules are analyzed to find the software metrics that differentiate the nine code smells.展开更多
Code smell is the product of improper design and operation,which may be introduced in many situations.It will cause serious problems for further software development and maintenance.Currently,most code smell detection...Code smell is the product of improper design and operation,which may be introduced in many situations.It will cause serious problems for further software development and maintenance.Currently,most code smell detection methods detect through a single type of software data.There are restrictions on detecting code smells with complex definitions and characteristics.In this paper,an approach of applying multi-dimensional software data is proposed.A complex network was built through structural data and historical version data,and code smell instances were determined by searching the network.We designed two smells detection strategies were designed and evaluated them in four open source projects.The results demonstrate that the proposed method has 23%and 15%higher F-measures on Shotgun Surgery and Parallel Inheritance Hierarchy than the existing mainstream detection ways.The code smell detection based on multi-dimensional software data and complex network is effective,and this method of processing multidimensional software data is also applicable for data-driven software research.展开更多
摘要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.
摘要Software systems have been employed in many fields as a means to reduce human efforts;consequently,stakeholders are interested in more updates of their capabilities.Code smells arise as one of the obstacles in the software industry.They are characteristics of software source code that indicate a deeper problem in design.These smells appear not only in the design but also in software implementation.Code smells introduce bugs,affect software maintainability,and lead to higher maintenance costs.Uncovering code smells can be formulated as an optimization problem of finding the best detection rules.Although researchers have recommended different techniques to improve the accuracy of code smell detection,these methods are still unstable and need to be improved.Previous research has sought only to discover a few at a time(three or five types)and did not set rules for detecting their types.Our research improves code smell detection by applying a search-based technique;we use the Whale Optimization Algorithm as a classifier to find ideal detection rules.Applying this algorithm,the Fisher criterion is utilized as a fitness function to maximize the between-class distance over the withinclass variance.The proposed framework adopts if-then detection rules during the software development life cycle.Those rules identify the types for both medium and large projects.Experiments are conducted on five open-source software projects to discover nine smell types that mostly appear in codes.The proposed detection framework has an average of 94.24%precision and 93.4%recall.These accurate values are better than other search-based algorithms of the same field.The proposed framework improves code smell detection,which increases software quality while minimizing maintenance effort,time,and cost.Additionally,the resulting classification rules are analyzed to find the software metrics that differentiate the nine code smells.
基金Anhui Provincial Natural Science Foundation(2008085MF189,1908085MF206)National Natural Science Foundation of China(NO.61402007)the Scientific Research Foundation for the Returned Overseas Chinese Scholars,State Education Ministry.
摘要Code smell is the product of improper design and operation,which may be introduced in many situations.It will cause serious problems for further software development and maintenance.Currently,most code smell detection methods detect through a single type of software data.There are restrictions on detecting code smells with complex definitions and characteristics.In this paper,an approach of applying multi-dimensional software data is proposed.A complex network was built through structural data and historical version data,and code smell instances were determined by searching the network.We designed two smells detection strategies were designed and evaluated them in four open source projects.The results demonstrate that the proposed method has 23%and 15%higher F-measures on Shotgun Surgery and Parallel Inheritance Hierarchy than the existing mainstream detection ways.The code smell detection based on multi-dimensional software data and complex network is effective,and this method of processing multidimensional software data is also applicable for data-driven software research.