UNPKG

agentsqripts

Version:

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

49 lines (44 loc) 1.9 kB
/** * @file Block comment extraction utility for multi-line documentation processing * @description Single responsibility: Extract complete block comments with accurate position tracking * * This extractor provides systematic block comment extraction capabilities that handle * multi-line comment patterns while maintaining accurate position information for analysis * and reporting. It implements robust parsing logic to handle various block comment formats * and edge cases, ensuring reliable extraction for downstream analysis workflows. * * Design rationale: * - Complete block extraction ensures full comment content is captured for analysis * - Position tracking provides accurate line number information for reporting and navigation * - Robust parsing handles malformed or incomplete block comments gracefully * - Null safety prevents extraction failures from corrupting analysis pipelines * - Simple interface minimizes complexity for consumers requiring block comment data * * Extraction capabilities: * - Multi-line block comment parsing with start and end boundary detection * - Accurate position tracking for both comment start and end locations * - Content normalization that preserves meaningful whitespace and formatting * - Error handling for incomplete or malformed block comment structures * - Efficient parsing algorithm that processes large files without performance degradation */ /** * Extract full block comment */ function extractBlockComment(lines, startIndex) { let text = ''; let endIndex = startIndex; for (let i = startIndex; i < lines.length; i++) { text += lines[i]; if (lines[i].includes('*/')) { endIndex = i; break; } } if (!text.includes('*/')) { return null; } return { text: text.trim(), startLine: startIndex + 1, endLine: endIndex + 1 }; } module.exports = { extractBlockComment };