47/ 50
+ 핵심 오류와 결제 안전성 개선을 간결히 제시했다.
- 통화 반올림 정책을 코드에 명시하지 않았다.
코드 조각, 언어, 중점 영역을 넣으면 버그, 최적화, 코딩 표준, 모범 사례 관점의 피드백을 제공합니다.
| 분류 | 개발 › 코딩 |
|---|---|
| 태그 | 검토분석개발자코드 |
Act as a Code Review Expert. You are an experienced software developer with extensive knowledge in code analysis and improvement. Your task is to review the code provided by the user, focusing on areas such as quality, efficiency, and adherence to best practices. You will:
- Identify potential bugs and suggest fixes
- Evaluate the code for optimization opportunities
- Ensure compliance with coding standards and conventions
- Provide constructive feedback to improve the codebase
Rules:
- Maintain a professional and constructive tone
- Focus on the given code and language specifics
- Use examples to illustrate points when necessary
Variables:
- ${codeSnippet} - the code snippet to review
- ${language:JavaScript} - the programming language of the code
- ${focusAreas:quality, efficiency} - specific areas to focus on during the review주어진 코드에 대한 건설적인 리뷰를 받을 때 쓰는 범용 개발 프롬프트다. 예시를 들어 설명하게 하며, 기본 언어는 JavaScript로 설정되어 있다.
ChatGPT가 정확성과 간결성의 균형이 가장 좋다. Gemini는 상세하지만 장황하고 방어 코드에 결함이 있으며, [C]는 답이 없다.
+ 핵심 오류와 결제 안전성 개선을 간결히 제시했다.
- 통화 반올림 정책을 코드에 명시하지 않았다.
+ 버그·비동기·보안 문제를 폭넓고 구체적으로 다뤘다.
- 잘못된 값을 0으로 숨기며 원인을 일부 과단정했다.
| 기준 | ChatGPT | Gemini | 앞선 모델 |
|---|---|---|---|
| 지시 준수 | 10 | 10 | 동점 |
| 정확성 | 9 | 7 | ChatGPT +29% |
| 구체성 | 10 | 9 | ChatGPT +11% |
| 구성·가독성 | 9 | 9 | 동점 |
| 분량 적정성 | 9 | 6 | ChatGPT +50% |
gpt-5.6-sol가 모델 이름을 가린 채 1~10점으로 채점했습니다 (2026-09-24). 측정값이 아니라 AI 심사 결과입니다.
같은 입력을 세 모델에 넣어 받은 답을 그대로 옮겼습니다. 각 CLI(에이전트 하네스)에서 실행했습니다. ChatGPT·Claude 앱이나 웹에서는 답이 다를 수 있습니다.
[붙여 넣은 자료]
언어: JavaScript
집중 리뷰 영역: 품질, 효율성, 잠재적 버그
장바구니 결제 로직인데 가끔 합계가 이상하게 나온다는 문의가 들어와서 리뷰 부탁드립니다.
function calculateTotal(items) {
let total = 0;
for (let i = 0; i <= items.length; i++) {
total += items[i].price * items[i].qty;
}
return total;
}
function applyDiscount(total, coupon) {
if (coupon == null) return total;
if (coupon.type == "percent") {
return total - (total * coupon.value / 100);
} else {
return total - coupon.value;
}
}
async function checkout(cart) {
let total = calculateTotal(cart.items);
total = applyDiscount(total, cart.coupon);
fetch('/api/order', {
method: 'POST',
body: JSON.stringify({ total })
});
console.log('주문 완료');
}가장 큰 원인은 calculateTotal의 반복 조건입니다.
for (let i = 0; i <= items.length; i++)
배열의 마지막 유효 인덱스는 items.length - 1이므로, 마지막 반복에서 items[items.length]가 undefined가 됩니다. 그 결과 items[i].price 접근 시 예외가 발생합니다.
수정 예시는 다음과 같습니다.
function calculateTotal(items) {
if (!Array.isArray(items)) {
throw new TypeError('items must be an array');
}
return items.reduce((total, item) => {
const price = Number(item.price);
const qty = Number(item.qty);
if (!Number.isFinite(price) || !Number.isFinite(qty) || qty < 0) {
throw new TypeError('Invalid price or quantity');
}
return total + price * qty;
}, 0);
}
function applyDiscount(total, coupon) {
if (!coupon) return total;
let discountedTotal;
if (coupon.type === 'percent') {
const percent = Number(coupon.value);
if (!Number.isFinite(percent) || percent < 0 || percent > 100) {
throw new RangeError('Invalid discount percentage');
}
discountedTotal = total * (1 - percent / 100);
} else if (coupon.type === 'fixed') {
const discount = Number(coupon.value);
if (!Number.isFinite(discount) || discount < 0) {
throw new RangeError('Invalid fixed discount');
}
discountedTotal = total - discount;
} else {
throw new TypeError('Unknown coupon type');
}
return Math.max(0, discountedTotal);
}
async function checkout(cart) {
const subtotal = calculateTotal(cart.items);
const total = applyDiscount(subtotal, cart.coupon);
const response = await fetch('/api/order', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ total })
});
if (!response.ok) {
throw new Error(`Order failed: ${response.status}`);
}
console.log('주문 완료');
}
추가로 확인할 사항은 다음과 같습니다.
fetch를 await하지 않아 API 요청이 실패해도 "주문 완료"가 먼저 출력됩니다.Content-Type 헤더가 없어 서버가 JSON 본문을 제대로 해석하지 못할 수 있습니다.==와 문자열 비교 대신 ===를 사용하는 것이 안전합니다.| 방산 CV 12개월 로드맵 프롬프트 | |
| 2046 퍼즐 게임 제작 프롬프트 | |
| React 컴포넌트 통합 프롬프트 | |
| 3D 아바타 팩토리 요구 프롬프트 | |
| 3D FPS 게임 개발 프롬프트 |