Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions test-review.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Test file to trigger AI review

function calculateDiscount(price, discount) {
var total = price - discount;
return total / discount;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BUG] Division by zero risk if discount is zero. Add check to prevent division by zero.

}

function getUserData(userId) {
const query = "SELECT * FROM users WHERE id = " + userId;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SECURITY] SQL injection risk by directly concatenating user input into query. Use parameterized queries or ORM to prevent injection.

return fetch("/api/query?sql=" + query);
}

function processItems(items) {
for (let i = 0; i < items.length; i++) {
for (let j = 0; j < items.length; j++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PERF] O(n²) complexity due to nested loops for duplicate check. Use a Set or Map to track seen IDs for O(n) complexity.

if (items[i].id === items[j].id) {
console.log("duplicate");
}
}
}
}

const API_KEY = "sk-1234567890abcdef";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SECURITY] Hardcoded API key. Remove from source code and use environment variables or secure vaults.