Comment Traps: How Defective Commented-out Code Augment Defects in AI-Assisted Code Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Huang, Yuan, Zhou, Yukang, Chen, Xiangping, Zheng, Zibin
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866915803203371008
author Huang, Yuan
Zhou, Yukang
Chen, Xiangping
Zheng, Zibin
author_facet Huang, Yuan
Zhou, Yukang
Chen, Xiangping
Zheng, Zibin
contents With the rapid development of large language models in code generation, AI-powered editors such as GitHub Copilot and Cursor are revolutionizing software development practices. At the same time, studies have identified potential defects in the generated code. Previous research has predominantly examined how code context influences the generation of defective code, often overlooking the impact of defects within commented-out code (CO code). AI coding assistants' interpretation of CO code in prompts affects the code they generate. This study evaluates how AI coding assistants, GitHub Copilot and Cursor, are influenced by defective CO code. The experimental results show that defective CO code in the context causes AI coding assistants to generate more defective code, reaching up to 58.17 percent. Our findings further demonstrate that the tools do not simply copy the defective code from the context. Instead, they actively reason to complete incomplete defect patterns and continue to produce defective code despite distractions such as incorrect indentation or tags. Even with explicit instructions to ignore the defective CO code, the reduction in defects does not exceed 21.84 percent. These findings underscore the need for improved robustness and security measures in AI coding assistants.
format Preprint
id arxiv_https___arxiv_org_abs_2512_20334
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Comment Traps: How Defective Commented-out Code Augment Defects in AI-Assisted Code Generation
Huang, Yuan
Zhou, Yukang
Chen, Xiangping
Zheng, Zibin
Software Engineering
With the rapid development of large language models in code generation, AI-powered editors such as GitHub Copilot and Cursor are revolutionizing software development practices. At the same time, studies have identified potential defects in the generated code. Previous research has predominantly examined how code context influences the generation of defective code, often overlooking the impact of defects within commented-out code (CO code). AI coding assistants' interpretation of CO code in prompts affects the code they generate. This study evaluates how AI coding assistants, GitHub Copilot and Cursor, are influenced by defective CO code. The experimental results show that defective CO code in the context causes AI coding assistants to generate more defective code, reaching up to 58.17 percent. Our findings further demonstrate that the tools do not simply copy the defective code from the context. Instead, they actively reason to complete incomplete defect patterns and continue to produce defective code despite distractions such as incorrect indentation or tags. Even with explicit instructions to ignore the defective CO code, the reduction in defects does not exceed 21.84 percent. These findings underscore the need for improved robustness and security measures in AI coding assistants.
title Comment Traps: How Defective Commented-out Code Augment Defects in AI-Assisted Code Generation
topic Software Engineering
url https://arxiv.org/abs/2512.20334