UNPKG

agentsqripts

Version:

Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems

44 lines (38 loc) 1.18 kB
/** * @file Technical debt score calculation * @description Calculates and categorizes technical debt scores */ /** * Calculates technical debt score * @param {Object} metrics - Code metrics * @param {Array<Object>} indicators - Debt indicators * @returns {number} Debt score (0-100, higher is more debt) */ function calculateTechnicalDebtScore(metrics, indicators) { let score = 0; // Base score from complexity score += Math.min(30, metrics.cyclomaticComplexity); score += Math.min(30, metrics.cognitiveComplexity * 0.5); score += Math.min(20, (metrics.linesOfCode - 200) * 0.05); // Add points for indicators indicators.forEach(indicator => { const points = { HIGH: 10, MEDIUM: 5, LOW: 2 }[indicator.severity] || 3; score += points; }); return Math.min(100, Math.max(0, score)); } /** * Categorizes debt level based on score * @param {number} score - Debt score * @returns {string} Debt level */ function categorizeDebtLevel(score) { if (score > 70) return 'CRITICAL'; if (score > 50) return 'HIGH'; if (score > 30) return 'MEDIUM'; return 'LOW'; } module.exports = { calculateTechnicalDebtScore, categorizeDebtLevel };