UNPKG

agentsqripts

Version:

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

42 lines (35 loc) 1.13 kB
/** * @file Extract dependencies used in the block * @description Single responsibility: Find imports and requires within a code block */ /** * Extract dependencies (imports, requires) used in the block */ function extractDependencies(node, fullContent) { const dependencies = new Set(); // This is a simplified version - could be enhanced with full scope analysis const blockContent = fullContent.substring(node.range[0], node.range[1]); // Find requires const requires = blockContent.match(/require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g); if (requires) { requires.forEach(req => { const match = req.match(/require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/); if (match) dependencies.add(match[1]); }); } // Find common library calls const libraryPatterns = [ /\bfs\./g, /\bpath\./g, /\bcrypto\./g, /\bBuffer\./g, /\bprocess\./g ]; libraryPatterns.forEach(pattern => { if (pattern.test(blockContent)) { dependencies.add(pattern.source.replace(/\\b|\\.|\/g/g, '')); } }); return Array.from(dependencies); } module.exports = extractDependencies;