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
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
吴宣京发布了新的文献求助10
刚刚
Xu_bl发布了新的文献求助10
1秒前
1秒前
Chem完成签到,获得积分10
1秒前
1秒前
1秒前
传奇3应助tutu采纳,获得10
2秒前
666发布了新的文献求助20
2秒前
啪叽米关注了科研通微信公众号
2秒前
3秒前
苦柒完成签到,获得积分10
4秒前
情怀应助小花采纳,获得10
4秒前
细心醉柳发布了新的文献求助10
4秒前
Xinyuanpeng发布了新的文献求助10
6秒前
可耐的张发布了新的文献求助10
6秒前
科研通AI6.2应助weizhuo采纳,获得10
6秒前
隐形曼青应助weizhuo采纳,获得10
7秒前
7秒前
8秒前
8秒前
9秒前
Aio完成签到,获得积分10
9秒前
科研通AI6.2应助Jackie采纳,获得10
10秒前
wink16完成签到,获得积分10
10秒前
10秒前
11秒前
11秒前
11秒前
11秒前
研友_O8Wz4Z完成签到,获得积分10
12秒前
12秒前
Summer发布了新的文献求助30
12秒前
12秒前
13秒前
SciGPT应助彩虹捕手采纳,获得10
13秒前
独特若南发布了新的文献求助10
13秒前
华仔应助微冷采纳,获得10
13秒前
竹林皓月完成签到,获得积分10
13秒前
机灵柚子应助惜灵采纳,获得20
13秒前
Lucas应助无心的翰采纳,获得10
13秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
HYDROLYSE ACIDE DE QUELQUES DIOXASPIROCYCLANES 1314
Essentials of Carbohydrate Chemistry and Biochemistry, 4th Edition 800
Navigating Normative Orders. Interdisciplinary Perspectives 800
1 Peter and Christ's Descent to the Dead in Its Early Christian Reception 700
Organizational Behavior 510
Management and the Arts 510
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 内科学 物理 复合材料 催化作用 细胞生物学 无机化学 光电子学 物理化学 电极 基因
热门帖子
关注 科研通微信公众号,转发送积分 7748916
求助须知:如何正确求助?哪些是违规求助? 9296863
关于积分的说明 20237292
捐赠科研通 7330160
什么是DOI,文献DOI怎么找? 3309041
关于科研通互助平台的介绍 2460655
邀请新用户注册赠送积分活动 2321165