UNPKG

agentsqripts

Version:

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

29 lines (24 loc) 963 B
/** * @file Check if operations are sequential not nested * @description Single responsibility: Determine if two loops are sequential rather than nested */ /** * Check if two operations are sequential (not nested) */ function checkSequentialNotNested(lines, outerIndex, innerIndex) { // Check if the outer operation closes before the inner starts let braceDepth = 0; let parenDepth = 0; for (let i = outerIndex; i < innerIndex; i++) { const line = lines[i]; // Count braces and parentheses braceDepth += (line.match(/{/g) || []).length - (line.match(/}/g) || []).length; parenDepth += (line.match(/\(/g) || []).length - (line.match(/\)/g) || []).length; // If we've closed all braces/parens before the inner operation, they're sequential if (i > outerIndex && braceDepth <= 0 && parenDepth <= 0) { return true; // Sequential, not nested } } return false; } module.exports = checkSequentialNotNested;