agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
35 lines (29 loc) • 1.07 kB
JavaScript
/**
* @file Generate higher-order function recommendation
* @description Single responsibility: Create recommendation for using higher-order functions
*/
function generateHigherOrderFunctionRecommendation(group, projectContext) {
const { blocks } = group;
return {
type: 'USE_HIGHER_ORDER_FUNCTION',
title: 'Refactor to use higher-order functions',
description: `${blocks.length} array processing patterns can use functional approach`,
impact: {
linesReduced: blocks.reduce((sum, b) => sum + (b.endLine - b.startLine), 0) * 0.5,
filesAffected: new Set(blocks.map(b => b.file)).size,
maintainability: 'HIGH',
effort: 'MEDIUM'
},
implementation: {
approach: 'Replace loops with map/filter/reduce',
example: 'Use array methods for cleaner, more functional code'
},
benefits: [
'More declarative code',
'Improved readability',
'Easier composition',
'Better performance potential'
]
};
}
module.exports = generateHigherOrderFunctionRecommendation;