UNPKG

agentsqripts

Version:

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

109 lines (95 loc) 4.07 kB
/** * @file Frontend-Backend integration command-line parser * @description Handles parsing of command-line arguments for frontend-backend analysis */ function parseFrontendBackendArgs(args) { const options = { frontendDir: './frontend', backendDir: './backend', frontendExtensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'], backendExtensions: ['.js', '.ts', '.py', '.php'], outputFormat: 'summary', severity: 'LOW', category: null }; let targetPath = '.'; for (let i = 0; i < args.length; i++) { switch (args[i]) { case '--frontend-dir': options.frontendDir = args[++i]; break; case '--backend-dir': options.backendDir = args[++i]; break; case '--frontend-ext': options.frontendExtensions = args[++i].split(','); break; case '--backend-ext': options.backendExtensions = args[++i].split(','); break; case '--output-format': options.outputFormat = args[++i]; break; case '--severity': options.severity = args[++i]; break; case '--category': options.category = args[++i]; break; default: if (!args[i].startsWith('--')) { targetPath = args[i]; } } } return { options, targetPath }; } function showFrontendBackendUsage() { console.log(`Usage: node analyze-frontend-backend.js [OPTIONS] <path> Analyzes frontend and backend code to identify integration issues including missing endpoints, unused APIs, HTTP method mismatches, and communication problems between client and server. OPTIONS: --frontend-dir <dir> Frontend directory path (default: ./frontend) --backend-dir <dir> Backend directory path (default: ./backend) --frontend-ext <exts> Frontend file extensions (default: .js,.jsx,.ts,.tsx,.vue) --backend-ext <exts> Backend file extensions (default: .js,.ts,.py,.php) --output-format <fmt> Output format: json, summary, detailed (default: summary) --severity <level> Minimum severity to report: LOW, MEDIUM, HIGH (default: LOW) --category <cat> Filter by category: "Dead Code", "API Mismatch", "HTTP Method", CORS, Authentication (default: all) --help Show this help message EXAMPLES: node analyze-frontend-backend.js . node analyze-frontend-backend.js --frontend-dir src --backend-dir api . node analyze-frontend-backend.js --output-format json --severity HIGH . node analyze-frontend-backend.js --category "API Mismatch" projects/ OUTPUT: The tool identifies integration issues by checking: - Missing backend endpoints (frontend calls with no matching backend route) - Unused backend endpoints (backend routes never called by frontend) - HTTP method mismatches (frontend uses GET, backend expects POST) - CORS configuration issues for cross-origin requests - Authentication/authorization mismatches - Response format inconsistencies SEVERITY LEVELS: 🔥 HIGH: Critical issues that will cause runtime errors ⚡ MEDIUM: Issues that affect maintainability and performance 💡 LOW: Minor improvements and optimizations CATEGORIES: 🗑️ Dead Code: Unused backend endpoints that can be removed 🔌 API Mismatch: Missing endpoints or route inconsistencies 🔄 HTTP Method: Method mismatches between frontend and backend 🌐 CORS: Cross-origin configuration issues 🔐 Authentication: Auth and authorization inconsistencies 📊 Data Format: Response format and structure mismatches INTEGRATION METRICS: - API Coverage: Percentage of frontend calls with matching backend endpoints - Endpoint Utilization: Percentage of backend endpoints used by frontend - Method Alignment: HTTP method consistency between layers - Integration Score: Overall health score (0-100) FIX RECOMMENDATIONS: Each issue includes specific recommendations, effort estimates, and impact descriptions.`); } module.exports = { parseFrontendBackendArgs, showFrontendBackendUsage };