UNPKG

agentsqripts

Version:

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

34 lines (28 loc) 839 B
/** * @file Line normalization utilities * @description Responsible for normalizing code lines for comparison */ /** * Normalizes code lines for comparison * @param {string} line - Code line to normalize * @param {Object} options - Normalization options * @returns {string} Normalized line */ function normalizeLine(line, options = {}) { const { ignoreComments = true, ignoreWhitespace = true } = options; let normalized = line; if (ignoreComments) { // Remove single-line comments normalized = normalized.replace(/\/\/.*$/g, ''); // Remove inline block comments normalized = normalized.replace(/\/\*.*?\*\//g, ''); } if (ignoreWhitespace) { // Normalize whitespace normalized = normalized.trim().replace(/\s+/g, ' '); } return normalized; } module.exports = { normalizeLine };