UNPKG

agentsqripts

Version:

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

27 lines (22 loc) 827 B
/** * @file Check if node is array loop method * @description Single responsibility: Check if AST node represents an array looping method */ /** * Check if a node represents an array method that loops * @param {Object} node - AST node * @returns {boolean} True if node is an array loop method */ function isArrayLoopMethod(node) { if (!node || node.type !== 'CallExpression') { return false; } const loopMethods = ['forEach', 'map', 'filter', 'reduce', 'some', 'every', 'find', 'findIndex']; // Check for method calls like array.forEach() if (node.callee && node.callee.type === 'MemberExpression' && node.callee.property && node.callee.property.type === 'Identifier') { return loopMethods.includes(node.callee.property.name); } return false; } module.exports = isArrayLoopMethod;