KG2Code: Correct Code Examples Mining Service Based on Knowledge Graph for Fixing API Misuses

Yangqi Zhang,Zhirui Kuai,Wenjin Yao,Zhiyang Zhang,Li Kuang
DOI: https://doi.org/10.1007/978-3-030-91431-8_65
2021-01-01
Abstract:API misuse has become an important factor restricting the quality of software services. Existing API misuse detectors based on the API-constraint knowledge graph can not intuitively assist developers in fixing the API misuse. Correct code examples are more direct and straightforward for developers to modify and debug code. Therefore, we first enrich the API-constraint knowledge graph. Besides, we publish a service called KG2Code, which can map the API-constraint Knowledge Graph to the Correct Code examples. According to the different types of constraint relations in the API-constraint knowledge graph, we design a code snippet mining framework that extracts the corresponding correct API usage pattern from over 9528K Java repositories GitHub. KG2Code is implemented by the interactive visualization website. It helped users (1) learn how to use an unfamiliar API or fix an API misuse and (2) understand why API misuse occurs.
What problem does this paper attempt to address?