// JavaScript sample file with technical debt comments function calculateTotal(items) { // TODO: This should use reduce instead of a loop let total = 0; for (let i = 0; i < items.length; i++) { total += items[i].price; } return total; } function fetchUserData(userId) { // FIXME: API error handling is missing // FIXME: This endpoint may return null return fetch(`/api/users/${userId}`) .then(response => response.json()); } function processPayment(amount) { // HACK: Quick fix for holiday season if (amount > 1000) { console.log("High value transaction"); } // TODO: Implement proper payment processing } function createUser(name, email) { // NOTE: Email validation is basic if (!email.includes('@')) { throw new Error('Invalid email'); } return { name, email }; } class DataProcessor { constructor() { this.data = []; // XXX: Memory leak - data is never cleared } addItem(item) { this.data.push(item); } process() { // BUG: This doesn't handle edge cases return this.data.map(x => x * 2); } } // TODO: Add JSDoc comments // TODO: Write unit tests async function loadConfig() { // FIXME: Hardcoded path should be configurable const response = await fetch('/config.json'); return response.json(); } function temporaryFix() { // TEMP: Remove this after Q1 return { status: 'pending' }; } function oldCode() { // REFACTOR: This code is legacy let result = 0; for (let i = 0; i < 10; i++) { result += i; } return result; } module.exports = { calculateTotal, fetchUserData, processPayment, createUser, DataProcessor, loadConfig, };