arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2112.06186cs.SE
收藏

Nalin:从命名行为中发现命名-价值的内在联系

Nalin: Learning from Runtime Behavior to Find Name-Value Inconsistencies in Jupyter Notebooks

Jibesh Patra, Michael Pradel

摘要:

变量名对于理解和维护代码很重要。如果变量名和存储在变量中的值不匹配,则程序会出现名称-值不一致,这是由于开发人员可能希望修复的两种情况之一:通过误导性名称引用正确的值,这对代码的可理解性和可维护性产生负面影响,或者正确的名称绑定到错误的值,这可能导致意外的运行时行为。查找名称-值不一致是很困难的,因为它需要理解名称的含义以及有关在运行时分配给变量的值的知识。本文介绍了Nalin,一种自动检测名称-值不一致的技术。该方法结合了一个动态分析,它跟踪名称的值分配,并结合了一个神经机器学习模型,预测名称和值是否匹配。据我们所知,这是第一次将发现编码问题的问题公式化为名称和运行时值的分类问题。我们将Nalin应用于106,652个真实的Python程序,由于没有静态声明的类型,有意义的名称特别重要。我们的研究结果表明,分类器检测名称值不一致的准确性很高,Nalin报告的警告有80%的精度和76%的召回w.r.t.用户研究中创建的基本事实,并且我们的方法补充了查找编码问题的现有技术。

英文摘要:

Variable names are important to understand and maintain code. If a variable name and the value stored in the variable do not match, then the program suffers from a name-value inconsistency, which is due to one of two situations that developers may want to fix: Either a correct value is referred to through a misleading name, which negatively affects code understandability and maintainability, or the correct name is bound to a wrong value, which may cause unexpected runtime behavior. Finding name-value inconsistencies is hard because it requires an understanding of the meaning of names and knowledge about the values assigned to a variable at runtime. This paper presents Nalin, a technique to automatically detect name-value inconsistencies. The approach combines a dynamic analysis that tracks assignments of values to names with a neural machine learning model that predicts whether a name and a value fit together. To the best of our knowledge, this is the first work to formulate the problem of finding coding issues as a classification problem over names and runtime values. We apply Nalin to 106,652 real-world Python programs, where meaningful names are particularly important due to the absence of statically declared types. Our results show that the classifier detects name-value inconsistencies with high accuracy, that the warnings reported by Nalin have a precision of 80% and a recall of 76% w.r.t. a ground truth created in a user study, and that our approach complements existing techniques for finding coding issues.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑