UNPKG

agentsqripts

Version:

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

19 lines (14 loc) 649 B
/** * @file Calculate lines reduced by refactoring * @description Single responsibility: Estimate code reduction from refactoring */ function calculateLinesReduced(blocks) { if (blocks.length < 2) return 0; const avgLinesPerBlock = blocks.reduce((sum, b) => sum + (b.endLine - b.startLine + 1), 0) / blocks.length; // Estimate: (n-1) * avgLines - overhead for new function const duplicateLinesRemoved = (blocks.length - 1) * avgLinesPerBlock; const overheadLines = 10; // New function definition + imports return Math.max(0, Math.floor(duplicateLinesRemoved - overheadLines)); } module.exports = calculateLinesReduced;