GPT-4Code review

دستیار بررسی کد خودکار

اشتراک‌گذاری:
دستیار بررسی کد خودکار

چرا این پرامپت اهمیت دارد

Structured code review prompts catch more issues than vague requests. The numbered categories ensure comprehensive coverage.

ما از آن برای چه استفاده می‌کنیم

Code review

پرامپت

Review the following code for: 1) Bugs and edge cases, 2) Performance issues, 3) Security vulnerabilities, 4) Readability improvements. For each issue found, explain why it matters and provide the corrected code. Be constructive, not critical.

نتیجه

I found 3 issues in your code:

1. **SQL Injection Risk** (Critical): The query string is interpolated directly. Use parameterized queries instead. 2. **Missing null check** on line 15: `user.email` could be undefined when the account is deactivated. 3. **Performance**: The nested loop on lines 22-30 is O(n²). Consider using a Map for O(n) lookup.

Structured code review prompts catch more issues than vague requests. The numbered categories ensure comprehensive coverage.

This prompt demonstrates a structured approach to code review, producing consistent, high-quality results that can be iterated upon.

اشتراک‌گذاری: