agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
24 lines (21 loc) • 776 B
JavaScript
/**
* @file Barrel file detection
* @description Detects if a file is a barrel file (re-exports only)
*/
/**
* Check if a file is a barrel file (contains mainly re-exports)
* @param {string} content - File content to analyze
* @returns {boolean} True if file appears to be a barrel file
*/
function isBarrelFile(content) {
const lines = content.split('\n').filter(line => line.trim());
const exportLines = lines.filter(line =>
line.includes('export') && (line.includes('from') || line.includes('* from'))
);
// If more than 80% of non-empty lines are re-exports, consider it a barrel file
const exportRatio = exportLines.length / Math.max(lines.length, 1);
return exportRatio > 0.8 && exportLines.length > 2;
}
module.exports = {
isBarrelFile
};