UNPKG

agentsqripts

Version:

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

50 lines (46 loc) 2.28 kB
/** * @file Refactoring effort estimator for resource planning and prioritization * @description Single responsibility: Estimate refactoring effort based on comprehensive complexity metrics * * This estimator provides realistic effort assessments for code refactoring initiatives based * on complexity metrics, code size, and structural characteristics. It helps development teams * plan refactoring sprints, allocate resources effectively, and prioritize improvement efforts * based on expected return on investment. * * Design rationale: * - Multi-metric approach provides more accurate effort estimation than single complexity measures * - Graduated effort scaling reflects non-linear relationship between complexity and refactoring time * - Time-based estimates enable practical sprint planning and resource allocation * - Priority-based classification helps teams focus on highest-impact refactoring opportunities * - Conservative estimation prevents under-planning of refactoring initiatives * * Estimation methodology: * - Complexity metric weighting balances cyclomatic, cognitive, and structural complexity factors * - Size-based adjustments account for the additional effort required for larger code units * - Non-linear scaling reflects increased difficulty of refactoring highly complex code * - Priority classification guides resource allocation for maximum improvement impact * - Time-based output enables integration with project planning and sprint allocation processes */ /** * Estimates effort required to refactor based on complexity metrics * @param {number} value - Metric value * @param {string} type - Type of metric * @returns {string} Effort estimate */ function estimateRefactorEffort(value, type) { const thresholds = { complexity: { LOW: 15, MEDIUM: 25, HIGH: 35 }, cognitive: { LOW: 20, MEDIUM: 30, HIGH: 40 }, file_size: { LOW: 400, MEDIUM: 600, HIGH: 800 }, function_count: { LOW: 20, MEDIUM: 30, HIGH: 40 }, nesting: { LOW: 5, MEDIUM: 7, HIGH: 10 } }; const threshold = thresholds[type]; if (!threshold) return 'MEDIUM'; if (value > threshold.HIGH) return 'HIGH'; if (value > threshold.MEDIUM) return 'MEDIUM'; return 'LOW'; } module.exports = { estimateRefactorEffort };