UNPKG

agentsqripts

Version:

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

27 lines (20 loc) 897 B
/** * @file Check if functions are related * @description Single responsibility: Determine if functions share common purpose */ function areRelatedFunctions(blocks) { if (!blocks || blocks.length < 2) return false; // Extract function names const names = blocks.map(b => b.name || '').filter(Boolean); if (names.length < blocks.length / 2) return false; // Too many anonymous // Check for common prefixes or suffixes const commonPrefixes = ['get', 'set', 'handle', 'process', 'validate', 'format']; const hasCommonPrefix = commonPrefixes.some(prefix => names.filter(name => name.toLowerCase().startsWith(prefix)).length > blocks.length / 2 ); // Check if they're in the same file or module const files = new Set(blocks.map(b => b.file)); const sameFile = files.size === 1; return hasCommonPrefix || sameFile; } module.exports = areRelatedFunctions;