Copilot Refinement: Addressing Code Smells in Copilot-Generated Python Code

要約

最も人気のある動的言語の 1 つである Python では、コードに臭いが存在すると、可読性と保守性が低下します。
大規模言語モデルの最近の進歩により、コード生成とリファクタリングの両方を行う AI 対応ツールへの関心が高まっています。
GitHub Copilot は、広く使用されているツールの 1 つです。
2023 年 9 月にリリースされた Copilot Chat は、自然言語を利用したコーディングを容易にすることを目的とした対話型ツールとして機能します。
ただし、Copilot で生成された Python コードのコード匂いの理解や、生成されるコード匂いを修正する Copilot の機能については、あまり注目されていません。
この目的を達成するために、Copilot で生成された Python コードで 102 のコード匂いを含むデータセットを構築しました。
私たちの目的は、まず Copilot で生成された Python コードでのコード臭の発生を調査し、次にさまざまなプロンプトを使用してこれらのコード臭を修正する際の Copilot の有効性を評価することです。
結果は、10 種類の Python の匂いのうち 8 種類が Copilot で生成された Python コードで検出でき、その中で最も一般的なのは Multiply-Nested Container であることを示しています。
これらのコード臭については、Copilot Chat は 87.1% という最高の修正率を達成しており、Copilot 自体によって生成された Python コード匂いの修正が期待できることを示しています。
さらに、より詳細なプロンプトを提供することで、これらの臭いを修正する Copilot Chat の有効性を向上させることができます。
ただし、Copilot Chat を使用してこれらの臭いを修正すると、新しいコードの臭いが発生する可能性があります。

要約(オリジナル)

As one of the most popular dynamic languages, Python experiences a decrease in readability and maintainability when code smells are present. Recent advancements in Large Language Models have sparked growing interest in AI-enabled tools for both code generation and refactoring. GitHub Copilot is one such tool that has gained widespread usage. Copilot Chat, released on September 2023, functions as an interactive tool aims at facilitating natural language-powered coding. However, limited attention has been given to understanding code smells in Copilot-generated Python code and Copilot’s ability to fix the code smells it generates. To this end, we built a dataset comprising 102 code smells in Copilot-generated Python code. Our aim is to first explore the occurrence of code smells in Copilot-generated Python code and then evaluate the effectiveness of Copilot in fixing these code smells employing different prompts. The results show that 8 out of 10 types of Python smells can be detected in Copilot-generated Python code, among which Multiply-Nested Container is the most common one. For these code smells, Copilot Chat achieves a highest fixing rate of 87.1%, showing promise in fixing Python code smells generated by Copilot itself. Besides, the effectiveness of Copilot Chat in fixing these smells can be improved with the provision of more detailed prompts. However, using Copilot Chat to fix these smells might introduce new code smells.

arxiv情報

著者 Beiqi Zhang,Peng Liang,Qiong Feng,Yujia Fu,Zengyang Li
発行日 2024-01-25 13:39:54+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.SE パーマリンク