paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Are code examples on an online Q&A forum reliable?

在线问答论坛中的代码示例可靠吗?
ICSE Proceedings of the 40th International Conference on Software Engineering2018匹配度 2/10 · 该论文属于程序分析与开发者工具,研究 Stack Overflow 上 API 误用的挖掘与检测,但未涉及 LLM/Agent、ML 系统静态分析、浮点程序分析或贝叶斯程序分析等用户核心方向,匹配度低。引用 172 inbox
Tianyi Zhang, Ganesha Upadhyaya, Anastasia Reinhardt, Hridesh Rajan, Miryung Kim
crossref: 2026-09-12

AI 速览

一句话:通过 ExampleCheck 挖掘 GitHub API 使用模式,发现 Stack Overflow 上 31% 的帖子可能存在 API 误用。

程序员常借助 Stack Overflow 等在线问答论坛学习 API,但其中的代码示例是否可靠尚缺系统证据。本文对 Stack Overflow 上 API 误用的普遍性与严重性进行实证研究,并提出 ExampleCheck:一个 API 使用挖掘框架,先从 GitHub 超过 38 万个 Java 仓库中提取 API 使用模式,再据此检测问答帖子中的潜在违规。作者分析 217,818 个帖子,发现 31% 可能存在会导致程序崩溃、资源泄漏等意外行为的 API 误用。误用主要源于缺失控制结构、API 调用缺失或顺序错误、守卫条件错误。即便被采纳或高赞的答案,在 API 误用方面也不一定更可靠。研究呼吁补充策展示例中通常未展示的替代 API 用法信息。

问题
在线问答论坛的代码示例是否可靠、API 误用有多普遍和多严重,缺乏系统实证。
方法
提出 ExampleCheck,从 GitHub 超 38 万个 Java 仓库挖掘 API 使用模式,并检测 Stack Overflow 帖子中的潜在 API 使用违规。
评估
分析 217,818 个 Stack Overflow 帖子,发现 31% 可能含 API 误用,且被采纳或高赞的答案未必更可靠。
原文摘要(Abstract)

Programmers often consult an online Q&A forum such as Stack Overflow to learn new APIs. This paper presents an empirical study on the prevalence and severity of API misuse on Stack Overflow. To reduce manual assessment effort, we design ExampleCheck, an API usage mining framework that extracts patterns from over 380K Java repositories on GitHub and subsequently reports potential API usage violations in Stack Overflow posts. We analyze 217,818 Stack Overflow posts using ExampleCheck and find that 31% may have potential API usage violations that could produce unexpected behavior such as program crashes and resource leaks. Such API misuse is caused by three main reasons---missing control constructs, missing or incorrect order of API calls, and incorrect guard conditions. Even the posts that are accepted as correct answers or upvoted by other programmers are not necessarily more reliable than other posts in terms of API misuse. This study result calls for a new approach to augment Stack Overflow with alternative API usage details that are not typically shown in curated examples.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot4482,
  title = {Are code examples on an online Q&A forum reliable?},
  author = {Tianyi Zhang and Ganesha Upadhyaya and Anastasia Reinhardt and Hridesh Rajan and Miryung Kim},
  booktitle = {ICSE},
  year = {2018},
  doi = {10.1145/3180155.3180260}
}