一句话:提出基于图的 CPatMiner,从海量仓库中挖掘细粒度语义代码变更模式,并在开发者调查与对比中验证有效性。
现有代码变更重复性挖掘多依赖语法相似性,难以准确检测语义变更模式。本文提出 CPatMiner,利用细粒度变更图捕获程序依赖,从大规模仓库中挖掘真实世界未知的重复性语义代码变更模式。在 GitHub 5,000+ 项目、170,000+ 开发者语料上评估:108 名开发者中 70% 认可模式有意义,79% 为其命名,44% 希望 IDE 自动化;相比 AST 方法多检测 2.1 倍有意义模式。在 88 个项目、164M SLOC 上构建 322K 变更图、3M 节点,检测 17K 实例,发现 75% 个人模式与他人共享且随时间广泛分布,并呼吁建立社区变更模式数据库。
Prior research exploited the repetitiveness of code changes to enable several tasks such as code completion, bug-fix recommendation, library adaption, etc. These and other novel applications require accurate detection of semantic changes, but the state-of-the-art methods are limited to algorithms that detect specific kinds of changes at the syntactic level. Existing algorithms relying on syntactic similarity have lower accuracy, and cannot effectively detect semantic change patterns. We introduce a novel graph-based mining approach, CPatMiner, to detect previously unknown repetitive changes in the wild, by mining fine-grained semantic code change patterns from a large number of repositories. To overcome unique challenges such as detecting meaningful change patterns and scaling to large repositories, we rely on fine-grained change graphs to capture program dependencies. We evaluate CPatMiner by mining change patterns in a diverse corpus of 5,000+ open-source projects from GitHub across a population of 170,000+ developers. We use three complementary methods. First, we sent the mined patterns to 108 open-source developers. We found that 70% of respondents recognized those patterns as their meaningful frequent changes. Moreover, 79% of respondents even named the patterns, and 44% wanted future IDEs to automate such repetitive changes. We found that the mined change patterns belong to various development activities: adaptive (9%), perfective (20%), corrective (35%) and preventive (36%, including refactorings). Second, we compared our tool with the state-of-the-art, AST-based technique, and reported that it detects 2.1x more meaningful patterns. Third, we use CPatMiner to search for patterns in a corpus of 88 GitHub projects with longer histories consisting of 164M SLOCs. It constructed 322K fine-grained change graphs containing 3M nodes, and detected 17K instances of change patterns from which we provide unique insights on the practice of change patterns among individuals and teams. We found that a large percentage (75%) of the change patterns from individual developers are commonly shared with others, and this holds true for teams. Moreover, we found that the patterns are not intermittent but spread widely over time. Thus, we call for a community-based change pattern database to provide important resources in novel applications.
@inproceedings{NguyenNDNTH19,
title = {Graph-Based Mining of In-the-Wild, Fine-Grained, Semantic Code Change Patterns},
author = {Hoan Anh Nguyen and Tien N. Nguyen and Danny Dig and Son Nguyen and Hieu Tran and Michael Hilton},
booktitle = {ICSE},
year = {2019},
doi = {10.1109/icse.2019.00089}
}