agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
48 lines (44 loc) • 2 kB
JavaScript
/**
* @file Block comment validation utility for orphaned documentation detection
* @description Single responsibility: Validate block comments to identify orphaned or outdated documentation patterns
*
* This validator implements specialized heuristics for analyzing block comments to determine
* whether they represent orphaned documentation that should be flagged for review or removal.
* It examines comment content, length, and patterns to distinguish between valuable
* documentation and outdated or irrelevant block comments that detract from code quality.
*
* Design rationale:
* - Length-based filtering identifies substantial documentation that should generally be preserved
* - Pattern-based detection catches common orphaned comment indicators like debug statements
* - Conservative validation approach minimizes false positives for valuable documentation
* - Block-specific analysis handles multi-line comment patterns appropriately
* - Targeted orphaned pattern recognition focuses on genuinely problematic comment types
*
* Block comment validation criteria:
* - Length assessment preserves substantial documentation (>200 characters) as likely valid
* - Debug pattern detection identifies development-time comments that may be orphaned
* - Temporary marker recognition catches comments indicating incomplete or temporary code
* - Content analysis examines comment text for indicators of outdated or irrelevant information
* - Systematic validation enables automated code quality improvement workflows
*/
/**
* Check if block comment is likely orphaned
*/
function isLikelyOrphanedBlock(text) {
// Large block comments are usually valid documentation
if (text.length > 200) {
return false;
}
// Check for outdated patterns
const orphanedPatterns = [
/console\.log/i,
/debug/i,
/temp/i,
/remove/i,
/delete/i
];
return orphanedPatterns.some(pattern => pattern.test(text));
}
module.exports = {
isLikelyOrphanedBlock
};