UNPKG

agentsqripts

Version:

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

23 lines (21 loc) 756 B
/** * @file Get loop type from AST node * @description Single responsibility: Determine the type of loop from an AST node */ /** * Get human-readable loop type * @param {Object} loopNode - Loop AST node * @returns {string} Loop type description */ function getLoopType(loopNode) { if (loopNode.type === 'ForStatement') return 'for loop'; if (loopNode.type === 'WhileStatement') return 'while loop'; if (loopNode.type === 'DoWhileStatement') return 'do-while loop'; if (loopNode.type === 'ForInStatement') return 'for-in loop'; if (loopNode.type === 'ForOfStatement') return 'for-of loop'; if (loopNode.type === 'CallExpression') { return `${loopNode.callee.property.name} loop`; } return 'loop'; } module.exports = getLoopType;