feat: add AI code review documentation, demonstration project, and update guidelines

This commit is contained in:
2026-06-26 17:05:00 +07:00
parent 7f99c55963
commit 852c9bc9c8
11 changed files with 296 additions and 103 deletions
+22
View File
@@ -0,0 +1,22 @@
# PR: Thêm tính năng hủy đơn hàng (cancel order)
Diff thêm vào cuối `src/services/orderService.js`:
```diff
@@ src/services/orderService.js @@
+function toMoney(n) { // hàm format tiền tự viết
+ return n.toLocaleString('vi-VN') + ' đ';
+}
+
+export async function cancelOrder(id) {
+ const order = await getOrder(id);
+ order.status = 'cancelled'; // cập nhật trạng thái
+ await db.orders.save(order);
+ return `Đã hủy đơn. Hoàn ${toMoney(order.total)}`;
+}
```
## Hai lỗi được cài (đáp án cho người trình bày — KHÔNG chiếu)
1. **Lỗi business:** `cancelOrder` không kiểm tra `order.status` → hủy được cả đơn đã `shipped`,
vi phạm rule trong CLAUDE.md. Chỉ phát hiện được nếu AI đọc business rule.
2. **Lỗi maintainability:** `toMoney()` trùng chức năng `formatCurrency()` đã có ở `src/lib/format.js`.