Automated Recommendation of Extracting Local Variable Refactorings

计算机科学 变量(数学) 情报检索 数据挖掘 数学 数学分析
作者
Yanjie Jiang,Xiaye Chi,Yuxia Zhang,Weixing Ji,Guangjie Li,Weixiao Wang,Yunni Xia,Lu Zhang,Hui Liu
出处
期刊:ACM Transactions on Software Engineering and Methodology [Association for Computing Machinery]
卷期号:34 (8): 1-42 被引量:3
标识
DOI:10.1145/3715110
摘要

Extracting local variable refactoring is frequently employed to replace one or more occurrences of a complex expression with simple accesses to a newly introduced variable. To facilitate refactoring, most IDEs can automate the extract local variable refactorings when the to-be-extracted expressions are selected by developers. However, refactoring tools usually replace all expressions that are lexically identical to the selected one without a comprehensive analysis of the safety of the refactoring. The automatically conducted refactorings may lead to serious software defects. Besides that, existing refactoring tools rely heavily on software developers to spot to-be-extracted expressions although it is often challenging for inexperienced developers and maintainers to make the selection. To this end, in this article, we propose an automated approach, called ValExtractor+ , to recommending extract local variable refactoring opportunities and to automatically and safely conduct the refactorings. ValExtractor+ is composed of two parts, i.e., solutionAdvisor and opportunityAdvisor . Given a to-be-extracted expression, solutionAdvisor leverages lightweight static source code analysis to validate potential side effects of the expression, and to identify expressions that could be extracted together with the selected expression as a single variable without changing the semantics of the program or introducing any new exceptions. The static code analysis significantly improves the safety of automated extraction of local variables. To free programmers from manually selecting to-be-extracted expressions, opportunityAdvisor leverages solutionAdvisor to automatically retrieve all expressions that could be extracted safely as well as their refactoring solutions. It then leverages a learning-based classifier to predict which of the retrieved expressions should be extracted. Evaluations on open-source applications suggest that solutionAdvisor successfully avoided all defects (more than two hundred) caused by extracting local variable refactorings conducted by Eclipse (243 defects) or IntelliJ IDEA (263 defects). Additionally, opportunityAdvisor was able to effectively recommend expressions for extraction, achieving 307 true positives (TP) and 21,121 true negatives (TN). Four pull requests from our work (PR IDs: 66, 333, 439, and 360) were successfully merged into the Eclipse community repository, showcasing the practical impact and robustness of our approach as recognized by the wider developer community.
最长约 10秒,即可获得该文献文件

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
raven456发布了新的文献求助10
1秒前
白嫖论文完成签到 ,获得积分10
1秒前
丘比特应助瞿寒采纳,获得10
2秒前
卡乐李发布了新的文献求助10
4秒前
llmm完成签到,获得积分10
9秒前
112完成签到,获得积分10
9秒前
呼延坤完成签到 ,获得积分10
10秒前
单纯的忆安完成签到 ,获得积分10
12秒前
Copyright应助llmm采纳,获得10
14秒前
chen完成签到,获得积分10
14秒前
14秒前
Yvan发布了新的文献求助10
14秒前
瞿寒发布了新的文献求助10
21秒前
某某完成签到,获得积分10
21秒前
欢喜新晴完成签到,获得积分10
22秒前
小米_M完成签到 ,获得积分10
23秒前
jinger完成签到 ,获得积分10
25秒前
Yvan完成签到,获得积分10
29秒前
jiaojaioo完成签到,获得积分10
31秒前
maclogos完成签到,获得积分10
35秒前
xiong完成签到,获得积分10
36秒前
回首不再是少年完成签到,获得积分0
41秒前
求助完成签到,获得积分10
43秒前
糖雪完成签到 ,获得积分10
49秒前
曈曦完成签到 ,获得积分10
51秒前
Hao完成签到,获得积分0
53秒前
独指蜗牛完成签到 ,获得积分10
56秒前
yaosan完成签到,获得积分10
56秒前
cocofan完成签到 ,获得积分10
1分钟前
哥哥完成签到,获得积分10
1分钟前
晨雾锁阳完成签到 ,获得积分10
1分钟前
科研通AI6.2应助Brave采纳,获得10
1分钟前
ty完成签到 ,获得积分10
1分钟前
ljw完成签到 ,获得积分10
1分钟前
眼睛大夜白完成签到 ,获得积分10
1分钟前
牛黄完成签到 ,获得积分10
1分钟前
李煜琛完成签到 ,获得积分10
1分钟前
他有篮完成签到 ,获得积分10
1分钟前
学术山芋完成签到,获得积分10
1分钟前
慕容杏子完成签到 ,获得积分10
1分钟前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
Single Cell Analysis of the Tumor Microenvironment Landscape Across the Disease Spectrum of Multiple Myeloma 1000
2026年中国辛酸癸酸聚乙二醇甘油酯行业市场现状调查及投资机会研判报告 1000
2026年中国辛酸癸酸聚乙二醇甘油酯行业市场规模及竞争格局分析报告 1000
模型平均及其应用 900
Fundamentals of Pharmaceutical and Biologics Regulations: A Global Perspective, Second Edition 700
The Cambridge History of China 英文版16册 600
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 内科学 物理 复合材料 催化作用 细胞生物学 无机化学 光电子学 物理化学 电极 基因
热门帖子
关注 科研通微信公众号,转发送积分 7331503
求助须知:如何正确求助?哪些是违规求助? 8945951
关于积分的说明 18975207
捐赠科研通 6985822
什么是DOI,文献DOI怎么找? 3216880
关于科研通互助平台的介绍 2383416
邀请新用户注册赠送积分活动 2196527