UNPKG

agentsqripts

Version:

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

67 lines (53 loc) 2.35 kB
/** * @file SRP project recommendation generator * @description Generates project-wide SRP recommendations */ /** * Generate project-wide SRP recommendations * @param {Array} violations - Array of violation results * @returns {string[]} Array of project recommendations */ function generateProjectSRPRecommendations(violations) { const recommendations = []; const criticalFiles = violations.filter(v => v.severity === 'CRITICAL').length; const highFiles = violations.filter(v => v.severity === 'HIGH').length; if (criticalFiles > 0) { recommendations.push(`Address ${criticalFiles} critical SRP violations immediately`); } if (highFiles > 0) { recommendations.push(`Refactor ${highFiles} files with high SRP violations`); } const commonClusters = {}; for (const v of violations) { if (v.details && v.details.foundClusters) { for (const cluster of v.details.foundClusters) { commonClusters[cluster.clusterType] = (commonClusters[cluster.clusterType] || 0) + 1; } } } const topConcerns = Object.entries(commonClusters) .sort(([,a], [,b]) => b - a) .slice(0, 3) .map(([type]) => type); if (topConcerns.length > 0) { recommendations.push(`Focus refactoring on separating: ${topConcerns.join(', ')}`); } // Add balanced AI token efficiency guidance const filesWithManyFunctions = violations.filter(v => v.details && v.details.functionCount > 5 ).length; const filesWithModerate = violations.filter(v => v.details && v.details.functionCount >= 3 && v.details.functionCount <= 5 ).length; if (filesWithManyFunctions > 0) { recommendations.push(`AI TOKEN OPTIMIZATION: ${filesWithManyFunctions} files have 5+ functions. These significantly impact AI token usage and should be prioritized for refactoring.`); } if (filesWithModerate > 0) { recommendations.push(`BALANCED APPROACH: ${filesWithModerate} files have 3-5 functions. Evaluate if refactoring benefits outweigh organizational overhead. Focus on files with complex or large functions.`); } recommendations.push(`GUIDANCE: Don't over-refactor files with 1-2 small helper functions. Focus on files where AI token reduction provides clear benefits.`); return recommendations; } module.exports = { generateProjectSRPRecommendations };